fragments.ts 11 KB

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