shared-definitions.ts 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. PROMOTION_FRAGMENT,
  13. ROLE_FRAGMENT,
  14. TAX_RATE_FRAGMENT,
  15. VARIANT_WITH_STOCK_FRAGMENT,
  16. } from './fragments';
  17. export const CREATE_ADMINISTRATOR = gql`
  18. mutation CreateAdministrator($input: CreateAdministratorInput!) {
  19. createAdministrator(input: $input) {
  20. ...Administrator
  21. }
  22. }
  23. ${ADMINISTRATOR_FRAGMENT}
  24. `;
  25. export const UPDATE_PRODUCT = gql`
  26. mutation UpdateProduct($input: UpdateProductInput!) {
  27. updateProduct(input: $input) {
  28. ...ProductWithVariants
  29. }
  30. }
  31. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  32. `;
  33. export const CREATE_PRODUCT = gql`
  34. mutation CreateProduct($input: CreateProductInput!) {
  35. createProduct(input: $input) {
  36. ...ProductWithVariants
  37. }
  38. }
  39. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  40. `;
  41. export const GET_PRODUCT_WITH_VARIANTS = gql`
  42. query GetProductWithVariants($id: ID, $slug: String) {
  43. product(slug: $slug, id: $id) {
  44. ...ProductWithVariants
  45. }
  46. }
  47. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  48. `;
  49. export const GET_PRODUCT_LIST = gql`
  50. query GetProductList($options: ProductListOptions) {
  51. products(options: $options) {
  52. items {
  53. id
  54. languageCode
  55. name
  56. slug
  57. featuredAsset {
  58. id
  59. preview
  60. }
  61. }
  62. totalItems
  63. }
  64. }
  65. `;
  66. export const CREATE_PRODUCT_VARIANTS = gql`
  67. mutation CreateProductVariants($input: [CreateProductVariantInput!]!) {
  68. createProductVariants(input: $input) {
  69. ...ProductVariant
  70. }
  71. }
  72. ${PRODUCT_VARIANT_FRAGMENT}
  73. `;
  74. export const UPDATE_PRODUCT_VARIANTS = gql`
  75. mutation UpdateProductVariants($input: [UpdateProductVariantInput!]!) {
  76. updateProductVariants(input: $input) {
  77. ...ProductVariant
  78. }
  79. }
  80. ${PRODUCT_VARIANT_FRAGMENT}
  81. `;
  82. export const UPDATE_TAX_RATE = gql`
  83. mutation UpdateTaxRate($input: UpdateTaxRateInput!) {
  84. updateTaxRate(input: $input) {
  85. ...TaxRate
  86. }
  87. }
  88. ${TAX_RATE_FRAGMENT}
  89. `;
  90. export const CREATE_FACET = gql`
  91. mutation CreateFacet($input: CreateFacetInput!) {
  92. createFacet(input: $input) {
  93. ...FacetWithValues
  94. }
  95. }
  96. ${FACET_WITH_VALUES_FRAGMENT}
  97. `;
  98. export const UPDATE_FACET = gql`
  99. mutation UpdateFacet($input: UpdateFacetInput!) {
  100. updateFacet(input: $input) {
  101. ...FacetWithValues
  102. }
  103. }
  104. ${FACET_WITH_VALUES_FRAGMENT}
  105. `;
  106. export const GET_CUSTOMER_LIST = gql`
  107. query GetCustomerList($options: CustomerListOptions) {
  108. customers(options: $options) {
  109. items {
  110. id
  111. title
  112. firstName
  113. lastName
  114. emailAddress
  115. user {
  116. id
  117. verified
  118. }
  119. }
  120. totalItems
  121. }
  122. }
  123. `;
  124. export const GET_ASSET_LIST = gql`
  125. query GetAssetList($options: AssetListOptions) {
  126. assets(options: $options) {
  127. items {
  128. ...Asset
  129. }
  130. totalItems
  131. }
  132. }
  133. ${ASSET_FRAGMENT}
  134. `;
  135. export const CREATE_ROLE = gql`
  136. mutation CreateRole($input: CreateRoleInput!) {
  137. createRole(input: $input) {
  138. ...Role
  139. }
  140. }
  141. ${ROLE_FRAGMENT}
  142. `;
  143. export const CREATE_COLLECTION = gql`
  144. mutation CreateCollection($input: CreateCollectionInput!) {
  145. createCollection(input: $input) {
  146. ...Collection
  147. }
  148. }
  149. ${COLLECTION_FRAGMENT}
  150. `;
  151. export const UPDATE_COLLECTION = gql`
  152. mutation UpdateCollection($input: UpdateCollectionInput!) {
  153. updateCollection(input: $input) {
  154. ...Collection
  155. }
  156. }
  157. ${COLLECTION_FRAGMENT}
  158. `;
  159. export const GET_CUSTOMER = gql`
  160. query GetCustomer($id: ID!, $orderListOptions: OrderListOptions) {
  161. customer(id: $id) {
  162. ...Customer
  163. orders(options: $orderListOptions) {
  164. items {
  165. id
  166. code
  167. state
  168. total
  169. currencyCode
  170. updatedAt
  171. }
  172. totalItems
  173. }
  174. }
  175. }
  176. ${CUSTOMER_FRAGMENT}
  177. `;
  178. export const ATTEMPT_LOGIN = gql`
  179. mutation AttemptLogin($username: String!, $password: String!, $rememberMe: Boolean!) {
  180. login(username: $username, password: $password, rememberMe: $rememberMe) {
  181. user {
  182. ...CurrentUser
  183. }
  184. }
  185. }
  186. ${CURRENT_USER_FRAGMENT}
  187. `;
  188. export const GET_COUNTRY_LIST = gql`
  189. query GetCountryList($options: CountryListOptions) {
  190. countries(options: $options) {
  191. items {
  192. id
  193. code
  194. name
  195. enabled
  196. }
  197. totalItems
  198. }
  199. }
  200. `;
  201. export const UPDATE_COUNTRY = gql`
  202. mutation UpdateCountry($input: UpdateCountryInput!) {
  203. updateCountry(input: $input) {
  204. ...Country
  205. }
  206. }
  207. ${COUNTRY_FRAGMENT}
  208. `;
  209. export const GET_FACET_LIST = gql`
  210. query GetFacetList($options: FacetListOptions) {
  211. facets(options: $options) {
  212. items {
  213. ...FacetWithValues
  214. }
  215. totalItems
  216. }
  217. }
  218. ${FACET_WITH_VALUES_FRAGMENT}
  219. `;
  220. export const DELETE_PRODUCT = gql`
  221. mutation DeleteProduct($id: ID!) {
  222. deleteProduct(id: $id) {
  223. result
  224. }
  225. }
  226. `;
  227. export const GET_PRODUCT_SIMPLE = gql`
  228. query GetProductSimple($id: ID, $slug: String) {
  229. product(slug: $slug, id: $id) {
  230. id
  231. slug
  232. }
  233. }
  234. `;
  235. export const GET_STOCK_MOVEMENT = gql`
  236. query GetStockMovement($id: ID!) {
  237. product(id: $id) {
  238. id
  239. variants {
  240. ...VariantWithStock
  241. }
  242. }
  243. }
  244. ${VARIANT_WITH_STOCK_FRAGMENT}
  245. `;
  246. export const GET_RUNNING_JOBS = gql`
  247. query GetRunningJobs {
  248. jobs {
  249. name
  250. state
  251. }
  252. }
  253. `;
  254. export const CREATE_PROMOTION = gql`
  255. mutation CreatePromotion($input: CreatePromotionInput!) {
  256. createPromotion(input: $input) {
  257. ...Promotion
  258. }
  259. }
  260. ${PROMOTION_FRAGMENT}
  261. `;
  262. export const ME = gql`
  263. query Me {
  264. me {
  265. ...CurrentUser
  266. }
  267. }
  268. ${CURRENT_USER_FRAGMENT}
  269. `;
  270. export const CREATE_CHANNEL = gql`
  271. mutation CreateChannel($input: CreateChannelInput!) {
  272. createChannel(input: $input) {
  273. id
  274. code
  275. token
  276. currencyCode
  277. defaultLanguageCode
  278. defaultShippingZone {
  279. id
  280. }
  281. defaultTaxZone {
  282. id
  283. }
  284. pricesIncludeTax
  285. }
  286. }
  287. `;
  288. export const DELETE_PRODUCT_VARIANT = gql`
  289. mutation DeleteProductVariant($id: ID!) {
  290. deleteProductVariant(id: $id) {
  291. result
  292. message
  293. }
  294. }
  295. `;
  296. export const ASSIGN_PRODUCT_TO_CHANNEL = gql`
  297. mutation AssignProductsToChannel($input: AssignProductsToChannelInput!) {
  298. assignProductsToChannel(input: $input) {
  299. ...ProductWithVariants
  300. }
  301. }
  302. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  303. `;
  304. export const REMOVE_PRODUCT_FROM_CHANNEL = gql`
  305. mutation RemoveProductsFromChannel($input: RemoveProductsFromChannelInput!) {
  306. removeProductsFromChannel(input: $input) {
  307. ...ProductWithVariants
  308. }
  309. }
  310. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  311. `;