1
0

shared-definitions.ts 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. import gql from 'graphql-tag';
  2. import {
  3. ADMINISTRATOR_FRAGMENT,
  4. ASSET_FRAGMENT,
  5. CHANNEL_FRAGMENT,
  6. COLLECTION_FRAGMENT,
  7. COUNTRY_FRAGMENT,
  8. CURRENT_USER_FRAGMENT,
  9. CUSTOMER_FRAGMENT,
  10. FACET_WITH_VALUES_FRAGMENT,
  11. FULFILLMENT_FRAGMENT,
  12. GLOBAL_SETTINGS_FRAGMENT,
  13. ORDER_FRAGMENT,
  14. ORDER_WITH_LINES_FRAGMENT,
  15. PRODUCT_VARIANT_FRAGMENT,
  16. PRODUCT_WITH_VARIANTS_FRAGMENT,
  17. PROMOTION_FRAGMENT,
  18. ROLE_FRAGMENT,
  19. TAX_RATE_FRAGMENT,
  20. VARIANT_WITH_STOCK_FRAGMENT,
  21. } from './fragments';
  22. export const CREATE_ADMINISTRATOR = gql`
  23. mutation CreateAdministrator($input: CreateAdministratorInput!) {
  24. createAdministrator(input: $input) {
  25. ...Administrator
  26. }
  27. }
  28. ${ADMINISTRATOR_FRAGMENT}
  29. `;
  30. export const UPDATE_PRODUCT = gql`
  31. mutation UpdateProduct($input: UpdateProductInput!) {
  32. updateProduct(input: $input) {
  33. ...ProductWithVariants
  34. }
  35. }
  36. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  37. `;
  38. export const CREATE_PRODUCT = gql`
  39. mutation CreateProduct($input: CreateProductInput!) {
  40. createProduct(input: $input) {
  41. ...ProductWithVariants
  42. }
  43. }
  44. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  45. `;
  46. export const GET_PRODUCT_WITH_VARIANTS = gql`
  47. query GetProductWithVariants($id: ID, $slug: String) {
  48. product(slug: $slug, id: $id) {
  49. ...ProductWithVariants
  50. }
  51. }
  52. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  53. `;
  54. export const GET_PRODUCT_LIST = gql`
  55. query GetProductList($options: ProductListOptions) {
  56. products(options: $options) {
  57. items {
  58. id
  59. languageCode
  60. name
  61. slug
  62. featuredAsset {
  63. id
  64. preview
  65. }
  66. }
  67. totalItems
  68. }
  69. }
  70. `;
  71. export const CREATE_PRODUCT_VARIANTS = gql`
  72. mutation CreateProductVariants($input: [CreateProductVariantInput!]!) {
  73. createProductVariants(input: $input) {
  74. ...ProductVariant
  75. }
  76. }
  77. ${PRODUCT_VARIANT_FRAGMENT}
  78. `;
  79. export const UPDATE_PRODUCT_VARIANTS = gql`
  80. mutation UpdateProductVariants($input: [UpdateProductVariantInput!]!) {
  81. updateProductVariants(input: $input) {
  82. ...ProductVariant
  83. }
  84. }
  85. ${PRODUCT_VARIANT_FRAGMENT}
  86. `;
  87. export const UPDATE_TAX_RATE = gql`
  88. mutation UpdateTaxRate($input: UpdateTaxRateInput!) {
  89. updateTaxRate(input: $input) {
  90. ...TaxRate
  91. }
  92. }
  93. ${TAX_RATE_FRAGMENT}
  94. `;
  95. export const CREATE_FACET = gql`
  96. mutation CreateFacet($input: CreateFacetInput!) {
  97. createFacet(input: $input) {
  98. ...FacetWithValues
  99. }
  100. }
  101. ${FACET_WITH_VALUES_FRAGMENT}
  102. `;
  103. export const UPDATE_FACET = gql`
  104. mutation UpdateFacet($input: UpdateFacetInput!) {
  105. updateFacet(input: $input) {
  106. ...FacetWithValues
  107. }
  108. }
  109. ${FACET_WITH_VALUES_FRAGMENT}
  110. `;
  111. export const GET_CUSTOMER_LIST = gql`
  112. query GetCustomerList($options: CustomerListOptions) {
  113. customers(options: $options) {
  114. items {
  115. id
  116. title
  117. firstName
  118. lastName
  119. emailAddress
  120. phoneNumber
  121. user {
  122. id
  123. verified
  124. }
  125. }
  126. totalItems
  127. }
  128. }
  129. `;
  130. export const GET_ASSET_LIST = gql`
  131. query GetAssetList($options: AssetListOptions) {
  132. assets(options: $options) {
  133. items {
  134. ...Asset
  135. }
  136. totalItems
  137. }
  138. }
  139. ${ASSET_FRAGMENT}
  140. `;
  141. export const CREATE_ROLE = gql`
  142. mutation CreateRole($input: CreateRoleInput!) {
  143. createRole(input: $input) {
  144. ...Role
  145. }
  146. }
  147. ${ROLE_FRAGMENT}
  148. `;
  149. export const CREATE_COLLECTION = gql`
  150. mutation CreateCollection($input: CreateCollectionInput!) {
  151. createCollection(input: $input) {
  152. ...Collection
  153. }
  154. }
  155. ${COLLECTION_FRAGMENT}
  156. `;
  157. export const UPDATE_COLLECTION = gql`
  158. mutation UpdateCollection($input: UpdateCollectionInput!) {
  159. updateCollection(input: $input) {
  160. ...Collection
  161. }
  162. }
  163. ${COLLECTION_FRAGMENT}
  164. `;
  165. export const GET_CUSTOMER = gql`
  166. query GetCustomer($id: ID!, $orderListOptions: OrderListOptions) {
  167. customer(id: $id) {
  168. ...Customer
  169. orders(options: $orderListOptions) {
  170. items {
  171. id
  172. code
  173. state
  174. total
  175. currencyCode
  176. updatedAt
  177. }
  178. totalItems
  179. }
  180. }
  181. }
  182. ${CUSTOMER_FRAGMENT}
  183. `;
  184. export const ATTEMPT_LOGIN = gql`
  185. mutation AttemptLogin($username: String!, $password: String!, $rememberMe: Boolean) {
  186. login(username: $username, password: $password, rememberMe: $rememberMe) {
  187. ...CurrentUser
  188. }
  189. }
  190. ${CURRENT_USER_FRAGMENT}
  191. `;
  192. export const GET_COUNTRY_LIST = gql`
  193. query GetCountryList($options: CountryListOptions) {
  194. countries(options: $options) {
  195. items {
  196. id
  197. code
  198. name
  199. enabled
  200. }
  201. totalItems
  202. }
  203. }
  204. `;
  205. export const UPDATE_COUNTRY = gql`
  206. mutation UpdateCountry($input: UpdateCountryInput!) {
  207. updateCountry(input: $input) {
  208. ...Country
  209. }
  210. }
  211. ${COUNTRY_FRAGMENT}
  212. `;
  213. export const GET_FACET_LIST = gql`
  214. query GetFacetList($options: FacetListOptions) {
  215. facets(options: $options) {
  216. items {
  217. ...FacetWithValues
  218. }
  219. totalItems
  220. }
  221. }
  222. ${FACET_WITH_VALUES_FRAGMENT}
  223. `;
  224. export const DELETE_PRODUCT = gql`
  225. mutation DeleteProduct($id: ID!) {
  226. deleteProduct(id: $id) {
  227. result
  228. }
  229. }
  230. `;
  231. export const GET_PRODUCT_SIMPLE = gql`
  232. query GetProductSimple($id: ID, $slug: String) {
  233. product(slug: $slug, id: $id) {
  234. id
  235. slug
  236. }
  237. }
  238. `;
  239. export const GET_STOCK_MOVEMENT = gql`
  240. query GetStockMovement($id: ID!) {
  241. product(id: $id) {
  242. id
  243. variants {
  244. ...VariantWithStock
  245. }
  246. }
  247. }
  248. ${VARIANT_WITH_STOCK_FRAGMENT}
  249. `;
  250. export const GET_RUNNING_JOBS = gql`
  251. query GetRunningJobs($options: JobListOptions) {
  252. jobs(options: $options) {
  253. items {
  254. id
  255. queueName
  256. state
  257. isSettled
  258. duration
  259. }
  260. totalItems
  261. }
  262. }
  263. `;
  264. export const CREATE_PROMOTION = gql`
  265. mutation CreatePromotion($input: CreatePromotionInput!) {
  266. createPromotion(input: $input) {
  267. ...Promotion
  268. ... on ErrorResult {
  269. errorCode
  270. message
  271. }
  272. }
  273. }
  274. ${PROMOTION_FRAGMENT}
  275. `;
  276. export const ME = gql`
  277. query Me {
  278. me {
  279. ...CurrentUser
  280. }
  281. }
  282. ${CURRENT_USER_FRAGMENT}
  283. `;
  284. export const CREATE_CHANNEL = gql`
  285. mutation CreateChannel($input: CreateChannelInput!) {
  286. createChannel(input: $input) {
  287. ...Channel
  288. ... on LanguageNotAvailableError {
  289. errorCode
  290. message
  291. languageCode
  292. }
  293. }
  294. }
  295. ${CHANNEL_FRAGMENT}
  296. `;
  297. export const DELETE_PRODUCT_VARIANT = gql`
  298. mutation DeleteProductVariant($id: ID!) {
  299. deleteProductVariant(id: $id) {
  300. result
  301. message
  302. }
  303. }
  304. `;
  305. export const ASSIGN_PRODUCT_TO_CHANNEL = gql`
  306. mutation AssignProductsToChannel($input: AssignProductsToChannelInput!) {
  307. assignProductsToChannel(input: $input) {
  308. ...ProductWithVariants
  309. }
  310. }
  311. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  312. `;
  313. export const REMOVE_PRODUCT_FROM_CHANNEL = gql`
  314. mutation RemoveProductsFromChannel($input: RemoveProductsFromChannelInput!) {
  315. removeProductsFromChannel(input: $input) {
  316. ...ProductWithVariants
  317. }
  318. }
  319. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  320. `;
  321. export const UPDATE_ASSET = gql`
  322. mutation UpdateAsset($input: UpdateAssetInput!) {
  323. updateAsset(input: $input) {
  324. ...Asset
  325. ... on Asset {
  326. focalPoint {
  327. x
  328. y
  329. }
  330. }
  331. }
  332. }
  333. ${ASSET_FRAGMENT}
  334. `;
  335. export const DELETE_ASSET = gql`
  336. mutation DeleteAsset($id: ID!, $force: Boolean) {
  337. deleteAsset(id: $id, force: $force) {
  338. result
  339. message
  340. }
  341. }
  342. `;
  343. export const UPDATE_CHANNEL = gql`
  344. mutation UpdateChannel($input: UpdateChannelInput!) {
  345. updateChannel(input: $input) {
  346. ...Channel
  347. ... on LanguageNotAvailableError {
  348. errorCode
  349. message
  350. languageCode
  351. }
  352. }
  353. }
  354. ${CHANNEL_FRAGMENT}
  355. `;
  356. export const GET_CUSTOMER_HISTORY = gql`
  357. query GetCustomerHistory($id: ID!, $options: HistoryEntryListOptions) {
  358. customer(id: $id) {
  359. id
  360. history(options: $options) {
  361. totalItems
  362. items {
  363. id
  364. administrator {
  365. id
  366. }
  367. type
  368. data
  369. }
  370. }
  371. }
  372. }
  373. `;
  374. export const GET_ORDER = gql`
  375. query GetOrder($id: ID!) {
  376. order(id: $id) {
  377. ...OrderWithLines
  378. }
  379. }
  380. ${ORDER_WITH_LINES_FRAGMENT}
  381. `;
  382. export const CUSTOMER_GROUP_FRAGMENT = gql`
  383. fragment CustomerGroup on CustomerGroup {
  384. id
  385. name
  386. customers {
  387. items {
  388. id
  389. }
  390. totalItems
  391. }
  392. }
  393. `;
  394. export const CREATE_CUSTOMER_GROUP = gql`
  395. mutation CreateCustomerGroup($input: CreateCustomerGroupInput!) {
  396. createCustomerGroup(input: $input) {
  397. ...CustomerGroup
  398. }
  399. }
  400. ${CUSTOMER_GROUP_FRAGMENT}
  401. `;
  402. export const REMOVE_CUSTOMERS_FROM_GROUP = gql`
  403. mutation RemoveCustomersFromGroup($groupId: ID!, $customerIds: [ID!]!) {
  404. removeCustomersFromGroup(customerGroupId: $groupId, customerIds: $customerIds) {
  405. ...CustomerGroup
  406. }
  407. }
  408. ${CUSTOMER_GROUP_FRAGMENT}
  409. `;
  410. export const CREATE_FULFILLMENT = gql`
  411. mutation CreateFulfillment($input: FulfillOrderInput!) {
  412. addFulfillmentToOrder(input: $input) {
  413. ...Fulfillment
  414. ... on ErrorResult {
  415. errorCode
  416. message
  417. }
  418. }
  419. }
  420. ${FULFILLMENT_FRAGMENT}
  421. `;
  422. export const TRANSIT_FULFILLMENT = gql`
  423. mutation TransitFulfillment($id: ID!, $state: String!) {
  424. transitionFulfillmentToState(id: $id, state: $state) {
  425. ...Fulfillment
  426. ... on FulfillmentStateTransitionError {
  427. errorCode
  428. message
  429. transitionError
  430. fromState
  431. toState
  432. }
  433. }
  434. }
  435. ${FULFILLMENT_FRAGMENT}
  436. `;
  437. export const GET_ORDER_FULFILLMENTS = gql`
  438. query GetOrderFulfillments($id: ID!) {
  439. order(id: $id) {
  440. id
  441. state
  442. fulfillments {
  443. id
  444. state
  445. nextStates
  446. method
  447. }
  448. }
  449. }
  450. `;
  451. export const GET_ORDERS_LIST = gql`
  452. query GetOrderList($options: OrderListOptions) {
  453. orders(options: $options) {
  454. items {
  455. ...Order
  456. }
  457. totalItems
  458. }
  459. }
  460. ${ORDER_FRAGMENT}
  461. `;
  462. export const CREATE_ADDRESS = gql`
  463. mutation CreateAddress($id: ID!, $input: CreateAddressInput!) {
  464. createCustomerAddress(customerId: $id, input: $input) {
  465. id
  466. fullName
  467. company
  468. streetLine1
  469. streetLine2
  470. city
  471. province
  472. postalCode
  473. country {
  474. code
  475. name
  476. }
  477. phoneNumber
  478. defaultShippingAddress
  479. defaultBillingAddress
  480. }
  481. }
  482. `;
  483. export const UPDATE_ADDRESS = gql`
  484. mutation UpdateAddress($input: UpdateAddressInput!) {
  485. updateCustomerAddress(input: $input) {
  486. id
  487. defaultShippingAddress
  488. defaultBillingAddress
  489. country {
  490. code
  491. name
  492. }
  493. }
  494. }
  495. `;
  496. export const CREATE_CUSTOMER = gql`
  497. mutation CreateCustomer($input: CreateCustomerInput!, $password: String) {
  498. createCustomer(input: $input, password: $password) {
  499. ...Customer
  500. ... on ErrorResult {
  501. errorCode
  502. message
  503. }
  504. }
  505. }
  506. ${CUSTOMER_FRAGMENT}
  507. `;
  508. export const UPDATE_CUSTOMER = gql`
  509. mutation UpdateCustomer($input: UpdateCustomerInput!) {
  510. updateCustomer(input: $input) {
  511. ...Customer
  512. ... on ErrorResult {
  513. errorCode
  514. message
  515. }
  516. }
  517. }
  518. ${CUSTOMER_FRAGMENT}
  519. `;
  520. export const DELETE_CUSTOMER = gql`
  521. mutation DeleteCustomer($id: ID!) {
  522. deleteCustomer(id: $id) {
  523. result
  524. }
  525. }
  526. `;
  527. export const UPDATE_CUSTOMER_NOTE = gql`
  528. mutation UpdateCustomerNote($input: UpdateCustomerNoteInput!) {
  529. updateCustomerNote(input: $input) {
  530. id
  531. data
  532. isPublic
  533. }
  534. }
  535. `;
  536. export const DELETE_CUSTOMER_NOTE = gql`
  537. mutation DeleteCustomerNote($id: ID!) {
  538. deleteCustomerNote(id: $id) {
  539. result
  540. message
  541. }
  542. }
  543. `;
  544. export const UPDATE_CUSTOMER_GROUP = gql`
  545. mutation UpdateCustomerGroup($input: UpdateCustomerGroupInput!) {
  546. updateCustomerGroup(input: $input) {
  547. ...CustomerGroup
  548. }
  549. }
  550. ${CUSTOMER_GROUP_FRAGMENT}
  551. `;
  552. export const DELETE_CUSTOMER_GROUP = gql`
  553. mutation DeleteCustomerGroup($id: ID!) {
  554. deleteCustomerGroup(id: $id) {
  555. result
  556. message
  557. }
  558. }
  559. `;
  560. export const GET_CUSTOMER_GROUPS = gql`
  561. query GetCustomerGroups($options: CustomerGroupListOptions) {
  562. customerGroups(options: $options) {
  563. items {
  564. id
  565. name
  566. }
  567. totalItems
  568. }
  569. }
  570. `;
  571. export const GET_CUSTOMER_GROUP = gql`
  572. query GetCustomerGroup($id: ID!, $options: CustomerListOptions) {
  573. customerGroup(id: $id) {
  574. id
  575. name
  576. customers(options: $options) {
  577. items {
  578. id
  579. }
  580. totalItems
  581. }
  582. }
  583. }
  584. `;
  585. export const ADD_CUSTOMERS_TO_GROUP = gql`
  586. mutation AddCustomersToGroup($groupId: ID!, $customerIds: [ID!]!) {
  587. addCustomersToGroup(customerGroupId: $groupId, customerIds: $customerIds) {
  588. ...CustomerGroup
  589. }
  590. }
  591. ${CUSTOMER_GROUP_FRAGMENT}
  592. `;
  593. export const GET_CUSTOMER_WITH_GROUPS = gql`
  594. query GetCustomerWithGroups($id: ID!) {
  595. customer(id: $id) {
  596. id
  597. groups {
  598. id
  599. name
  600. }
  601. }
  602. }
  603. `;
  604. export const ADMIN_TRANSITION_TO_STATE = gql`
  605. mutation AdminTransition($id: ID!, $state: String!) {
  606. transitionOrderToState(id: $id, state: $state) {
  607. ...Order
  608. ... on OrderStateTransitionError {
  609. errorCode
  610. message
  611. transitionError
  612. fromState
  613. toState
  614. }
  615. }
  616. }
  617. ${ORDER_FRAGMENT}
  618. `;
  619. export const CANCEL_ORDER = gql`
  620. mutation CancelOrder($input: CancelOrderInput!) {
  621. cancelOrder(input: $input) {
  622. ...CanceledOrder
  623. ... on ErrorResult {
  624. errorCode
  625. message
  626. }
  627. }
  628. }
  629. fragment CanceledOrder on Order {
  630. id
  631. lines {
  632. quantity
  633. items {
  634. id
  635. cancelled
  636. }
  637. }
  638. }
  639. `;
  640. export const UPDATE_GLOBAL_SETTINGS = gql`
  641. mutation UpdateGlobalSettings($input: UpdateGlobalSettingsInput!) {
  642. updateGlobalSettings(input: $input) {
  643. ...GlobalSettings
  644. ... on ErrorResult {
  645. errorCode
  646. message
  647. }
  648. }
  649. }
  650. ${GLOBAL_SETTINGS_FRAGMENT}
  651. `;