fragments.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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 PAYMENT_FRAGMENT = gql`
  322. fragment Payment on Payment {
  323. id
  324. transactionId
  325. amount
  326. method
  327. state
  328. nextStates
  329. metadata
  330. refunds {
  331. id
  332. total
  333. reason
  334. }
  335. }
  336. `;
  337. export const ORDER_WITH_LINES_FRAGMENT = gql`
  338. fragment OrderWithLines on Order {
  339. id
  340. createdAt
  341. updatedAt
  342. code
  343. state
  344. active
  345. customer {
  346. id
  347. firstName
  348. lastName
  349. }
  350. lines {
  351. id
  352. featuredAsset {
  353. preview
  354. }
  355. productVariant {
  356. id
  357. name
  358. sku
  359. }
  360. taxLines {
  361. description
  362. taxRate
  363. }
  364. unitPrice
  365. unitPriceWithTax
  366. quantity
  367. unitPrice
  368. unitPriceWithTax
  369. taxRate
  370. linePriceWithTax
  371. }
  372. surcharges {
  373. id
  374. description
  375. sku
  376. price
  377. priceWithTax
  378. }
  379. subTotal
  380. subTotalWithTax
  381. total
  382. totalWithTax
  383. totalQuantity
  384. currencyCode
  385. shipping
  386. shippingWithTax
  387. shippingLines {
  388. priceWithTax
  389. shippingMethod {
  390. id
  391. code
  392. name
  393. description
  394. }
  395. }
  396. shippingAddress {
  397. ...ShippingAddress
  398. }
  399. payments {
  400. ...Payment
  401. }
  402. fulfillments {
  403. id
  404. state
  405. method
  406. trackingCode
  407. lines {
  408. orderLineId
  409. quantity
  410. }
  411. }
  412. total
  413. }
  414. ${SHIPPING_ADDRESS_FRAGMENT}
  415. ${PAYMENT_FRAGMENT}
  416. `;
  417. export const PROMOTION_FRAGMENT = gql`
  418. fragment Promotion on Promotion {
  419. id
  420. createdAt
  421. updatedAt
  422. couponCode
  423. startsAt
  424. endsAt
  425. name
  426. description
  427. enabled
  428. conditions {
  429. ...ConfigurableOperation
  430. }
  431. actions {
  432. ...ConfigurableOperation
  433. }
  434. translations {
  435. id
  436. languageCode
  437. name
  438. description
  439. }
  440. }
  441. ${CONFIGURABLE_FRAGMENT}
  442. `;
  443. export const ZONE_FRAGMENT = gql`
  444. fragment Zone on Zone {
  445. id
  446. name
  447. members {
  448. ...Country
  449. }
  450. }
  451. ${COUNTRY_FRAGMENT}
  452. `;
  453. export const TAX_RATE_FRAGMENT = gql`
  454. fragment TaxRate on TaxRate {
  455. id
  456. name
  457. enabled
  458. value
  459. category {
  460. id
  461. name
  462. }
  463. zone {
  464. id
  465. name
  466. }
  467. customerGroup {
  468. id
  469. name
  470. }
  471. }
  472. `;
  473. export const CURRENT_USER_FRAGMENT = gql`
  474. fragment CurrentUser on CurrentUser {
  475. id
  476. identifier
  477. channels {
  478. code
  479. token
  480. permissions
  481. }
  482. }
  483. `;
  484. export const VARIANT_WITH_STOCK_FRAGMENT = gql`
  485. fragment VariantWithStock on ProductVariant {
  486. id
  487. stockOnHand
  488. stockAllocated
  489. stockMovements {
  490. items {
  491. ... on StockMovement {
  492. id
  493. type
  494. quantity
  495. }
  496. }
  497. totalItems
  498. }
  499. }
  500. `;
  501. export const FULFILLMENT_FRAGMENT = gql`
  502. fragment Fulfillment on Fulfillment {
  503. id
  504. state
  505. nextStates
  506. method
  507. trackingCode
  508. lines {
  509. orderLineId
  510. quantity
  511. }
  512. }
  513. `;
  514. export const CHANNEL_FRAGMENT = gql`
  515. fragment Channel on Channel {
  516. id
  517. code
  518. token
  519. currencyCode
  520. defaultLanguageCode
  521. defaultShippingZone {
  522. id
  523. }
  524. defaultTaxZone {
  525. id
  526. }
  527. pricesIncludeTax
  528. }
  529. `;
  530. export const GLOBAL_SETTINGS_FRAGMENT = gql`
  531. fragment GlobalSettings on GlobalSettings {
  532. id
  533. availableLanguages
  534. trackInventory
  535. outOfStockThreshold
  536. serverConfig {
  537. orderProcess {
  538. name
  539. to
  540. }
  541. permittedAssetTypes
  542. permissions {
  543. name
  544. description
  545. assignable
  546. }
  547. customFieldConfig {
  548. Customer {
  549. ... on CustomField {
  550. name
  551. }
  552. }
  553. }
  554. }
  555. }
  556. `;
  557. export const CUSTOMER_GROUP_FRAGMENT = gql`
  558. fragment CustomerGroup on CustomerGroup {
  559. id
  560. name
  561. customers {
  562. items {
  563. id
  564. }
  565. totalItems
  566. }
  567. }
  568. `;
  569. export const PRODUCT_OPTION_GROUP_FRAGMENT = gql`
  570. fragment ProductOptionGroup on ProductOptionGroup {
  571. id
  572. code
  573. name
  574. options {
  575. id
  576. code
  577. name
  578. }
  579. translations {
  580. id
  581. languageCode
  582. name
  583. }
  584. }
  585. `;
  586. export const PRODUCT_WITH_OPTIONS_FRAGMENT = gql`
  587. fragment ProductWithOptions on Product {
  588. id
  589. optionGroups {
  590. id
  591. code
  592. options {
  593. id
  594. code
  595. }
  596. }
  597. }
  598. `;
  599. export const SHIPPING_METHOD_FRAGMENT = gql`
  600. fragment ShippingMethod on ShippingMethod {
  601. id
  602. code
  603. name
  604. description
  605. calculator {
  606. code
  607. args {
  608. name
  609. value
  610. }
  611. }
  612. checker {
  613. code
  614. args {
  615. name
  616. value
  617. }
  618. }
  619. }
  620. `;