fragments.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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. }
  188. }
  189. ${ASSET_FRAGMENT}
  190. ${CONFIGURABLE_FRAGMENT}
  191. `;
  192. export const FACET_VALUE_FRAGMENT = gql`
  193. fragment FacetValue on FacetValue {
  194. id
  195. languageCode
  196. code
  197. name
  198. translations {
  199. id
  200. languageCode
  201. name
  202. }
  203. facet {
  204. id
  205. name
  206. }
  207. }
  208. `;
  209. export const FACET_WITH_VALUES_FRAGMENT = gql`
  210. fragment FacetWithValues on Facet {
  211. id
  212. languageCode
  213. isPrivate
  214. code
  215. name
  216. translations {
  217. id
  218. languageCode
  219. name
  220. }
  221. values {
  222. ...FacetValue
  223. }
  224. }
  225. ${FACET_VALUE_FRAGMENT}
  226. `;
  227. export const COUNTRY_FRAGMENT = gql`
  228. fragment Country on Country {
  229. id
  230. code
  231. name
  232. enabled
  233. translations {
  234. id
  235. languageCode
  236. name
  237. }
  238. }
  239. `;
  240. export const ADDRESS_FRAGMENT = gql`
  241. fragment Address on Address {
  242. id
  243. fullName
  244. company
  245. streetLine1
  246. streetLine2
  247. city
  248. province
  249. postalCode
  250. country {
  251. id
  252. code
  253. name
  254. }
  255. phoneNumber
  256. defaultShippingAddress
  257. defaultBillingAddress
  258. }
  259. `;
  260. export const CUSTOMER_FRAGMENT = gql`
  261. fragment Customer on Customer {
  262. id
  263. title
  264. firstName
  265. lastName
  266. phoneNumber
  267. emailAddress
  268. user {
  269. id
  270. identifier
  271. verified
  272. lastLogin
  273. }
  274. addresses {
  275. ...Address
  276. }
  277. }
  278. ${ADDRESS_FRAGMENT}
  279. `;
  280. export const ADJUSTMENT_FRAGMENT = gql`
  281. fragment Adjustment on Adjustment {
  282. adjustmentSource
  283. amount
  284. description
  285. type
  286. }
  287. `;
  288. export const SHIPPING_ADDRESS_FRAGMENT = gql`
  289. fragment ShippingAddress on OrderAddress {
  290. fullName
  291. company
  292. streetLine1
  293. streetLine2
  294. city
  295. province
  296. postalCode
  297. country
  298. phoneNumber
  299. }
  300. `;
  301. export const ORDER_FRAGMENT = gql`
  302. fragment Order on Order {
  303. id
  304. createdAt
  305. updatedAt
  306. code
  307. active
  308. state
  309. total
  310. totalWithTax
  311. totalQuantity
  312. currencyCode
  313. customer {
  314. id
  315. firstName
  316. lastName
  317. }
  318. }
  319. `;
  320. export const ORDER_ITEM_FRAGMENT = gql`
  321. fragment OrderItem on OrderItem {
  322. id
  323. cancelled
  324. unitPrice
  325. unitPriceWithTax
  326. taxRate
  327. fulfillment {
  328. id
  329. }
  330. }
  331. `;
  332. export const PAYMENT_FRAGMENT = gql`
  333. fragment Payment on Payment {
  334. id
  335. transactionId
  336. amount
  337. method
  338. state
  339. nextStates
  340. metadata
  341. refunds {
  342. id
  343. total
  344. reason
  345. }
  346. }
  347. `;
  348. export const ORDER_WITH_LINES_FRAGMENT = gql`
  349. fragment OrderWithLines on Order {
  350. id
  351. createdAt
  352. updatedAt
  353. code
  354. state
  355. active
  356. customer {
  357. id
  358. firstName
  359. lastName
  360. }
  361. lines {
  362. id
  363. featuredAsset {
  364. preview
  365. }
  366. productVariant {
  367. id
  368. name
  369. sku
  370. }
  371. unitPrice
  372. unitPriceWithTax
  373. quantity
  374. items {
  375. ...OrderItem
  376. }
  377. linePriceWithTax
  378. }
  379. surcharges {
  380. id
  381. description
  382. sku
  383. price
  384. priceWithTax
  385. }
  386. subTotal
  387. subTotalWithTax
  388. total
  389. totalWithTax
  390. totalQuantity
  391. currencyCode
  392. shipping
  393. shippingWithTax
  394. shippingLines {
  395. priceWithTax
  396. shippingMethod {
  397. id
  398. code
  399. name
  400. description
  401. }
  402. }
  403. shippingAddress {
  404. ...ShippingAddress
  405. }
  406. payments {
  407. ...Payment
  408. }
  409. total
  410. }
  411. ${SHIPPING_ADDRESS_FRAGMENT}
  412. ${ORDER_ITEM_FRAGMENT}
  413. ${PAYMENT_FRAGMENT}
  414. `;
  415. export const PROMOTION_FRAGMENT = gql`
  416. fragment Promotion on Promotion {
  417. id
  418. createdAt
  419. updatedAt
  420. couponCode
  421. startsAt
  422. endsAt
  423. name
  424. enabled
  425. conditions {
  426. ...ConfigurableOperation
  427. }
  428. actions {
  429. ...ConfigurableOperation
  430. }
  431. }
  432. ${CONFIGURABLE_FRAGMENT}
  433. `;
  434. export const ZONE_FRAGMENT = gql`
  435. fragment Zone on Zone {
  436. id
  437. name
  438. members {
  439. ...Country
  440. }
  441. }
  442. ${COUNTRY_FRAGMENT}
  443. `;
  444. export const TAX_RATE_FRAGMENT = gql`
  445. fragment TaxRate on TaxRate {
  446. id
  447. name
  448. enabled
  449. value
  450. category {
  451. id
  452. name
  453. }
  454. zone {
  455. id
  456. name
  457. }
  458. customerGroup {
  459. id
  460. name
  461. }
  462. }
  463. `;
  464. export const CURRENT_USER_FRAGMENT = gql`
  465. fragment CurrentUser on CurrentUser {
  466. id
  467. identifier
  468. channels {
  469. code
  470. token
  471. permissions
  472. }
  473. }
  474. `;
  475. export const VARIANT_WITH_STOCK_FRAGMENT = gql`
  476. fragment VariantWithStock on ProductVariant {
  477. id
  478. stockOnHand
  479. stockAllocated
  480. stockMovements {
  481. items {
  482. ... on StockMovement {
  483. id
  484. type
  485. quantity
  486. }
  487. }
  488. totalItems
  489. }
  490. }
  491. `;
  492. export const FULFILLMENT_FRAGMENT = gql`
  493. fragment Fulfillment on Fulfillment {
  494. id
  495. state
  496. nextStates
  497. method
  498. trackingCode
  499. orderItems {
  500. id
  501. }
  502. }
  503. `;
  504. export const CHANNEL_FRAGMENT = gql`
  505. fragment Channel on Channel {
  506. id
  507. code
  508. token
  509. currencyCode
  510. defaultLanguageCode
  511. defaultShippingZone {
  512. id
  513. }
  514. defaultTaxZone {
  515. id
  516. }
  517. pricesIncludeTax
  518. }
  519. `;
  520. export const GLOBAL_SETTINGS_FRAGMENT = gql`
  521. fragment GlobalSettings on GlobalSettings {
  522. id
  523. availableLanguages
  524. trackInventory
  525. outOfStockThreshold
  526. serverConfig {
  527. orderProcess {
  528. name
  529. to
  530. }
  531. permittedAssetTypes
  532. permissions {
  533. name
  534. description
  535. assignable
  536. }
  537. customFieldConfig {
  538. Customer {
  539. ... on CustomField {
  540. name
  541. }
  542. }
  543. }
  544. }
  545. }
  546. `;
  547. export const CUSTOMER_GROUP_FRAGMENT = gql`
  548. fragment CustomerGroup on CustomerGroup {
  549. id
  550. name
  551. customers {
  552. items {
  553. id
  554. }
  555. totalItems
  556. }
  557. }
  558. `;
  559. export const PRODUCT_OPTION_GROUP_FRAGMENT = gql`
  560. fragment ProductOptionGroup on ProductOptionGroup {
  561. id
  562. code
  563. name
  564. options {
  565. id
  566. code
  567. name
  568. }
  569. translations {
  570. id
  571. languageCode
  572. name
  573. }
  574. }
  575. `;
  576. export const PRODUCT_WITH_OPTIONS_FRAGMENT = gql`
  577. fragment ProductWithOptions on Product {
  578. id
  579. optionGroups {
  580. id
  581. code
  582. options {
  583. id
  584. code
  585. }
  586. }
  587. }
  588. `;
  589. export const SHIPPING_METHOD_FRAGMENT = gql`
  590. fragment ShippingMethod on ShippingMethod {
  591. id
  592. code
  593. name
  594. description
  595. calculator {
  596. code
  597. args {
  598. name
  599. value
  600. }
  601. }
  602. checker {
  603. code
  604. args {
  605. name
  606. value
  607. }
  608. }
  609. }
  610. `;