shop-definitions.ts 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. import gql from 'graphql-tag';
  2. export const TEST_ORDER_FRAGMENT = gql`
  3. fragment TestOrderFragment on Order {
  4. id
  5. code
  6. state
  7. active
  8. total
  9. couponCodes
  10. adjustments {
  11. adjustmentSource
  12. amount
  13. description
  14. type
  15. }
  16. lines {
  17. id
  18. quantity
  19. productVariant {
  20. id
  21. }
  22. }
  23. shipping
  24. shippingMethod {
  25. id
  26. code
  27. description
  28. }
  29. customer {
  30. id
  31. user {
  32. id
  33. identifier
  34. }
  35. }
  36. history {
  37. items {
  38. id
  39. type
  40. data
  41. }
  42. }
  43. }
  44. `;
  45. export const ADD_ITEM_TO_ORDER = gql`
  46. mutation AddItemToOrder($productVariantId: ID!, $quantity: Int!) {
  47. addItemToOrder(productVariantId: $productVariantId, quantity: $quantity) {
  48. id
  49. code
  50. state
  51. active
  52. total
  53. lines {
  54. id
  55. quantity
  56. productVariant {
  57. id
  58. }
  59. }
  60. adjustments {
  61. adjustmentSource
  62. amount
  63. description
  64. type
  65. }
  66. }
  67. }
  68. `;
  69. export const SEARCH_PRODUCTS_SHOP = gql`
  70. query SearchProductsShop($input: SearchInput!) {
  71. search(input: $input) {
  72. totalItems
  73. items {
  74. productId
  75. productName
  76. productPreview
  77. productVariantId
  78. productVariantName
  79. productVariantPreview
  80. sku
  81. collectionIds
  82. }
  83. }
  84. }
  85. `;
  86. export const REGISTER_ACCOUNT = gql`
  87. mutation Register($input: RegisterCustomerInput!) {
  88. registerCustomerAccount(input: $input)
  89. }
  90. `;
  91. export const VERIFY_EMAIL = gql`
  92. mutation Verify($password: String!, $token: String!) {
  93. verifyCustomerAccount(password: $password, token: $token) {
  94. user {
  95. id
  96. identifier
  97. }
  98. }
  99. }
  100. `;
  101. export const REFRESH_TOKEN = gql`
  102. mutation RefreshToken($emailAddress: String!) {
  103. refreshCustomerVerification(emailAddress: $emailAddress)
  104. }
  105. `;
  106. export const REQUEST_PASSWORD_RESET = gql`
  107. mutation RequestPasswordReset($identifier: String!) {
  108. requestPasswordReset(emailAddress: $identifier)
  109. }
  110. `;
  111. export const RESET_PASSWORD = gql`
  112. mutation ResetPassword($token: String!, $password: String!) {
  113. resetPassword(token: $token, password: $password) {
  114. user {
  115. id
  116. identifier
  117. }
  118. }
  119. }
  120. `;
  121. export const REQUEST_UPDATE_EMAIL_ADDRESS = gql`
  122. mutation RequestUpdateEmailAddress($password: String!, $newEmailAddress: String!) {
  123. requestUpdateCustomerEmailAddress(password: $password, newEmailAddress: $newEmailAddress)
  124. }
  125. `;
  126. export const UPDATE_EMAIL_ADDRESS = gql`
  127. mutation UpdateEmailAddress($token: String!) {
  128. updateCustomerEmailAddress(token: $token)
  129. }
  130. `;
  131. export const GET_ACTIVE_CUSTOMER = gql`
  132. query GetActiveCustomer {
  133. activeCustomer {
  134. id
  135. emailAddress
  136. }
  137. }
  138. `;
  139. export const CREATE_ADDRESS = gql`
  140. mutation CreateAddressShop($input: CreateAddressInput!) {
  141. createCustomerAddress(input: $input) {
  142. id
  143. streetLine1
  144. country {
  145. code
  146. }
  147. }
  148. }
  149. `;
  150. export const UPDATE_ADDRESS = gql`
  151. mutation UpdateAddressShop($input: UpdateAddressInput!) {
  152. updateCustomerAddress(input: $input) {
  153. streetLine1
  154. country {
  155. code
  156. }
  157. }
  158. }
  159. `;
  160. export const DELETE_ADDRESS = gql`
  161. mutation DeleteAddressShop($id: ID!) {
  162. deleteCustomerAddress(id: $id)
  163. }
  164. `;
  165. export const UPDATE_CUSTOMER = gql`
  166. mutation UpdateCustomer($input: UpdateCustomerInput!) {
  167. updateCustomer(input: $input) {
  168. id
  169. firstName
  170. lastName
  171. }
  172. }
  173. `;
  174. export const UPDATE_PASSWORD = gql`
  175. mutation UpdatePassword($old: String!, $new: String!) {
  176. updateCustomerPassword(currentPassword: $old, newPassword: $new)
  177. }
  178. `;
  179. export const GET_ACTIVE_ORDER = gql`
  180. query GetActiveOrder {
  181. activeOrder {
  182. ...TestOrderFragment
  183. }
  184. }
  185. ${TEST_ORDER_FRAGMENT}
  186. `;
  187. export const ADJUST_ITEM_QUANTITY = gql`
  188. mutation AdjustItemQuantity($orderLineId: ID!, $quantity: Int!) {
  189. adjustOrderLine(orderLineId: $orderLineId, quantity: $quantity) {
  190. ...TestOrderFragment
  191. }
  192. }
  193. ${TEST_ORDER_FRAGMENT}
  194. `;
  195. export const REMOVE_ITEM_FROM_ORDER = gql`
  196. mutation RemoveItemFromOrder($orderLineId: ID!) {
  197. removeOrderLine(orderLineId: $orderLineId) {
  198. ...TestOrderFragment
  199. }
  200. }
  201. ${TEST_ORDER_FRAGMENT}
  202. `;
  203. export const GET_ELIGIBLE_SHIPPING_METHODS = gql`
  204. query GetShippingMethods {
  205. eligibleShippingMethods {
  206. id
  207. price
  208. description
  209. }
  210. }
  211. `;
  212. export const SET_SHIPPING_METHOD = gql`
  213. mutation SetShippingMethod($id: ID!) {
  214. setOrderShippingMethod(shippingMethodId: $id) {
  215. shipping
  216. shippingMethod {
  217. id
  218. code
  219. description
  220. }
  221. }
  222. }
  223. `;
  224. export const SET_CUSTOMER = gql`
  225. mutation SetCustomerForOrder($input: CreateCustomerInput!) {
  226. setCustomerForOrder(input: $input) {
  227. id
  228. customer {
  229. id
  230. emailAddress
  231. firstName
  232. lastName
  233. }
  234. }
  235. }
  236. `;
  237. export const GET_ORDER_BY_CODE = gql`
  238. query GetOrderByCode($code: String!) {
  239. orderByCode(code: $code) {
  240. ...TestOrderFragment
  241. }
  242. }
  243. ${TEST_ORDER_FRAGMENT}
  244. `;
  245. export const GET_ORDER_PROMOTIONS_BY_CODE = gql`
  246. query GetOrderPromotionsByCode($code: String!) {
  247. orderByCode(code: $code) {
  248. ...TestOrderFragment
  249. promotions {
  250. id
  251. name
  252. }
  253. }
  254. }
  255. ${TEST_ORDER_FRAGMENT}
  256. `;
  257. export const GET_AVAILABLE_COUNTRIES = gql`
  258. query GetAvailableCountries {
  259. availableCountries {
  260. id
  261. code
  262. }
  263. }
  264. `;
  265. export const TRANSITION_TO_STATE = gql`
  266. mutation TransitionToState($state: String!) {
  267. transitionOrderToState(state: $state) {
  268. id
  269. state
  270. }
  271. }
  272. `;
  273. export const SET_SHIPPING_ADDRESS = gql`
  274. mutation SetShippingAddress($input: CreateAddressInput!) {
  275. setOrderShippingAddress(input: $input) {
  276. shippingAddress {
  277. fullName
  278. company
  279. streetLine1
  280. streetLine2
  281. city
  282. province
  283. postalCode
  284. country
  285. phoneNumber
  286. }
  287. }
  288. }
  289. `;
  290. export const ADD_PAYMENT = gql`
  291. mutation AddPaymentToOrder($input: PaymentInput!) {
  292. addPaymentToOrder(input: $input) {
  293. ...TestOrderFragment
  294. payments {
  295. id
  296. transactionId
  297. method
  298. amount
  299. state
  300. metadata
  301. }
  302. }
  303. }
  304. ${TEST_ORDER_FRAGMENT}
  305. `;
  306. export const GET_ACTIVE_ORDER_PAYMENTS = gql`
  307. query GetActiveOrderPayments {
  308. activeOrder {
  309. id
  310. payments {
  311. id
  312. transactionId
  313. method
  314. amount
  315. state
  316. errorMessage
  317. metadata
  318. }
  319. }
  320. }
  321. `;
  322. export const GET_NEXT_STATES = gql`
  323. query GetNextOrderStates {
  324. nextOrderStates
  325. }
  326. `;
  327. export const GET_ACTIVE_ORDER_ADDRESSES = gql`
  328. query GetCustomerAddresses {
  329. activeOrder {
  330. customer {
  331. addresses {
  332. id
  333. streetLine1
  334. }
  335. }
  336. }
  337. }
  338. `;
  339. export const GET_ACTIVE_ORDER_ORDERS = gql`
  340. query GetCustomerOrders {
  341. activeOrder {
  342. customer {
  343. orders {
  344. items {
  345. id
  346. }
  347. }
  348. }
  349. }
  350. }
  351. `;
  352. export const APPLY_COUPON_CODE = gql`
  353. mutation ApplyCouponCode($couponCode: String!) {
  354. applyCouponCode(couponCode: $couponCode) {
  355. ...TestOrderFragment
  356. }
  357. }
  358. ${TEST_ORDER_FRAGMENT}
  359. `;
  360. export const REMOVE_COUPON_CODE = gql`
  361. mutation RemoveCouponCode($couponCode: String!) {
  362. removeCouponCode(couponCode: $couponCode) {
  363. ...TestOrderFragment
  364. }
  365. }
  366. ${TEST_ORDER_FRAGMENT}
  367. `;