shared-definitions.ts 18 KB

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