shop-definitions.ts 7.2 KB

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