shared-definitions.ts 6.1 KB

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