fragments.ts 8.2 KB

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