shared-definitions.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. import gql from 'graphql-tag';
  2. import {
  3. ADMINISTRATOR_FRAGMENT,
  4. ASSET_FRAGMENT,
  5. COLLECTION_FRAGMENT,
  6. COUNTRY_FRAGMENT,
  7. CURRENT_USER_FRAGMENT,
  8. CUSTOMER_FRAGMENT,
  9. FACET_WITH_VALUES_FRAGMENT,
  10. PRODUCT_VARIANT_FRAGMENT,
  11. PRODUCT_WITH_VARIANTS_FRAGMENT,
  12. ROLE_FRAGMENT,
  13. TAX_RATE_FRAGMENT
  14. } from './fragments';
  15. export const CREATE_ADMINISTRATOR = gql`
  16. mutation CreateAdministrator($input: CreateAdministratorInput!) {
  17. createAdministrator(input: $input) {
  18. ...Administrator
  19. }
  20. }
  21. ${ADMINISTRATOR_FRAGMENT}
  22. `;
  23. export const UPDATE_PRODUCT = gql`
  24. mutation UpdateProduct($input: UpdateProductInput!) {
  25. updateProduct(input: $input) {
  26. ...ProductWithVariants
  27. }
  28. }
  29. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  30. `;
  31. export const CREATE_PRODUCT = gql`
  32. mutation CreateProduct($input: CreateProductInput!) {
  33. createProduct(input: $input) {
  34. ...ProductWithVariants
  35. }
  36. }
  37. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  38. `;
  39. export const GET_PRODUCT_WITH_VARIANTS = gql`
  40. query GetProductWithVariants($id: ID!, $languageCode: LanguageCode) {
  41. product(languageCode: $languageCode, id: $id) {
  42. ...ProductWithVariants
  43. }
  44. }
  45. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  46. `;
  47. export const GET_PRODUCT_LIST = gql`
  48. query GetProductList($options: ProductListOptions, $languageCode: LanguageCode) {
  49. products(languageCode: $languageCode, options: $options) {
  50. items {
  51. id
  52. enabled
  53. languageCode
  54. name
  55. slug
  56. featuredAsset {
  57. id
  58. preview
  59. }
  60. }
  61. totalItems
  62. }
  63. }
  64. `;
  65. export const UPDATE_PRODUCT_VARIANTS = gql`
  66. mutation UpdateProductVariants($input: [UpdateProductVariantInput!]!) {
  67. updateProductVariants(input: $input) {
  68. ...ProductVariant
  69. }
  70. }
  71. ${PRODUCT_VARIANT_FRAGMENT}
  72. `;
  73. export const UPDATE_TAX_RATE = gql`
  74. mutation UpdateTaxRate($input: UpdateTaxRateInput!) {
  75. updateTaxRate(input: $input) {
  76. ...TaxRate
  77. }
  78. }
  79. ${TAX_RATE_FRAGMENT}
  80. `;
  81. export const CREATE_FACET = gql`
  82. mutation CreateFacet($input: CreateFacetInput!) {
  83. createFacet(input: $input) {
  84. ...FacetWithValues
  85. }
  86. }
  87. ${FACET_WITH_VALUES_FRAGMENT}
  88. `;
  89. export const UPDATE_FACET = gql`
  90. mutation UpdateFacet($input: UpdateFacetInput!) {
  91. updateFacet(input: $input) {
  92. ...FacetWithValues
  93. }
  94. }
  95. ${FACET_WITH_VALUES_FRAGMENT}
  96. `;
  97. export const GET_CUSTOMER_LIST = gql`
  98. query GetCustomerList($options: CustomerListOptions) {
  99. customers(options: $options) {
  100. items {
  101. id
  102. title
  103. firstName
  104. lastName
  105. emailAddress
  106. user {
  107. id
  108. verified
  109. }
  110. }
  111. totalItems
  112. }
  113. }
  114. `;
  115. export const GET_ASSET_LIST = gql`
  116. query GetAssetList($options: AssetListOptions) {
  117. assets(options: $options) {
  118. items {
  119. ...Asset
  120. }
  121. totalItems
  122. }
  123. }
  124. ${ASSET_FRAGMENT}
  125. `;
  126. export const CREATE_ROLE = gql`
  127. mutation CreateRole($input: CreateRoleInput!) {
  128. createRole(input: $input) {
  129. ...Role
  130. }
  131. }
  132. ${ROLE_FRAGMENT}
  133. `;
  134. export const CREATE_COLLECTION = gql`
  135. mutation CreateCollection($input: CreateCollectionInput!) {
  136. createCollection(input: $input) {
  137. ...Collection
  138. }
  139. }
  140. ${COLLECTION_FRAGMENT}
  141. `;
  142. export const UPDATE_COLLECTION = gql`
  143. mutation UpdateCollection($input: UpdateCollectionInput!) {
  144. updateCollection(input: $input) {
  145. ...Collection
  146. }
  147. }
  148. ${COLLECTION_FRAGMENT}
  149. `;
  150. export const GET_CUSTOMER = gql`
  151. query GetCustomer($id: ID!, $orderListOptions: OrderListOptions) {
  152. customer(id: $id) {
  153. ...Customer
  154. orders(options: $orderListOptions) {
  155. items {
  156. id
  157. code
  158. state
  159. total
  160. currencyCode
  161. updatedAt
  162. }
  163. totalItems
  164. }
  165. }
  166. }
  167. ${CUSTOMER_FRAGMENT}
  168. `;
  169. export const ATTEMPT_LOGIN = gql`
  170. mutation AttemptLogin($username: String!, $password: String!, $rememberMe: Boolean!) {
  171. login(username: $username, password: $password, rememberMe: $rememberMe) {
  172. user {
  173. ...CurrentUser
  174. }
  175. }
  176. }
  177. ${CURRENT_USER_FRAGMENT}
  178. `;
  179. export const GET_COUNTRY_LIST = gql`
  180. query GetCountryList($options: CountryListOptions) {
  181. countries(options: $options) {
  182. items {
  183. id
  184. code
  185. name
  186. enabled
  187. }
  188. totalItems
  189. }
  190. }
  191. `;
  192. export const UPDATE_COUNTRY = gql`
  193. mutation UpdateCountry($input: UpdateCountryInput!) {
  194. updateCountry(input: $input) {
  195. ...Country
  196. }
  197. }
  198. ${COUNTRY_FRAGMENT}
  199. `;
  200. export const GET_FACET_LIST = gql`
  201. query GetFacetList($options: FacetListOptions, $languageCode: LanguageCode) {
  202. facets(languageCode: $languageCode, options: $options) {
  203. items {
  204. ...FacetWithValues
  205. }
  206. totalItems
  207. }
  208. }
  209. ${FACET_WITH_VALUES_FRAGMENT}
  210. `;