active-order-strategy.e2e-spec.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. import { LanguageCode } from '@vendure/common/lib/generated-types';
  2. import { mergeConfig, orderPercentageDiscount } from '@vendure/core';
  3. import { createErrorResultGuard, createTestEnvironment, ErrorResultGuard } from '@vendure/testing';
  4. import path from 'path';
  5. import { afterAll, beforeAll, describe, expect, it } from 'vitest';
  6. import { initialData } from '../../../e2e-common/e2e-initial-data';
  7. import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
  8. import { testSuccessfulPaymentMethod } from './fixtures/test-payment-methods';
  9. import { TokenActiveOrderPlugin } from './fixtures/test-plugins/token-active-order-plugin';
  10. import { ResultOf } from './graphql/graphql-admin';
  11. import { graphql, ResultOf as ShopResultOf } from './graphql/graphql-shop';
  12. import { createPromotionDocument, getCustomerListDocument } from './graphql/shared-definitions';
  13. import { addItemToOrderDocument, getActiveOrderDocument } from './graphql/shop-definitions';
  14. import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
  15. describe('custom ActiveOrderStrategy', () => {
  16. const { server, adminClient, shopClient } = createTestEnvironment(
  17. mergeConfig(testConfig(), {
  18. plugins: [TokenActiveOrderPlugin],
  19. paymentOptions: {
  20. paymentMethodHandlers: [testSuccessfulPaymentMethod],
  21. },
  22. customFields: {
  23. Order: [
  24. {
  25. name: 'message',
  26. type: 'string',
  27. nullable: true,
  28. },
  29. ],
  30. },
  31. }),
  32. );
  33. type OrderResult = Extract<
  34. ShopResultOf<typeof addItemToOrderWithTokenDocument>['addItemToOrder'],
  35. { __typename?: 'Order' }
  36. >;
  37. const orderResultGuard: ErrorResultGuard<OrderResult> = createErrorResultGuard(
  38. input => !('errorCode' in input) && !('message' in input),
  39. );
  40. let customers: ResultOf<typeof getCustomerListDocument>['customers']['items'];
  41. beforeAll(async () => {
  42. await server.init({
  43. initialData: {
  44. ...initialData,
  45. paymentMethods: [
  46. {
  47. name: testSuccessfulPaymentMethod.code,
  48. handler: { code: testSuccessfulPaymentMethod.code, arguments: [] },
  49. },
  50. ],
  51. },
  52. productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-full.csv'),
  53. customerCount: 3,
  54. });
  55. await adminClient.asSuperAdmin();
  56. const result = await adminClient.query(getCustomerListDocument);
  57. customers = result.customers.items;
  58. }, TEST_SETUP_TIMEOUT_MS);
  59. afterAll(async () => {
  60. await server.destroy();
  61. });
  62. it('activeOrder with no createActiveOrder defined returns null', async () => {
  63. const { activeOrder } = await shopClient.query(getActiveOrderDocument);
  64. expect(activeOrder).toBeNull();
  65. });
  66. it(
  67. 'addItemToOrder with no createActiveOrder throws',
  68. assertThrowsWithMessage(async () => {
  69. await shopClient.query(addItemToOrderDocument, {
  70. productVariantId: 'T_1',
  71. quantity: 1,
  72. });
  73. }, 'No active Order could be determined nor created'),
  74. );
  75. it('activeOrder with valid input', async () => {
  76. const { createOrder } = await shopClient.query(createCustomOrderDocument, {
  77. customerId: customers[1].id,
  78. });
  79. expect(createOrder).toEqual({
  80. id: 'T_1',
  81. orderToken: 'token-2',
  82. });
  83. await shopClient.asUserWithCredentials(customers[1].emailAddress, 'test');
  84. const { activeOrder } = await shopClient.query(activeOrderByTokenDocument, {
  85. // @ts-expect-error
  86. input: {
  87. orderToken: { token: 'token-2' },
  88. },
  89. });
  90. expect(activeOrder).toEqual({
  91. id: 'T_1',
  92. orderToken: 'token-2',
  93. });
  94. });
  95. it('activeOrder with invalid input', async () => {
  96. await shopClient.asUserWithCredentials(customers[1].emailAddress, 'test');
  97. const { activeOrder } = await shopClient.query(activeOrderByTokenDocument, {
  98. // @ts-expect-error
  99. input: {
  100. orderToken: { token: 'invalid' },
  101. },
  102. });
  103. expect(activeOrder).toBeNull();
  104. });
  105. it('activeOrder with invalid condition', async () => {
  106. // wrong customer logged in
  107. await shopClient.asUserWithCredentials(customers[0].emailAddress, 'test');
  108. const { activeOrder } = await shopClient.query(activeOrderByTokenDocument, {
  109. // @ts-expect-error
  110. input: {
  111. orderToken: { token: 'token-2' },
  112. },
  113. });
  114. expect(activeOrder).toBeNull();
  115. });
  116. describe('happy path', () => {
  117. const activeOrderInput = 'activeOrderInput: { orderToken: { token: "token-2" } }';
  118. const TEST_COUPON_CODE = 'TESTCOUPON';
  119. let firstOrderLineId: string;
  120. beforeAll(async () => {
  121. await shopClient.asUserWithCredentials(customers[1].emailAddress, 'test');
  122. const result = await adminClient.query(createPromotionDocument, {
  123. input: {
  124. enabled: true,
  125. couponCode: TEST_COUPON_CODE,
  126. conditions: [],
  127. actions: [
  128. {
  129. code: orderPercentageDiscount.code,
  130. arguments: [{ name: 'discount', value: '100' }],
  131. },
  132. ],
  133. translations: [{ languageCode: LanguageCode.en, name: 'Free with test coupon' }],
  134. },
  135. });
  136. });
  137. it('addItemToOrder', async () => {
  138. const { addItemToOrder } = await shopClient.query(addItemToOrderWithTokenDocument, {
  139. productVariantId: 'T_1',
  140. quantity: 1,
  141. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  142. });
  143. orderResultGuard.assertSuccess(addItemToOrder);
  144. expect(addItemToOrder).toEqual({
  145. id: 'T_1',
  146. orderToken: 'token-2',
  147. lines: [
  148. {
  149. id: 'T_1',
  150. productVariant: { id: 'T_1' },
  151. },
  152. ],
  153. });
  154. if (!addItemToOrder.lines) {
  155. throw new Error('No lines found');
  156. }
  157. firstOrderLineId = addItemToOrder.lines[0].id;
  158. });
  159. it('adjustOrderLine', async () => {
  160. const { adjustOrderLine } = await shopClient.query(adjustOrderLineWithTokenDocument, {
  161. orderLineId: firstOrderLineId,
  162. quantity: 2,
  163. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  164. });
  165. orderResultGuard.assertSuccess(adjustOrderLine);
  166. expect(adjustOrderLine).toEqual({
  167. id: 'T_1',
  168. orderToken: 'token-2',
  169. lines: [
  170. {
  171. quantity: 2,
  172. productVariant: { id: 'T_1' },
  173. },
  174. ],
  175. });
  176. });
  177. it('removeOrderLine', async () => {
  178. const { removeOrderLine } = await shopClient.query(removeOrderLineWithTokenDocument, {
  179. orderLineId: firstOrderLineId,
  180. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  181. });
  182. orderResultGuard.assertSuccess(removeOrderLine);
  183. expect(removeOrderLine).toEqual({
  184. id: 'T_1',
  185. orderToken: 'token-2',
  186. lines: [],
  187. });
  188. });
  189. it('removeAllOrderLines', async () => {
  190. const { addItemToOrder } = await shopClient.query(addItemToOrderWithTokenDocument, {
  191. productVariantId: 'T_1',
  192. quantity: 1,
  193. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  194. });
  195. orderResultGuard.assertSuccess(addItemToOrder);
  196. expect(addItemToOrder.lines.length).toBe(1);
  197. const { removeAllOrderLines } = await shopClient.query(removeAllOrderLinesWithTokenDocument, {
  198. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  199. });
  200. orderResultGuard.assertSuccess(removeAllOrderLines);
  201. expect(removeAllOrderLines.lines.length).toBe(0);
  202. });
  203. it('applyCouponCode', async () => {
  204. await shopClient.query(addItemToOrderWithTokenDocument, {
  205. productVariantId: 'T_1',
  206. quantity: 1,
  207. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  208. });
  209. const { applyCouponCode } = await shopClient.query(applyCouponCodeWithTokenDocument, {
  210. couponCode: TEST_COUPON_CODE,
  211. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  212. });
  213. orderResultGuard.assertSuccess(applyCouponCode);
  214. expect(applyCouponCode).toEqual({
  215. id: 'T_1',
  216. orderToken: 'token-2',
  217. couponCodes: [TEST_COUPON_CODE],
  218. discounts: [{ description: 'Free with test coupon' }],
  219. });
  220. });
  221. it('removeCouponCode', async () => {
  222. const { removeCouponCode } = await shopClient.query(removeCouponCodeWithTokenDocument, {
  223. couponCode: TEST_COUPON_CODE,
  224. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  225. });
  226. if (!removeCouponCode) {
  227. throw new Error('No removeCouponCode found');
  228. }
  229. orderResultGuard.assertSuccess(removeCouponCode);
  230. expect(removeCouponCode).toEqual({
  231. id: 'T_1',
  232. orderToken: 'token-2',
  233. couponCodes: [],
  234. discounts: [],
  235. });
  236. });
  237. it('setOrderShippingAddress', async () => {
  238. const { setOrderShippingAddress } = await shopClient.query(
  239. setOrderShippingAddressWithTokenDocument,
  240. {
  241. input: {
  242. streetLine1: 'Shipping Street',
  243. countryCode: 'AT',
  244. },
  245. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  246. },
  247. );
  248. orderResultGuard.assertSuccess(setOrderShippingAddress);
  249. expect(setOrderShippingAddress).toEqual({
  250. id: 'T_1',
  251. orderToken: 'token-2',
  252. shippingAddress: {
  253. streetLine1: 'Shipping Street',
  254. country: 'Austria',
  255. },
  256. });
  257. });
  258. it('setOrderBillingAddress', async () => {
  259. const { setOrderBillingAddress } = await shopClient.query(
  260. setOrderBillingAddressWithTokenDocument,
  261. {
  262. input: {
  263. streetLine1: 'Billing Street',
  264. countryCode: 'AT',
  265. },
  266. activeOrderInput: { orderToken: { token: 'token-2' } } as any,
  267. },
  268. );
  269. orderResultGuard.assertSuccess(setOrderBillingAddress);
  270. expect(setOrderBillingAddress).toEqual({
  271. id: 'T_1',
  272. orderToken: 'token-2',
  273. billingAddress: {
  274. streetLine1: 'Billing Street',
  275. country: 'Austria',
  276. },
  277. });
  278. });
  279. it('unsetOrderShippingAddress', async () => {
  280. const { unsetOrderShippingAddress } = await shopClient.query(
  281. unsetOrderShippingAddressWithTokenDocument,
  282. {
  283. // @ts-expect-error
  284. activeOrderInput: { orderToken: { token: 'token-2' } },
  285. },
  286. );
  287. orderResultGuard.assertSuccess(unsetOrderShippingAddress);
  288. expect(unsetOrderShippingAddress).toEqual({
  289. id: 'T_1',
  290. orderToken: 'token-2',
  291. shippingAddress: {
  292. streetLine1: null,
  293. country: null,
  294. },
  295. });
  296. });
  297. it('unsetOrderBillingAddress', async () => {
  298. const { unsetOrderBillingAddress } = await shopClient.query(
  299. unsetOrderBillingAddressWithTokenDocument,
  300. {
  301. // @ts-expect-error
  302. activeOrderInput: { orderToken: { token: 'token-2' } },
  303. },
  304. );
  305. orderResultGuard.assertSuccess(unsetOrderBillingAddress);
  306. expect(unsetOrderBillingAddress).toEqual({
  307. id: 'T_1',
  308. orderToken: 'token-2',
  309. billingAddress: {
  310. streetLine1: null,
  311. country: null,
  312. },
  313. });
  314. });
  315. it('eligibleShippingMethods', async () => {
  316. const { eligibleShippingMethods } = await shopClient.query(
  317. eligibleShippingMethodsWithTokenDocument,
  318. {
  319. // @ts-expect-error
  320. activeOrderInput: { orderToken: { token: 'token-2' } },
  321. },
  322. );
  323. expect(eligibleShippingMethods).toEqual([
  324. {
  325. id: 'T_1',
  326. name: 'Standard Shipping',
  327. priceWithTax: 500,
  328. },
  329. {
  330. id: 'T_2',
  331. name: 'Express Shipping',
  332. priceWithTax: 1000,
  333. },
  334. {
  335. id: 'T_3',
  336. name: 'Express Shipping (Taxed)',
  337. priceWithTax: 1200,
  338. },
  339. ]);
  340. });
  341. it('setOrderShippingMethod', async () => {
  342. const { setOrderShippingMethod } = await shopClient.query(
  343. setOrderShippingMethodWithTokenDocument,
  344. {
  345. shippingMethodId: ['T_1'],
  346. // @ts-expect-error
  347. activeOrderInput: { orderToken: { token: 'token-2' } },
  348. },
  349. );
  350. orderResultGuard.assertSuccess(setOrderShippingMethod);
  351. expect(setOrderShippingMethod).toEqual({
  352. id: 'T_1',
  353. orderToken: 'token-2',
  354. shippingLines: [{ price: 500 }],
  355. });
  356. });
  357. it('setOrderCustomFields', async () => {
  358. const { setOrderCustomFields } = await shopClient.query(setOrderCustomFieldsWithTokenDocument, {
  359. input: { customFields: { message: 'foo' } },
  360. // @ts-expect-error
  361. activeOrderInput: { orderToken: { token: 'token-2' } },
  362. });
  363. orderResultGuard.assertSuccess(setOrderCustomFields);
  364. expect(setOrderCustomFields).toEqual({
  365. id: 'T_1',
  366. orderToken: 'token-2',
  367. customFields: { message: 'foo' },
  368. });
  369. });
  370. it('eligiblePaymentMethods', async () => {
  371. const { eligiblePaymentMethods } = await shopClient.query(
  372. eligiblePaymentMethodsWithTokenDocument,
  373. {
  374. // @ts-expect-error
  375. activeOrderInput: { orderToken: { token: 'token-2' } },
  376. },
  377. );
  378. expect(eligiblePaymentMethods).toEqual([
  379. {
  380. id: 'T_1',
  381. name: 'test-payment-method',
  382. code: 'test-payment-method',
  383. },
  384. ]);
  385. });
  386. it('nextOrderStates', async () => {
  387. const { nextOrderStates } = await shopClient.query(nextOrderStatesWithTokenDocument, {
  388. // @ts-expect-error
  389. activeOrderInput: { orderToken: { token: 'token-2' } },
  390. });
  391. expect(nextOrderStates).toEqual(['ArrangingPayment', 'Cancelled']);
  392. });
  393. it('transitionOrderToState', async () => {
  394. const { transitionOrderToState } = await shopClient.query(
  395. transitionOrderToStateWithTokenDocument,
  396. {
  397. state: 'ArrangingPayment',
  398. // @ts-expect-error
  399. activeOrderInput: { orderToken: { token: 'token-2' } },
  400. },
  401. );
  402. if (!transitionOrderToState) {
  403. throw new Error('No transitionOrderToState found');
  404. }
  405. orderResultGuard.assertSuccess(transitionOrderToState);
  406. expect(transitionOrderToState).toEqual({
  407. id: 'T_1',
  408. orderToken: 'token-2',
  409. state: 'ArrangingPayment',
  410. });
  411. });
  412. it('addPaymentToOrder', async () => {
  413. const { addPaymentToOrder } = await shopClient.query(addPaymentToOrderWithTokenDocument, {
  414. input: { method: 'test-payment-method', metadata: {} },
  415. // @ts-expect-error
  416. activeOrderInput: { orderToken: { token: 'token-2' } },
  417. });
  418. if (!addPaymentToOrder) {
  419. throw new Error('No addPaymentToOrder found');
  420. }
  421. orderResultGuard.assertSuccess(addPaymentToOrder);
  422. expect(addPaymentToOrder).toEqual({
  423. id: 'T_1',
  424. orderToken: 'token-2',
  425. payments: [
  426. {
  427. state: 'Settled',
  428. },
  429. ],
  430. state: 'PaymentSettled',
  431. });
  432. });
  433. });
  434. });
  435. export const activeOrderByTokenDocument = graphql(`
  436. query ActiveOrderByToken($input: ActiveOrderInput) {
  437. activeOrder(activeOrderInput: $input) {
  438. id
  439. orderToken
  440. }
  441. }
  442. `);
  443. export const createCustomOrderDocument = graphql(`
  444. mutation CreateCustomOrder($customerId: ID!) {
  445. createOrder(customerId: $customerId) {
  446. id
  447. orderToken
  448. }
  449. }
  450. `);
  451. const addItemToOrderWithTokenDocument = graphql(`
  452. mutation AddItemToOrderWithToken(
  453. $productVariantId: ID!
  454. $quantity: Int!
  455. $activeOrderInput: ActiveOrderInput
  456. ) {
  457. addItemToOrder(
  458. productVariantId: $productVariantId
  459. quantity: $quantity
  460. activeOrderInput: $activeOrderInput
  461. ) {
  462. ... on Order {
  463. id
  464. orderToken
  465. lines {
  466. id
  467. productVariant {
  468. id
  469. }
  470. }
  471. }
  472. }
  473. }
  474. `);
  475. const adjustOrderLineWithTokenDocument = graphql(`
  476. mutation AdjustOrderLineWithToken(
  477. $orderLineId: ID!
  478. $quantity: Int!
  479. $activeOrderInput: ActiveOrderInput
  480. ) {
  481. adjustOrderLine(orderLineId: $orderLineId, quantity: $quantity, activeOrderInput: $activeOrderInput) {
  482. ... on Order {
  483. id
  484. orderToken
  485. lines {
  486. quantity
  487. productVariant {
  488. id
  489. }
  490. }
  491. }
  492. }
  493. }
  494. `);
  495. const removeOrderLineWithTokenDocument = graphql(`
  496. mutation RemoveOrderLineWithToken($orderLineId: ID!, $activeOrderInput: ActiveOrderInput) {
  497. removeOrderLine(orderLineId: $orderLineId, activeOrderInput: $activeOrderInput) {
  498. ... on Order {
  499. id
  500. orderToken
  501. lines {
  502. id
  503. }
  504. }
  505. }
  506. }
  507. `);
  508. const removeAllOrderLinesWithTokenDocument = graphql(`
  509. mutation RemoveAllOrderLinesWithToken($activeOrderInput: ActiveOrderInput) {
  510. removeAllOrderLines(activeOrderInput: $activeOrderInput) {
  511. ... on Order {
  512. id
  513. orderToken
  514. lines {
  515. id
  516. }
  517. }
  518. }
  519. }
  520. `);
  521. const applyCouponCodeWithTokenDocument = graphql(`
  522. mutation ApplyCouponCodeWithToken($couponCode: String!, $activeOrderInput: ActiveOrderInput) {
  523. applyCouponCode(couponCode: $couponCode, activeOrderInput: $activeOrderInput) {
  524. ... on Order {
  525. id
  526. orderToken
  527. couponCodes
  528. discounts {
  529. description
  530. }
  531. }
  532. }
  533. }
  534. `);
  535. const removeCouponCodeWithTokenDocument = graphql(`
  536. mutation RemoveCouponCodeWithToken($couponCode: String!, $activeOrderInput: ActiveOrderInput) {
  537. removeCouponCode(couponCode: $couponCode, activeOrderInput: $activeOrderInput) {
  538. ... on Order {
  539. id
  540. orderToken
  541. couponCodes
  542. discounts {
  543. description
  544. }
  545. }
  546. }
  547. }
  548. `);
  549. const setOrderShippingAddressWithTokenDocument = graphql(`
  550. mutation SetOrderShippingAddressWithToken(
  551. $input: CreateAddressInput!
  552. $activeOrderInput: ActiveOrderInput
  553. ) {
  554. setOrderShippingAddress(input: $input, activeOrderInput: $activeOrderInput) {
  555. ... on Order {
  556. id
  557. orderToken
  558. shippingAddress {
  559. streetLine1
  560. country
  561. }
  562. }
  563. }
  564. }
  565. `);
  566. const setOrderBillingAddressWithTokenDocument = graphql(`
  567. mutation SetOrderBillingAddressWithToken(
  568. $input: CreateAddressInput!
  569. $activeOrderInput: ActiveOrderInput
  570. ) {
  571. setOrderBillingAddress(input: $input, activeOrderInput: $activeOrderInput) {
  572. ... on Order {
  573. id
  574. orderToken
  575. billingAddress {
  576. streetLine1
  577. country
  578. }
  579. }
  580. }
  581. }
  582. `);
  583. const unsetOrderShippingAddressWithTokenDocument = graphql(`
  584. mutation UnsetOrderShippingAddressWithToken($activeOrderInput: ActiveOrderInput) {
  585. unsetOrderShippingAddress(activeOrderInput: $activeOrderInput) {
  586. ... on Order {
  587. id
  588. orderToken
  589. shippingAddress {
  590. streetLine1
  591. country
  592. }
  593. }
  594. }
  595. }
  596. `);
  597. const unsetOrderBillingAddressWithTokenDocument = graphql(`
  598. mutation UnsetOrderBillingAddressWithToken($activeOrderInput: ActiveOrderInput) {
  599. unsetOrderBillingAddress(activeOrderInput: $activeOrderInput) {
  600. ... on Order {
  601. id
  602. orderToken
  603. billingAddress {
  604. streetLine1
  605. country
  606. }
  607. }
  608. }
  609. }
  610. `);
  611. const eligibleShippingMethodsWithTokenDocument = graphql(`
  612. query EligibleShippingMethodsWithToken($activeOrderInput: ActiveOrderInput) {
  613. eligibleShippingMethods(activeOrderInput: $activeOrderInput) {
  614. id
  615. name
  616. priceWithTax
  617. }
  618. }
  619. `);
  620. const setOrderShippingMethodWithTokenDocument = graphql(`
  621. mutation SetOrderShippingMethodWithToken($shippingMethodId: [ID!]!, $activeOrderInput: ActiveOrderInput) {
  622. setOrderShippingMethod(shippingMethodId: $shippingMethodId, activeOrderInput: $activeOrderInput) {
  623. ... on Order {
  624. id
  625. orderToken
  626. shippingLines {
  627. price
  628. }
  629. }
  630. }
  631. }
  632. `);
  633. const setOrderCustomFieldsWithTokenDocument = graphql(`
  634. mutation SetOrderCustomFieldsWithToken($input: UpdateOrderInput!, $activeOrderInput: ActiveOrderInput) {
  635. setOrderCustomFields(input: $input, activeOrderInput: $activeOrderInput) {
  636. ... on Order {
  637. id
  638. orderToken
  639. customFields {
  640. message
  641. }
  642. }
  643. }
  644. }
  645. `);
  646. const eligiblePaymentMethodsWithTokenDocument = graphql(`
  647. query EligiblePaymentMethodsWithToken($activeOrderInput: ActiveOrderInput) {
  648. eligiblePaymentMethods(activeOrderInput: $activeOrderInput) {
  649. id
  650. name
  651. code
  652. }
  653. }
  654. `);
  655. const nextOrderStatesWithTokenDocument = graphql(`
  656. query NextOrderStatesWithToken($activeOrderInput: ActiveOrderInput) {
  657. nextOrderStates(activeOrderInput: $activeOrderInput)
  658. }
  659. `);
  660. const transitionOrderToStateWithTokenDocument = graphql(`
  661. mutation TransitionOrderToStateWithToken($state: String!, $activeOrderInput: ActiveOrderInput) {
  662. transitionOrderToState(state: $state, activeOrderInput: $activeOrderInput) {
  663. ... on Order {
  664. id
  665. orderToken
  666. state
  667. }
  668. }
  669. }
  670. `);
  671. const addPaymentToOrderWithTokenDocument = graphql(`
  672. mutation AddPaymentToOrderWithToken($input: PaymentInput!, $activeOrderInput: ActiveOrderInput) {
  673. addPaymentToOrder(input: $input, activeOrderInput: $activeOrderInput) {
  674. ... on Order {
  675. id
  676. orderToken
  677. state
  678. payments {
  679. state
  680. }
  681. }
  682. }
  683. }
  684. `);