shared-definitions.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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 UPDATE_ASSET = gql`
  326. mutation UpdateAsset($input: UpdateAssetInput!) {
  327. updateAsset(input: $input) {
  328. ...Asset
  329. ... on Asset {
  330. focalPoint {
  331. x
  332. y
  333. }
  334. }
  335. }
  336. }
  337. ${ASSET_FRAGMENT}
  338. `;
  339. export const DELETE_ASSET = gql`
  340. mutation DeleteAsset($id: ID!, $force: Boolean) {
  341. deleteAsset(id: $id, force: $force) {
  342. result
  343. message
  344. }
  345. }
  346. `;
  347. export const UPDATE_CHANNEL = gql`
  348. mutation UpdateChannel($input: UpdateChannelInput!) {
  349. updateChannel(input: $input) {
  350. ...Channel
  351. ... on LanguageNotAvailableError {
  352. errorCode
  353. message
  354. languageCode
  355. }
  356. }
  357. }
  358. ${CHANNEL_FRAGMENT}
  359. `;
  360. export const GET_CUSTOMER_HISTORY = gql`
  361. query GetCustomerHistory($id: ID!, $options: HistoryEntryListOptions) {
  362. customer(id: $id) {
  363. id
  364. history(options: $options) {
  365. totalItems
  366. items {
  367. id
  368. administrator {
  369. id
  370. }
  371. type
  372. data
  373. }
  374. }
  375. }
  376. }
  377. `;
  378. export const GET_ORDER = gql`
  379. query GetOrder($id: ID!) {
  380. order(id: $id) {
  381. ...OrderWithLines
  382. }
  383. }
  384. ${ORDER_WITH_LINES_FRAGMENT}
  385. `;
  386. export const CREATE_CUSTOMER_GROUP = gql`
  387. mutation CreateCustomerGroup($input: CreateCustomerGroupInput!) {
  388. createCustomerGroup(input: $input) {
  389. ...CustomerGroup
  390. }
  391. }
  392. ${CUSTOMER_GROUP_FRAGMENT}
  393. `;
  394. export const REMOVE_CUSTOMERS_FROM_GROUP = gql`
  395. mutation RemoveCustomersFromGroup($groupId: ID!, $customerIds: [ID!]!) {
  396. removeCustomersFromGroup(customerGroupId: $groupId, customerIds: $customerIds) {
  397. ...CustomerGroup
  398. }
  399. }
  400. ${CUSTOMER_GROUP_FRAGMENT}
  401. `;
  402. export const CREATE_FULFILLMENT = gql`
  403. mutation CreateFulfillment($input: FulfillOrderInput!) {
  404. addFulfillmentToOrder(input: $input) {
  405. ...Fulfillment
  406. ... on ErrorResult {
  407. errorCode
  408. message
  409. }
  410. }
  411. }
  412. ${FULFILLMENT_FRAGMENT}
  413. `;
  414. export const TRANSIT_FULFILLMENT = gql`
  415. mutation TransitFulfillment($id: ID!, $state: String!) {
  416. transitionFulfillmentToState(id: $id, state: $state) {
  417. ...Fulfillment
  418. ... on FulfillmentStateTransitionError {
  419. errorCode
  420. message
  421. transitionError
  422. fromState
  423. toState
  424. }
  425. }
  426. }
  427. ${FULFILLMENT_FRAGMENT}
  428. `;
  429. export const GET_ORDER_FULFILLMENTS = gql`
  430. query GetOrderFulfillments($id: ID!) {
  431. order(id: $id) {
  432. id
  433. state
  434. fulfillments {
  435. id
  436. state
  437. nextStates
  438. method
  439. }
  440. }
  441. }
  442. `;
  443. export const GET_ORDERS_LIST = gql`
  444. query GetOrderList($options: OrderListOptions) {
  445. orders(options: $options) {
  446. items {
  447. ...Order
  448. }
  449. totalItems
  450. }
  451. }
  452. ${ORDER_FRAGMENT}
  453. `;
  454. export const CREATE_ADDRESS = gql`
  455. mutation CreateAddress($id: ID!, $input: CreateAddressInput!) {
  456. createCustomerAddress(customerId: $id, input: $input) {
  457. id
  458. fullName
  459. company
  460. streetLine1
  461. streetLine2
  462. city
  463. province
  464. postalCode
  465. country {
  466. code
  467. name
  468. }
  469. phoneNumber
  470. defaultShippingAddress
  471. defaultBillingAddress
  472. }
  473. }
  474. `;
  475. export const UPDATE_ADDRESS = gql`
  476. mutation UpdateAddress($input: UpdateAddressInput!) {
  477. updateCustomerAddress(input: $input) {
  478. id
  479. defaultShippingAddress
  480. defaultBillingAddress
  481. country {
  482. code
  483. name
  484. }
  485. }
  486. }
  487. `;
  488. export const CREATE_CUSTOMER = gql`
  489. mutation CreateCustomer($input: CreateCustomerInput!, $password: String) {
  490. createCustomer(input: $input, password: $password) {
  491. ...Customer
  492. ... on ErrorResult {
  493. errorCode
  494. message
  495. }
  496. }
  497. }
  498. ${CUSTOMER_FRAGMENT}
  499. `;
  500. export const UPDATE_CUSTOMER = gql`
  501. mutation UpdateCustomer($input: UpdateCustomerInput!) {
  502. updateCustomer(input: $input) {
  503. ...Customer
  504. ... on ErrorResult {
  505. errorCode
  506. message
  507. }
  508. }
  509. }
  510. ${CUSTOMER_FRAGMENT}
  511. `;
  512. export const DELETE_CUSTOMER = gql`
  513. mutation DeleteCustomer($id: ID!) {
  514. deleteCustomer(id: $id) {
  515. result
  516. }
  517. }
  518. `;
  519. export const UPDATE_CUSTOMER_NOTE = gql`
  520. mutation UpdateCustomerNote($input: UpdateCustomerNoteInput!) {
  521. updateCustomerNote(input: $input) {
  522. id
  523. data
  524. isPublic
  525. }
  526. }
  527. `;
  528. export const DELETE_CUSTOMER_NOTE = gql`
  529. mutation DeleteCustomerNote($id: ID!) {
  530. deleteCustomerNote(id: $id) {
  531. result
  532. message
  533. }
  534. }
  535. `;
  536. export const UPDATE_CUSTOMER_GROUP = gql`
  537. mutation UpdateCustomerGroup($input: UpdateCustomerGroupInput!) {
  538. updateCustomerGroup(input: $input) {
  539. ...CustomerGroup
  540. }
  541. }
  542. ${CUSTOMER_GROUP_FRAGMENT}
  543. `;
  544. export const DELETE_CUSTOMER_GROUP = gql`
  545. mutation DeleteCustomerGroup($id: ID!) {
  546. deleteCustomerGroup(id: $id) {
  547. result
  548. message
  549. }
  550. }
  551. `;
  552. export const GET_CUSTOMER_GROUPS = gql`
  553. query GetCustomerGroups($options: CustomerGroupListOptions) {
  554. customerGroups(options: $options) {
  555. items {
  556. id
  557. name
  558. }
  559. totalItems
  560. }
  561. }
  562. `;
  563. export const GET_CUSTOMER_GROUP = gql`
  564. query GetCustomerGroup($id: ID!, $options: CustomerListOptions) {
  565. customerGroup(id: $id) {
  566. id
  567. name
  568. customers(options: $options) {
  569. items {
  570. id
  571. }
  572. totalItems
  573. }
  574. }
  575. }
  576. `;
  577. export const ADD_CUSTOMERS_TO_GROUP = gql`
  578. mutation AddCustomersToGroup($groupId: ID!, $customerIds: [ID!]!) {
  579. addCustomersToGroup(customerGroupId: $groupId, customerIds: $customerIds) {
  580. ...CustomerGroup
  581. }
  582. }
  583. ${CUSTOMER_GROUP_FRAGMENT}
  584. `;
  585. export const GET_CUSTOMER_WITH_GROUPS = gql`
  586. query GetCustomerWithGroups($id: ID!) {
  587. customer(id: $id) {
  588. id
  589. groups {
  590. id
  591. name
  592. }
  593. }
  594. }
  595. `;
  596. export const ADMIN_TRANSITION_TO_STATE = gql`
  597. mutation AdminTransition($id: ID!, $state: String!) {
  598. transitionOrderToState(id: $id, state: $state) {
  599. ...Order
  600. ... on OrderStateTransitionError {
  601. errorCode
  602. message
  603. transitionError
  604. fromState
  605. toState
  606. }
  607. }
  608. }
  609. ${ORDER_FRAGMENT}
  610. `;
  611. export const CANCEL_ORDER = gql`
  612. mutation CancelOrder($input: CancelOrderInput!) {
  613. cancelOrder(input: $input) {
  614. ...CanceledOrder
  615. ... on ErrorResult {
  616. errorCode
  617. message
  618. }
  619. }
  620. }
  621. fragment CanceledOrder on Order {
  622. id
  623. lines {
  624. quantity
  625. items {
  626. id
  627. cancelled
  628. }
  629. }
  630. }
  631. `;
  632. export const UPDATE_GLOBAL_SETTINGS = gql`
  633. mutation UpdateGlobalSettings($input: UpdateGlobalSettingsInput!) {
  634. updateGlobalSettings(input: $input) {
  635. ...GlobalSettings
  636. ... on ErrorResult {
  637. errorCode
  638. message
  639. }
  640. }
  641. }
  642. ${GLOBAL_SETTINGS_FRAGMENT}
  643. `;
  644. export const UPDATE_ROLE = gql`
  645. mutation UpdateRole($input: UpdateRoleInput!) {
  646. updateRole(input: $input) {
  647. ...Role
  648. }
  649. }
  650. ${ROLE_FRAGMENT}
  651. `;
  652. export const GET_PRODUCTS_WITH_VARIANT_PRICES = gql`
  653. query GetProductsWithVariantPrices {
  654. products {
  655. items {
  656. id
  657. slug
  658. variants {
  659. id
  660. price
  661. priceWithTax
  662. sku
  663. facetValues {
  664. id
  665. code
  666. }
  667. }
  668. }
  669. }
  670. }
  671. `;
  672. export const CREATE_PRODUCT_OPTION_GROUP = gql`
  673. mutation CreateProductOptionGroup($input: CreateProductOptionGroupInput!) {
  674. createProductOptionGroup(input: $input) {
  675. ...ProductOptionGroup
  676. }
  677. }
  678. ${PRODUCT_OPTION_GROUP_FRAGMENT}
  679. `;
  680. export const ADD_OPTION_GROUP_TO_PRODUCT = gql`
  681. mutation AddOptionGroupToProduct($productId: ID!, $optionGroupId: ID!) {
  682. addOptionGroupToProduct(productId: $productId, optionGroupId: $optionGroupId) {
  683. ...ProductWithOptions
  684. }
  685. }
  686. ${PRODUCT_WITH_OPTIONS_FRAGMENT}
  687. `;
  688. export const CREATE_SHIPPING_METHOD = gql`
  689. mutation CreateShippingMethod($input: CreateShippingMethodInput!) {
  690. createShippingMethod(input: $input) {
  691. ...ShippingMethod
  692. }
  693. }
  694. ${SHIPPING_METHOD_FRAGMENT}
  695. `;