fragments.ts 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. price
  39. currencyCode
  40. priceIncludesTax
  41. priceWithTax
  42. stockOnHand
  43. trackInventory
  44. taxRateApplied {
  45. id
  46. name
  47. value
  48. }
  49. taxCategory {
  50. id
  51. name
  52. }
  53. sku
  54. options {
  55. id
  56. code
  57. languageCode
  58. name
  59. }
  60. facetValues {
  61. id
  62. code
  63. name
  64. facet {
  65. id
  66. name
  67. }
  68. }
  69. featuredAsset {
  70. ...Asset
  71. }
  72. assets {
  73. ...Asset
  74. }
  75. translations {
  76. id
  77. languageCode
  78. name
  79. }
  80. }
  81. ${ASSET_FRAGMENT}
  82. `;
  83. export const PRODUCT_WITH_VARIANTS_FRAGMENT = gql`
  84. fragment ProductWithVariants on Product {
  85. id
  86. enabled
  87. languageCode
  88. name
  89. slug
  90. description
  91. featuredAsset {
  92. ...Asset
  93. }
  94. assets {
  95. ...Asset
  96. }
  97. translations {
  98. languageCode
  99. name
  100. slug
  101. description
  102. }
  103. optionGroups {
  104. id
  105. languageCode
  106. code
  107. name
  108. }
  109. variants {
  110. ...ProductVariant
  111. }
  112. facetValues {
  113. id
  114. code
  115. name
  116. facet {
  117. id
  118. name
  119. }
  120. }
  121. channels {
  122. id
  123. code
  124. }
  125. }
  126. ${PRODUCT_VARIANT_FRAGMENT}
  127. ${ASSET_FRAGMENT}
  128. `;
  129. export const ROLE_FRAGMENT = gql`
  130. fragment Role on Role {
  131. id
  132. code
  133. description
  134. permissions
  135. channels {
  136. id
  137. code
  138. token
  139. }
  140. }
  141. `;
  142. export const CONFIGURABLE_FRAGMENT = gql`
  143. fragment ConfigurableOperation on ConfigurableOperation {
  144. args {
  145. name
  146. type
  147. value
  148. }
  149. code
  150. }
  151. `;
  152. export const COLLECTION_FRAGMENT = gql`
  153. fragment Collection on Collection {
  154. id
  155. name
  156. description
  157. isPrivate
  158. languageCode
  159. featuredAsset {
  160. ...Asset
  161. }
  162. assets {
  163. ...Asset
  164. }
  165. filters {
  166. ...ConfigurableOperation
  167. }
  168. translations {
  169. id
  170. languageCode
  171. name
  172. description
  173. }
  174. parent {
  175. id
  176. name
  177. }
  178. children {
  179. id
  180. name
  181. }
  182. }
  183. ${ASSET_FRAGMENT}
  184. ${CONFIGURABLE_FRAGMENT}
  185. `;
  186. export const FACET_VALUE_FRAGMENT = gql`
  187. fragment FacetValue on FacetValue {
  188. id
  189. languageCode
  190. code
  191. name
  192. translations {
  193. id
  194. languageCode
  195. name
  196. }
  197. facet {
  198. id
  199. name
  200. }
  201. }
  202. `;
  203. export const FACET_WITH_VALUES_FRAGMENT = gql`
  204. fragment FacetWithValues on Facet {
  205. id
  206. languageCode
  207. isPrivate
  208. code
  209. name
  210. translations {
  211. id
  212. languageCode
  213. name
  214. }
  215. values {
  216. ...FacetValue
  217. }
  218. }
  219. ${FACET_VALUE_FRAGMENT}
  220. `;
  221. export const COUNTRY_FRAGMENT = gql`
  222. fragment Country on Country {
  223. id
  224. code
  225. name
  226. enabled
  227. translations {
  228. id
  229. languageCode
  230. name
  231. }
  232. }
  233. `;
  234. export const ADDRESS_FRAGMENT = gql`
  235. fragment Address on Address {
  236. id
  237. fullName
  238. company
  239. streetLine1
  240. streetLine2
  241. city
  242. province
  243. postalCode
  244. country {
  245. id
  246. code
  247. name
  248. }
  249. phoneNumber
  250. defaultShippingAddress
  251. defaultBillingAddress
  252. }
  253. `;
  254. export const CUSTOMER_FRAGMENT = gql`
  255. fragment Customer on Customer {
  256. id
  257. title
  258. firstName
  259. lastName
  260. phoneNumber
  261. emailAddress
  262. user {
  263. id
  264. identifier
  265. verified
  266. lastLogin
  267. }
  268. addresses {
  269. ...Address
  270. }
  271. }
  272. ${ADDRESS_FRAGMENT}
  273. `;
  274. export const ADJUSTMENT_FRAGMENT = gql`
  275. fragment Adjustment on Adjustment {
  276. adjustmentSource
  277. amount
  278. description
  279. type
  280. }
  281. `;
  282. export const SHIPPING_ADDRESS_FRAGMENT = gql`
  283. fragment ShippingAddress on OrderAddress {
  284. fullName
  285. company
  286. streetLine1
  287. streetLine2
  288. city
  289. province
  290. postalCode
  291. country
  292. phoneNumber
  293. }
  294. `;
  295. export const ORDER_FRAGMENT = gql`
  296. fragment Order on Order {
  297. id
  298. createdAt
  299. updatedAt
  300. code
  301. state
  302. total
  303. currencyCode
  304. customer {
  305. id
  306. firstName
  307. lastName
  308. }
  309. }
  310. `;
  311. export const ORDER_ITEM_FRAGMENT = gql`
  312. fragment OrderItem on OrderItem {
  313. id
  314. cancelled
  315. unitPrice
  316. unitPriceIncludesTax
  317. unitPriceWithTax
  318. taxRate
  319. fulfillment {
  320. id
  321. }
  322. }
  323. `;
  324. export const ORDER_WITH_LINES_FRAGMENT = gql`
  325. fragment OrderWithLines on Order {
  326. id
  327. createdAt
  328. updatedAt
  329. code
  330. state
  331. active
  332. customer {
  333. id
  334. firstName
  335. lastName
  336. }
  337. lines {
  338. id
  339. featuredAsset {
  340. preview
  341. }
  342. productVariant {
  343. id
  344. name
  345. sku
  346. }
  347. unitPrice
  348. unitPriceWithTax
  349. quantity
  350. items {
  351. ...OrderItem
  352. }
  353. totalPrice
  354. }
  355. adjustments {
  356. ...Adjustment
  357. }
  358. subTotal
  359. subTotalBeforeTax
  360. totalBeforeTax
  361. currencyCode
  362. shipping
  363. shippingMethod {
  364. id
  365. code
  366. description
  367. }
  368. shippingAddress {
  369. ...ShippingAddress
  370. }
  371. payments {
  372. id
  373. transactionId
  374. amount
  375. method
  376. state
  377. metadata
  378. }
  379. total
  380. }
  381. ${ADJUSTMENT_FRAGMENT}
  382. ${SHIPPING_ADDRESS_FRAGMENT}
  383. ${ORDER_ITEM_FRAGMENT}
  384. `;
  385. export const PROMOTION_FRAGMENT = gql`
  386. fragment Promotion on Promotion {
  387. id
  388. createdAt
  389. updatedAt
  390. couponCode
  391. startsAt
  392. endsAt
  393. name
  394. enabled
  395. conditions {
  396. ...ConfigurableOperation
  397. }
  398. actions {
  399. ...ConfigurableOperation
  400. }
  401. }
  402. ${CONFIGURABLE_FRAGMENT}
  403. `;
  404. export const ZONE_FRAGMENT = gql`
  405. fragment Zone on Zone {
  406. id
  407. name
  408. members {
  409. ...Country
  410. }
  411. }
  412. ${COUNTRY_FRAGMENT}
  413. `;
  414. export const TAX_RATE_FRAGMENT = gql`
  415. fragment TaxRate on TaxRate {
  416. id
  417. name
  418. enabled
  419. value
  420. category {
  421. id
  422. name
  423. }
  424. zone {
  425. id
  426. name
  427. }
  428. customerGroup {
  429. id
  430. name
  431. }
  432. }
  433. `;
  434. export const CURRENT_USER_FRAGMENT = gql`
  435. fragment CurrentUser on CurrentUser {
  436. id
  437. identifier
  438. channels {
  439. code
  440. token
  441. permissions
  442. }
  443. }
  444. `;
  445. export const VARIANT_WITH_STOCK_FRAGMENT = gql`
  446. fragment VariantWithStock on ProductVariant {
  447. id
  448. stockOnHand
  449. stockMovements {
  450. items {
  451. ... on StockMovement {
  452. id
  453. type
  454. quantity
  455. }
  456. }
  457. totalItems
  458. }
  459. }
  460. `;