fragments.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. import gql from 'graphql-tag';
  2. export const ADMINISTRATOR_FRAGMENT = gql`
  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 ASSET_FRAGMENT = gql`
  22. fragment Asset on Asset {
  23. id
  24. name
  25. fileSize
  26. mimeType
  27. type
  28. preview
  29. source
  30. }
  31. `;
  32. export const PRODUCT_VARIANT_FRAGMENT = gql`
  33. fragment ProductVariant on ProductVariant {
  34. id
  35. createdAt
  36. updatedAt
  37. enabled
  38. languageCode
  39. name
  40. currencyCode
  41. price
  42. priceWithTax
  43. prices {
  44. currencyCode
  45. price
  46. }
  47. stockOnHand
  48. trackInventory
  49. taxRateApplied {
  50. id
  51. name
  52. value
  53. }
  54. taxCategory {
  55. id
  56. name
  57. }
  58. sku
  59. options {
  60. id
  61. code
  62. languageCode
  63. groupId
  64. name
  65. }
  66. facetValues {
  67. id
  68. code
  69. name
  70. facet {
  71. id
  72. name
  73. }
  74. }
  75. featuredAsset {
  76. ...Asset
  77. }
  78. assets {
  79. ...Asset
  80. }
  81. translations {
  82. id
  83. languageCode
  84. name
  85. }
  86. channels {
  87. id
  88. code
  89. }
  90. }
  91. ${ASSET_FRAGMENT}
  92. `;
  93. export const PRODUCT_WITH_VARIANTS_FRAGMENT = gql`
  94. fragment ProductWithVariants on Product {
  95. id
  96. enabled
  97. languageCode
  98. name
  99. slug
  100. description
  101. featuredAsset {
  102. ...Asset
  103. }
  104. assets {
  105. ...Asset
  106. }
  107. translations {
  108. languageCode
  109. name
  110. slug
  111. description
  112. }
  113. optionGroups {
  114. id
  115. languageCode
  116. code
  117. name
  118. }
  119. variants {
  120. ...ProductVariant
  121. }
  122. facetValues {
  123. id
  124. code
  125. name
  126. facet {
  127. id
  128. name
  129. }
  130. }
  131. channels {
  132. id
  133. code
  134. }
  135. }
  136. ${PRODUCT_VARIANT_FRAGMENT}
  137. ${ASSET_FRAGMENT}
  138. `;
  139. export const ROLE_FRAGMENT = gql`
  140. fragment Role on Role {
  141. id
  142. code
  143. description
  144. permissions
  145. channels {
  146. id
  147. code
  148. token
  149. }
  150. }
  151. `;
  152. export const CONFIGURABLE_FRAGMENT = gql`
  153. fragment ConfigurableOperation on ConfigurableOperation {
  154. args {
  155. name
  156. value
  157. }
  158. code
  159. }
  160. `;
  161. export const COLLECTION_FRAGMENT = gql`
  162. fragment Collection on Collection {
  163. id
  164. name
  165. slug
  166. description
  167. isPrivate
  168. languageCode
  169. featuredAsset {
  170. ...Asset
  171. }
  172. assets {
  173. ...Asset
  174. }
  175. filters {
  176. ...ConfigurableOperation
  177. }
  178. translations {
  179. id
  180. languageCode
  181. name
  182. slug
  183. description
  184. }
  185. parent {
  186. id
  187. name
  188. }
  189. children {
  190. id
  191. name
  192. position
  193. }
  194. }
  195. ${ASSET_FRAGMENT}
  196. ${CONFIGURABLE_FRAGMENT}
  197. `;
  198. export const FACET_VALUE_FRAGMENT = gql`
  199. fragment FacetValue on FacetValue {
  200. id
  201. languageCode
  202. code
  203. name
  204. translations {
  205. id
  206. languageCode
  207. name
  208. }
  209. facet {
  210. id
  211. name
  212. }
  213. }
  214. `;
  215. export const FACET_WITH_VALUES_FRAGMENT = gql`
  216. fragment FacetWithValues on Facet {
  217. id
  218. languageCode
  219. isPrivate
  220. code
  221. name
  222. translations {
  223. id
  224. languageCode
  225. name
  226. }
  227. values {
  228. ...FacetValue
  229. }
  230. }
  231. ${FACET_VALUE_FRAGMENT}
  232. `;
  233. export const COUNTRY_FRAGMENT = gql`
  234. fragment Country on Region {
  235. id
  236. code
  237. name
  238. enabled
  239. translations {
  240. id
  241. languageCode
  242. name
  243. }
  244. }
  245. `;
  246. export const ADDRESS_FRAGMENT = gql`
  247. fragment Address on Address {
  248. id
  249. fullName
  250. company
  251. streetLine1
  252. streetLine2
  253. city
  254. province
  255. postalCode
  256. country {
  257. id
  258. code
  259. name
  260. }
  261. phoneNumber
  262. defaultShippingAddress
  263. defaultBillingAddress
  264. }
  265. `;
  266. export const CUSTOMER_FRAGMENT = gql`
  267. fragment Customer on Customer {
  268. id
  269. title
  270. firstName
  271. lastName
  272. phoneNumber
  273. emailAddress
  274. user {
  275. id
  276. identifier
  277. verified
  278. lastLogin
  279. }
  280. addresses {
  281. ...Address
  282. }
  283. }
  284. ${ADDRESS_FRAGMENT}
  285. `;
  286. export const ADJUSTMENT_FRAGMENT = gql`
  287. fragment Adjustment on Adjustment {
  288. adjustmentSource
  289. amount
  290. description
  291. type
  292. }
  293. `;
  294. export const SHIPPING_ADDRESS_FRAGMENT = gql`
  295. fragment ShippingAddress on OrderAddress {
  296. fullName
  297. company
  298. streetLine1
  299. streetLine2
  300. city
  301. province
  302. postalCode
  303. country
  304. phoneNumber
  305. }
  306. `;
  307. export const ORDER_FRAGMENT = gql`
  308. fragment Order on Order {
  309. id
  310. createdAt
  311. updatedAt
  312. code
  313. active
  314. state
  315. total
  316. totalWithTax
  317. totalQuantity
  318. currencyCode
  319. customer {
  320. id
  321. firstName
  322. lastName
  323. }
  324. }
  325. `;
  326. export const PAYMENT_FRAGMENT = gql`
  327. fragment Payment on Payment {
  328. id
  329. transactionId
  330. amount
  331. method
  332. state
  333. nextStates
  334. metadata
  335. refunds {
  336. id
  337. total
  338. reason
  339. }
  340. }
  341. `;
  342. export const ORDER_WITH_LINES_FRAGMENT = gql`
  343. fragment OrderWithLines on Order {
  344. id
  345. createdAt
  346. updatedAt
  347. code
  348. state
  349. active
  350. customer {
  351. id
  352. firstName
  353. lastName
  354. }
  355. lines {
  356. id
  357. featuredAsset {
  358. preview
  359. }
  360. productVariant {
  361. id
  362. name
  363. sku
  364. }
  365. taxLines {
  366. description
  367. taxRate
  368. }
  369. unitPrice
  370. unitPriceWithTax
  371. quantity
  372. unitPrice
  373. unitPriceWithTax
  374. taxRate
  375. linePriceWithTax
  376. }
  377. surcharges {
  378. id
  379. description
  380. sku
  381. price
  382. priceWithTax
  383. }
  384. subTotal
  385. subTotalWithTax
  386. total
  387. totalWithTax
  388. totalQuantity
  389. currencyCode
  390. shipping
  391. shippingWithTax
  392. shippingLines {
  393. priceWithTax
  394. shippingMethod {
  395. id
  396. code
  397. name
  398. description
  399. }
  400. }
  401. shippingAddress {
  402. ...ShippingAddress
  403. }
  404. payments {
  405. ...Payment
  406. }
  407. fulfillments {
  408. id
  409. state
  410. method
  411. trackingCode
  412. lines {
  413. orderLineId
  414. quantity
  415. }
  416. }
  417. total
  418. }
  419. ${SHIPPING_ADDRESS_FRAGMENT}
  420. ${PAYMENT_FRAGMENT}
  421. `;
  422. export const PROMOTION_FRAGMENT = gql`
  423. fragment Promotion on Promotion {
  424. id
  425. createdAt
  426. updatedAt
  427. couponCode
  428. startsAt
  429. endsAt
  430. name
  431. description
  432. enabled
  433. conditions {
  434. ...ConfigurableOperation
  435. }
  436. actions {
  437. ...ConfigurableOperation
  438. }
  439. translations {
  440. id
  441. languageCode
  442. name
  443. description
  444. }
  445. }
  446. ${CONFIGURABLE_FRAGMENT}
  447. `;
  448. export const ZONE_FRAGMENT = gql`
  449. fragment Zone on Zone {
  450. id
  451. name
  452. members {
  453. ...Country
  454. }
  455. }
  456. ${COUNTRY_FRAGMENT}
  457. `;
  458. export const TAX_RATE_FRAGMENT = gql`
  459. fragment TaxRate on TaxRate {
  460. id
  461. name
  462. enabled
  463. value
  464. category {
  465. id
  466. name
  467. }
  468. zone {
  469. id
  470. name
  471. }
  472. customerGroup {
  473. id
  474. name
  475. }
  476. }
  477. `;
  478. export const CURRENT_USER_FRAGMENT = gql`
  479. fragment CurrentUser on CurrentUser {
  480. id
  481. identifier
  482. channels {
  483. code
  484. token
  485. permissions
  486. }
  487. }
  488. `;
  489. export const VARIANT_WITH_STOCK_FRAGMENT = gql`
  490. fragment VariantWithStock on ProductVariant {
  491. id
  492. stockOnHand
  493. stockAllocated
  494. stockMovements {
  495. items {
  496. ... on StockMovement {
  497. id
  498. type
  499. quantity
  500. }
  501. }
  502. totalItems
  503. }
  504. }
  505. `;
  506. export const FULFILLMENT_FRAGMENT = gql`
  507. fragment Fulfillment on Fulfillment {
  508. id
  509. state
  510. nextStates
  511. method
  512. trackingCode
  513. lines {
  514. orderLineId
  515. quantity
  516. }
  517. }
  518. `;
  519. export const CHANNEL_FRAGMENT = gql`
  520. fragment Channel on Channel {
  521. id
  522. code
  523. token
  524. currencyCode
  525. availableCurrencyCodes
  526. defaultCurrencyCode
  527. defaultLanguageCode
  528. defaultShippingZone {
  529. id
  530. }
  531. defaultTaxZone {
  532. id
  533. }
  534. pricesIncludeTax
  535. }
  536. `;
  537. export const GLOBAL_SETTINGS_FRAGMENT = gql`
  538. fragment GlobalSettings on GlobalSettings {
  539. id
  540. availableLanguages
  541. trackInventory
  542. outOfStockThreshold
  543. serverConfig {
  544. orderProcess {
  545. name
  546. to
  547. }
  548. permittedAssetTypes
  549. permissions {
  550. name
  551. description
  552. assignable
  553. }
  554. customFieldConfig {
  555. Customer {
  556. ... on CustomField {
  557. name
  558. }
  559. }
  560. }
  561. }
  562. }
  563. `;
  564. export const CUSTOMER_GROUP_FRAGMENT = gql`
  565. fragment CustomerGroup on CustomerGroup {
  566. id
  567. name
  568. customers {
  569. items {
  570. id
  571. }
  572. totalItems
  573. }
  574. }
  575. `;
  576. export const PRODUCT_OPTION_GROUP_FRAGMENT = gql`
  577. fragment ProductOptionGroup on ProductOptionGroup {
  578. id
  579. code
  580. name
  581. options {
  582. id
  583. code
  584. name
  585. }
  586. translations {
  587. id
  588. languageCode
  589. name
  590. }
  591. }
  592. `;
  593. export const PRODUCT_WITH_OPTIONS_FRAGMENT = gql`
  594. fragment ProductWithOptions on Product {
  595. id
  596. optionGroups {
  597. id
  598. code
  599. options {
  600. id
  601. code
  602. }
  603. }
  604. }
  605. `;
  606. export const SHIPPING_METHOD_FRAGMENT = gql`
  607. fragment ShippingMethod on ShippingMethod {
  608. id
  609. code
  610. name
  611. description
  612. calculator {
  613. code
  614. args {
  615. name
  616. value
  617. }
  618. }
  619. checker {
  620. code
  621. args {
  622. name
  623. value
  624. }
  625. }
  626. }
  627. `;