fragments.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  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. perCustomerUsageLimit
  434. usageLimit
  435. conditions {
  436. ...ConfigurableOperation
  437. }
  438. actions {
  439. ...ConfigurableOperation
  440. }
  441. translations {
  442. id
  443. languageCode
  444. name
  445. description
  446. }
  447. }
  448. ${CONFIGURABLE_FRAGMENT}
  449. `;
  450. export const ZONE_FRAGMENT = gql`
  451. fragment Zone on Zone {
  452. id
  453. name
  454. members {
  455. ...Country
  456. }
  457. }
  458. ${COUNTRY_FRAGMENT}
  459. `;
  460. export const TAX_RATE_FRAGMENT = gql`
  461. fragment TaxRate on TaxRate {
  462. id
  463. name
  464. enabled
  465. value
  466. category {
  467. id
  468. name
  469. }
  470. zone {
  471. id
  472. name
  473. }
  474. customerGroup {
  475. id
  476. name
  477. }
  478. }
  479. `;
  480. export const CURRENT_USER_FRAGMENT = gql`
  481. fragment CurrentUser on CurrentUser {
  482. id
  483. identifier
  484. channels {
  485. code
  486. token
  487. permissions
  488. }
  489. }
  490. `;
  491. export const VARIANT_WITH_STOCK_FRAGMENT = gql`
  492. fragment VariantWithStock on ProductVariant {
  493. id
  494. stockOnHand
  495. stockAllocated
  496. stockMovements {
  497. items {
  498. ... on StockMovement {
  499. id
  500. type
  501. quantity
  502. }
  503. }
  504. totalItems
  505. }
  506. }
  507. `;
  508. export const FULFILLMENT_FRAGMENT = gql`
  509. fragment Fulfillment on Fulfillment {
  510. id
  511. state
  512. nextStates
  513. method
  514. trackingCode
  515. lines {
  516. orderLineId
  517. quantity
  518. }
  519. }
  520. `;
  521. export const CHANNEL_FRAGMENT = gql`
  522. fragment Channel on Channel {
  523. id
  524. code
  525. token
  526. currencyCode
  527. availableCurrencyCodes
  528. defaultCurrencyCode
  529. defaultLanguageCode
  530. defaultShippingZone {
  531. id
  532. }
  533. defaultTaxZone {
  534. id
  535. }
  536. pricesIncludeTax
  537. }
  538. `;
  539. export const GLOBAL_SETTINGS_FRAGMENT = gql`
  540. fragment GlobalSettings on GlobalSettings {
  541. id
  542. availableLanguages
  543. trackInventory
  544. outOfStockThreshold
  545. serverConfig {
  546. orderProcess {
  547. name
  548. to
  549. }
  550. permittedAssetTypes
  551. permissions {
  552. name
  553. description
  554. assignable
  555. }
  556. customFieldConfig {
  557. Customer {
  558. ... on CustomField {
  559. name
  560. }
  561. }
  562. }
  563. }
  564. }
  565. `;
  566. export const CUSTOMER_GROUP_FRAGMENT = gql`
  567. fragment CustomerGroup on CustomerGroup {
  568. id
  569. name
  570. customers {
  571. items {
  572. id
  573. }
  574. totalItems
  575. }
  576. }
  577. `;
  578. export const PRODUCT_OPTION_GROUP_FRAGMENT = gql`
  579. fragment ProductOptionGroup on ProductOptionGroup {
  580. id
  581. code
  582. name
  583. options {
  584. id
  585. code
  586. name
  587. }
  588. translations {
  589. id
  590. languageCode
  591. name
  592. }
  593. }
  594. `;
  595. export const PRODUCT_WITH_OPTIONS_FRAGMENT = gql`
  596. fragment ProductWithOptions on Product {
  597. id
  598. optionGroups {
  599. id
  600. code
  601. options {
  602. id
  603. code
  604. }
  605. }
  606. }
  607. `;
  608. export const SHIPPING_METHOD_FRAGMENT = gql`
  609. fragment ShippingMethod on ShippingMethod {
  610. id
  611. code
  612. name
  613. description
  614. calculator {
  615. code
  616. args {
  617. name
  618. value
  619. }
  620. }
  621. checker {
  622. code
  623. args {
  624. name
  625. value
  626. }
  627. }
  628. }
  629. `;