shared-definitions.ts 6.1 KB

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