shared-definitions.ts 15 KB

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