fragments-admin.ts 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. import { graphql } from './graphql-admin';
  2. export const administratorFragment = graphql(`
  3. fragment Administrator on Administrator {
  4. id
  5. firstName
  6. lastName
  7. emailAddress
  8. user {
  9. id
  10. identifier
  11. lastLogin
  12. roles {
  13. id
  14. code
  15. description
  16. permissions
  17. }
  18. }
  19. }
  20. `);
  21. export const assetFragment = graphql(`
  22. fragment Asset on Asset {
  23. id
  24. name
  25. fileSize
  26. mimeType
  27. type
  28. preview
  29. source
  30. }
  31. `);
  32. export const productVariantFragment = graphql(
  33. `
  34. fragment ProductVariant on ProductVariant {
  35. id
  36. createdAt
  37. updatedAt
  38. enabled
  39. languageCode
  40. name
  41. currencyCode
  42. price
  43. priceWithTax
  44. prices {
  45. currencyCode
  46. price
  47. }
  48. stockOnHand
  49. trackInventory
  50. taxRateApplied {
  51. id
  52. name
  53. value
  54. }
  55. taxCategory {
  56. id
  57. name
  58. }
  59. sku
  60. options {
  61. id
  62. code
  63. languageCode
  64. groupId
  65. name
  66. }
  67. facetValues {
  68. id
  69. code
  70. name
  71. facet {
  72. id
  73. name
  74. }
  75. }
  76. featuredAsset {
  77. ...Asset
  78. }
  79. assets {
  80. ...Asset
  81. }
  82. translations {
  83. id
  84. languageCode
  85. name
  86. }
  87. channels {
  88. id
  89. code
  90. }
  91. }
  92. `,
  93. [assetFragment],
  94. );
  95. export const productWithVariantsFragment = graphql(
  96. `
  97. fragment ProductWithVariants on Product {
  98. id
  99. enabled
  100. languageCode
  101. name
  102. slug
  103. description
  104. featuredAsset {
  105. ...Asset
  106. }
  107. assets {
  108. ...Asset
  109. }
  110. translations {
  111. languageCode
  112. name
  113. slug
  114. description
  115. }
  116. optionGroups {
  117. id
  118. languageCode
  119. code
  120. name
  121. }
  122. variants {
  123. ...ProductVariant
  124. }
  125. facetValues {
  126. id
  127. code
  128. name
  129. facet {
  130. id
  131. name
  132. }
  133. }
  134. channels {
  135. id
  136. code
  137. }
  138. }
  139. `,
  140. [productVariantFragment, assetFragment],
  141. );
  142. export const roleFragment = graphql(`
  143. fragment Role on Role {
  144. id
  145. code
  146. description
  147. permissions
  148. channels {
  149. id
  150. code
  151. token
  152. }
  153. }
  154. `);
  155. export const configurableFragment = graphql(`
  156. fragment ConfigurableOperation on ConfigurableOperation {
  157. args {
  158. name
  159. value
  160. }
  161. code
  162. }
  163. `);
  164. export const collectionFragment = graphql(
  165. `
  166. fragment Collection on Collection {
  167. id
  168. name
  169. slug
  170. description
  171. isPrivate
  172. languageCode
  173. featuredAsset {
  174. ...Asset
  175. }
  176. assets {
  177. ...Asset
  178. }
  179. filters {
  180. ...ConfigurableOperation
  181. }
  182. translations {
  183. id
  184. languageCode
  185. name
  186. slug
  187. description
  188. }
  189. parent {
  190. id
  191. name
  192. }
  193. children {
  194. id
  195. name
  196. position
  197. }
  198. }
  199. `,
  200. [assetFragment, configurableFragment],
  201. );
  202. export const facetValueFragment = graphql(`
  203. fragment FacetValue on FacetValue {
  204. id
  205. languageCode
  206. code
  207. name
  208. translations {
  209. id
  210. languageCode
  211. name
  212. }
  213. facet {
  214. id
  215. name
  216. }
  217. }
  218. `);
  219. export const facetWithValuesFragment = graphql(
  220. `
  221. fragment FacetWithValues on Facet {
  222. id
  223. languageCode
  224. isPrivate
  225. code
  226. name
  227. translations {
  228. id
  229. languageCode
  230. name
  231. }
  232. values {
  233. ...FacetValue
  234. }
  235. }
  236. `,
  237. [facetValueFragment],
  238. );
  239. export const countryFragment = graphql(`
  240. fragment Country on Region {
  241. id
  242. code
  243. name
  244. enabled
  245. translations {
  246. id
  247. languageCode
  248. name
  249. }
  250. }
  251. `);
  252. export const addressFragment = graphql(`
  253. fragment Address on Address {
  254. id
  255. fullName
  256. company
  257. streetLine1
  258. streetLine2
  259. city
  260. province
  261. postalCode
  262. country {
  263. id
  264. code
  265. name
  266. }
  267. phoneNumber
  268. defaultShippingAddress
  269. defaultBillingAddress
  270. }
  271. `);
  272. export const customerFragment = graphql(
  273. `
  274. fragment Customer on Customer {
  275. id
  276. title
  277. firstName
  278. lastName
  279. phoneNumber
  280. emailAddress
  281. user {
  282. id
  283. identifier
  284. verified
  285. lastLogin
  286. }
  287. addresses {
  288. ...Address
  289. }
  290. }
  291. `,
  292. [addressFragment],
  293. );
  294. export const adjustmentFragment = graphql(`
  295. fragment Adjustment on Adjustment {
  296. adjustmentSource
  297. amount
  298. description
  299. type
  300. }
  301. `);
  302. export const shippingAddressFragment = graphql(`
  303. fragment ShippingAddress on OrderAddress {
  304. fullName
  305. company
  306. streetLine1
  307. streetLine2
  308. city
  309. province
  310. postalCode
  311. country
  312. countryCode
  313. phoneNumber
  314. }
  315. `);
  316. export const orderFragment = graphql(`
  317. fragment Order on Order {
  318. id
  319. createdAt
  320. updatedAt
  321. code
  322. active
  323. state
  324. total
  325. totalWithTax
  326. totalQuantity
  327. currencyCode
  328. customer {
  329. id
  330. firstName
  331. lastName
  332. }
  333. }
  334. `);
  335. export const canceledOrderFragment = graphql(`
  336. fragment CanceledOrder on Order {
  337. id
  338. state
  339. lines {
  340. id
  341. quantity
  342. }
  343. }
  344. `);
  345. export const paymentFragment = graphql(`
  346. fragment Payment on Payment {
  347. id
  348. transactionId
  349. amount
  350. method
  351. state
  352. nextStates
  353. metadata
  354. refunds {
  355. id
  356. total
  357. reason
  358. }
  359. }
  360. `);
  361. export const refundFragment = graphql(`
  362. fragment Refund on Refund {
  363. id
  364. state
  365. items
  366. transactionId
  367. shipping
  368. total
  369. metadata
  370. }
  371. `);
  372. export const orderWithLinesFragment = graphql(
  373. `
  374. fragment OrderWithLines on Order {
  375. id
  376. createdAt
  377. updatedAt
  378. code
  379. state
  380. active
  381. customer {
  382. id
  383. firstName
  384. lastName
  385. }
  386. lines {
  387. id
  388. featuredAsset {
  389. preview
  390. }
  391. productVariant {
  392. id
  393. name
  394. sku
  395. }
  396. taxLines {
  397. description
  398. taxRate
  399. }
  400. unitPrice
  401. unitPriceWithTax
  402. quantity
  403. unitPrice
  404. unitPriceWithTax
  405. taxRate
  406. linePriceWithTax
  407. }
  408. surcharges {
  409. id
  410. description
  411. sku
  412. price
  413. priceWithTax
  414. }
  415. subTotal
  416. subTotalWithTax
  417. total
  418. totalWithTax
  419. totalQuantity
  420. currencyCode
  421. shipping
  422. shippingWithTax
  423. shippingLines {
  424. priceWithTax
  425. shippingMethod {
  426. id
  427. code
  428. name
  429. description
  430. }
  431. }
  432. shippingAddress {
  433. ...ShippingAddress
  434. }
  435. payments {
  436. ...Payment
  437. }
  438. fulfillments {
  439. id
  440. state
  441. method
  442. trackingCode
  443. lines {
  444. orderLineId
  445. quantity
  446. }
  447. }
  448. total
  449. }
  450. `,
  451. [shippingAddressFragment, paymentFragment],
  452. );
  453. export const orderWithModificationsFragment = graphql(
  454. `
  455. fragment OrderWithModifications on Order {
  456. id
  457. state
  458. subTotal
  459. subTotalWithTax
  460. shipping
  461. shippingWithTax
  462. total
  463. totalWithTax
  464. lines {
  465. id
  466. quantity
  467. orderPlacedQuantity
  468. linePrice
  469. linePriceWithTax
  470. unitPriceWithTax
  471. discountedLinePriceWithTax
  472. proratedLinePriceWithTax
  473. proratedUnitPriceWithTax
  474. discounts {
  475. description
  476. amountWithTax
  477. }
  478. productVariant {
  479. id
  480. name
  481. }
  482. }
  483. surcharges {
  484. id
  485. description
  486. sku
  487. price
  488. priceWithTax
  489. taxRate
  490. }
  491. payments {
  492. ...Payment
  493. }
  494. modifications {
  495. id
  496. note
  497. priceChange
  498. isSettled
  499. lines {
  500. orderLineId
  501. quantity
  502. }
  503. surcharges {
  504. id
  505. }
  506. payment {
  507. id
  508. state
  509. amount
  510. method
  511. }
  512. refund {
  513. id
  514. state
  515. total
  516. paymentId
  517. }
  518. }
  519. promotions {
  520. id
  521. name
  522. couponCode
  523. }
  524. discounts {
  525. description
  526. adjustmentSource
  527. amount
  528. amountWithTax
  529. }
  530. shippingAddress {
  531. ...ShippingAddress
  532. }
  533. billingAddress {
  534. ...ShippingAddress
  535. }
  536. shippingLines {
  537. id
  538. discountedPriceWithTax
  539. shippingMethod {
  540. id
  541. name
  542. }
  543. }
  544. }
  545. `,
  546. [paymentFragment, shippingAddressFragment],
  547. );
  548. export const promotionFragment = graphql(
  549. `
  550. fragment Promotion on Promotion {
  551. id
  552. createdAt
  553. updatedAt
  554. couponCode
  555. startsAt
  556. endsAt
  557. name
  558. description
  559. enabled
  560. perCustomerUsageLimit
  561. usageLimit
  562. conditions {
  563. ...ConfigurableOperation
  564. }
  565. actions {
  566. ...ConfigurableOperation
  567. }
  568. translations {
  569. id
  570. languageCode
  571. name
  572. description
  573. }
  574. }
  575. `,
  576. [configurableFragment],
  577. );
  578. export const zoneFragment = graphql(
  579. `
  580. fragment Zone on Zone {
  581. id
  582. name
  583. members {
  584. ...Country
  585. }
  586. }
  587. `,
  588. [countryFragment],
  589. );
  590. export const taxRateFragment = graphql(`
  591. fragment TaxRate on TaxRate {
  592. id
  593. name
  594. enabled
  595. value
  596. category {
  597. id
  598. name
  599. }
  600. zone {
  601. id
  602. name
  603. }
  604. customerGroup {
  605. id
  606. name
  607. }
  608. }
  609. `);
  610. export const currentUserFragment = graphql(`
  611. fragment CurrentUser on CurrentUser {
  612. id
  613. identifier
  614. channels {
  615. code
  616. token
  617. permissions
  618. }
  619. }
  620. `);
  621. export const variantWithStockFragment = graphql(`
  622. fragment VariantWithStock on ProductVariant {
  623. id
  624. stockOnHand
  625. stockAllocated
  626. stockMovements {
  627. items {
  628. ... on StockMovement {
  629. id
  630. type
  631. quantity
  632. }
  633. }
  634. totalItems
  635. }
  636. }
  637. `);
  638. export const fulfillmentFragment = graphql(`
  639. fragment Fulfillment on Fulfillment {
  640. id
  641. state
  642. nextStates
  643. method
  644. trackingCode
  645. lines {
  646. orderLineId
  647. quantity
  648. }
  649. }
  650. `);
  651. export const channelFragment = graphql(`
  652. fragment Channel on Channel {
  653. id
  654. code
  655. token
  656. currencyCode
  657. availableCurrencyCodes
  658. defaultCurrencyCode
  659. defaultLanguageCode
  660. defaultShippingZone {
  661. id
  662. }
  663. defaultTaxZone {
  664. id
  665. }
  666. pricesIncludeTax
  667. }
  668. `);
  669. export const globalSettingsFragment = graphql(`
  670. fragment GlobalSettings on GlobalSettings {
  671. id
  672. availableLanguages
  673. trackInventory
  674. outOfStockThreshold
  675. serverConfig {
  676. orderProcess {
  677. name
  678. to
  679. }
  680. permittedAssetTypes
  681. permissions {
  682. name
  683. description
  684. assignable
  685. }
  686. customFieldConfig {
  687. Customer {
  688. ... on CustomField {
  689. name
  690. }
  691. }
  692. }
  693. }
  694. }
  695. `);
  696. export const customerGroupFragment = graphql(`
  697. fragment CustomerGroup on CustomerGroup {
  698. id
  699. name
  700. customers {
  701. items {
  702. id
  703. }
  704. totalItems
  705. }
  706. }
  707. `);
  708. export const productOptionGroupFragment = graphql(`
  709. fragment ProductOptionGroup on ProductOptionGroup {
  710. id
  711. code
  712. name
  713. options {
  714. id
  715. code
  716. name
  717. }
  718. translations {
  719. id
  720. languageCode
  721. name
  722. }
  723. }
  724. `);
  725. export const productWithOptionsFragment = graphql(`
  726. fragment ProductWithOptions on Product {
  727. id
  728. optionGroups {
  729. id
  730. code
  731. options {
  732. id
  733. code
  734. }
  735. }
  736. }
  737. `);
  738. export const shippingMethodFragment = graphql(`
  739. fragment ShippingMethod on ShippingMethod {
  740. id
  741. code
  742. name
  743. description
  744. calculator {
  745. code
  746. args {
  747. name
  748. value
  749. }
  750. }
  751. checker {
  752. code
  753. args {
  754. name
  755. value
  756. }
  757. }
  758. }
  759. `);