fragments.ts 11 KB

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