shop-definitions.ts 8.4 KB

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