shared-definitions.ts 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. import gql from 'graphql-tag';
  2. import {
  3. ADMINISTRATOR_FRAGMENT,
  4. ASSET_FRAGMENT,
  5. COLLECTION_FRAGMENT,
  6. COUNTRY_FRAGMENT,
  7. CURRENT_USER_FRAGMENT,
  8. CUSTOMER_FRAGMENT,
  9. FACET_WITH_VALUES_FRAGMENT,
  10. ORDER_WITH_LINES_FRAGMENT,
  11. PRODUCT_VARIANT_FRAGMENT,
  12. PRODUCT_WITH_VARIANTS_FRAGMENT,
  13. PROMOTION_FRAGMENT,
  14. ROLE_FRAGMENT,
  15. TAX_RATE_FRAGMENT,
  16. VARIANT_WITH_STOCK_FRAGMENT,
  17. } from './fragments';
  18. export const CREATE_ADMINISTRATOR = gql`
  19. mutation CreateAdministrator($input: CreateAdministratorInput!) {
  20. createAdministrator(input: $input) {
  21. ...Administrator
  22. }
  23. }
  24. ${ADMINISTRATOR_FRAGMENT}
  25. `;
  26. export const UPDATE_PRODUCT = gql`
  27. mutation UpdateProduct($input: UpdateProductInput!) {
  28. updateProduct(input: $input) {
  29. ...ProductWithVariants
  30. }
  31. }
  32. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  33. `;
  34. export const CREATE_PRODUCT = gql`
  35. mutation CreateProduct($input: CreateProductInput!) {
  36. createProduct(input: $input) {
  37. ...ProductWithVariants
  38. }
  39. }
  40. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  41. `;
  42. export const GET_PRODUCT_WITH_VARIANTS = gql`
  43. query GetProductWithVariants($id: ID, $slug: String) {
  44. product(slug: $slug, id: $id) {
  45. ...ProductWithVariants
  46. }
  47. }
  48. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  49. `;
  50. export const GET_PRODUCT_LIST = gql`
  51. query GetProductList($options: ProductListOptions) {
  52. products(options: $options) {
  53. items {
  54. id
  55. languageCode
  56. name
  57. slug
  58. featuredAsset {
  59. id
  60. preview
  61. }
  62. }
  63. totalItems
  64. }
  65. }
  66. `;
  67. export const CREATE_PRODUCT_VARIANTS = gql`
  68. mutation CreateProductVariants($input: [CreateProductVariantInput!]!) {
  69. createProductVariants(input: $input) {
  70. ...ProductVariant
  71. }
  72. }
  73. ${PRODUCT_VARIANT_FRAGMENT}
  74. `;
  75. export const UPDATE_PRODUCT_VARIANTS = gql`
  76. mutation UpdateProductVariants($input: [UpdateProductVariantInput!]!) {
  77. updateProductVariants(input: $input) {
  78. ...ProductVariant
  79. }
  80. }
  81. ${PRODUCT_VARIANT_FRAGMENT}
  82. `;
  83. export const UPDATE_TAX_RATE = gql`
  84. mutation UpdateTaxRate($input: UpdateTaxRateInput!) {
  85. updateTaxRate(input: $input) {
  86. ...TaxRate
  87. }
  88. }
  89. ${TAX_RATE_FRAGMENT}
  90. `;
  91. export const CREATE_FACET = gql`
  92. mutation CreateFacet($input: CreateFacetInput!) {
  93. createFacet(input: $input) {
  94. ...FacetWithValues
  95. }
  96. }
  97. ${FACET_WITH_VALUES_FRAGMENT}
  98. `;
  99. export const UPDATE_FACET = gql`
  100. mutation UpdateFacet($input: UpdateFacetInput!) {
  101. updateFacet(input: $input) {
  102. ...FacetWithValues
  103. }
  104. }
  105. ${FACET_WITH_VALUES_FRAGMENT}
  106. `;
  107. export const GET_CUSTOMER_LIST = gql`
  108. query GetCustomerList($options: CustomerListOptions) {
  109. customers(options: $options) {
  110. items {
  111. id
  112. title
  113. firstName
  114. lastName
  115. emailAddress
  116. phoneNumber
  117. user {
  118. id
  119. verified
  120. }
  121. }
  122. totalItems
  123. }
  124. }
  125. `;
  126. export const GET_ASSET_LIST = gql`
  127. query GetAssetList($options: AssetListOptions) {
  128. assets(options: $options) {
  129. items {
  130. ...Asset
  131. }
  132. totalItems
  133. }
  134. }
  135. ${ASSET_FRAGMENT}
  136. `;
  137. export const CREATE_ROLE = gql`
  138. mutation CreateRole($input: CreateRoleInput!) {
  139. createRole(input: $input) {
  140. ...Role
  141. }
  142. }
  143. ${ROLE_FRAGMENT}
  144. `;
  145. export const CREATE_COLLECTION = gql`
  146. mutation CreateCollection($input: CreateCollectionInput!) {
  147. createCollection(input: $input) {
  148. ...Collection
  149. }
  150. }
  151. ${COLLECTION_FRAGMENT}
  152. `;
  153. export const UPDATE_COLLECTION = gql`
  154. mutation UpdateCollection($input: UpdateCollectionInput!) {
  155. updateCollection(input: $input) {
  156. ...Collection
  157. }
  158. }
  159. ${COLLECTION_FRAGMENT}
  160. `;
  161. export const GET_CUSTOMER = gql`
  162. query GetCustomer($id: ID!, $orderListOptions: OrderListOptions) {
  163. customer(id: $id) {
  164. ...Customer
  165. orders(options: $orderListOptions) {
  166. items {
  167. id
  168. code
  169. state
  170. total
  171. currencyCode
  172. updatedAt
  173. }
  174. totalItems
  175. }
  176. }
  177. }
  178. ${CUSTOMER_FRAGMENT}
  179. `;
  180. export const ATTEMPT_LOGIN = gql`
  181. mutation AttemptLogin($username: String!, $password: String!, $rememberMe: Boolean) {
  182. login(username: $username, password: $password, rememberMe: $rememberMe) {
  183. user {
  184. ...CurrentUser
  185. }
  186. }
  187. }
  188. ${CURRENT_USER_FRAGMENT}
  189. `;
  190. export const GET_COUNTRY_LIST = gql`
  191. query GetCountryList($options: CountryListOptions) {
  192. countries(options: $options) {
  193. items {
  194. id
  195. code
  196. name
  197. enabled
  198. }
  199. totalItems
  200. }
  201. }
  202. `;
  203. export const UPDATE_COUNTRY = gql`
  204. mutation UpdateCountry($input: UpdateCountryInput!) {
  205. updateCountry(input: $input) {
  206. ...Country
  207. }
  208. }
  209. ${COUNTRY_FRAGMENT}
  210. `;
  211. export const GET_FACET_LIST = gql`
  212. query GetFacetList($options: FacetListOptions) {
  213. facets(options: $options) {
  214. items {
  215. ...FacetWithValues
  216. }
  217. totalItems
  218. }
  219. }
  220. ${FACET_WITH_VALUES_FRAGMENT}
  221. `;
  222. export const DELETE_PRODUCT = gql`
  223. mutation DeleteProduct($id: ID!) {
  224. deleteProduct(id: $id) {
  225. result
  226. }
  227. }
  228. `;
  229. export const GET_PRODUCT_SIMPLE = gql`
  230. query GetProductSimple($id: ID, $slug: String) {
  231. product(slug: $slug, id: $id) {
  232. id
  233. slug
  234. }
  235. }
  236. `;
  237. export const GET_STOCK_MOVEMENT = gql`
  238. query GetStockMovement($id: ID!) {
  239. product(id: $id) {
  240. id
  241. variants {
  242. ...VariantWithStock
  243. }
  244. }
  245. }
  246. ${VARIANT_WITH_STOCK_FRAGMENT}
  247. `;
  248. export const GET_RUNNING_JOBS = gql`
  249. query GetRunningJobs($options: JobListOptions) {
  250. jobs(options: $options) {
  251. items {
  252. id
  253. queueName
  254. state
  255. isSettled
  256. duration
  257. }
  258. totalItems
  259. }
  260. }
  261. `;
  262. export const CREATE_PROMOTION = gql`
  263. mutation CreatePromotion($input: CreatePromotionInput!) {
  264. createPromotion(input: $input) {
  265. ...Promotion
  266. }
  267. }
  268. ${PROMOTION_FRAGMENT}
  269. `;
  270. export const ME = gql`
  271. query Me {
  272. me {
  273. ...CurrentUser
  274. }
  275. }
  276. ${CURRENT_USER_FRAGMENT}
  277. `;
  278. export const CREATE_CHANNEL = gql`
  279. mutation CreateChannel($input: CreateChannelInput!) {
  280. createChannel(input: $input) {
  281. id
  282. code
  283. token
  284. currencyCode
  285. defaultLanguageCode
  286. defaultShippingZone {
  287. id
  288. }
  289. defaultTaxZone {
  290. id
  291. }
  292. pricesIncludeTax
  293. }
  294. }
  295. `;
  296. export const DELETE_PRODUCT_VARIANT = gql`
  297. mutation DeleteProductVariant($id: ID!) {
  298. deleteProductVariant(id: $id) {
  299. result
  300. message
  301. }
  302. }
  303. `;
  304. export const ASSIGN_PRODUCT_TO_CHANNEL = gql`
  305. mutation AssignProductsToChannel($input: AssignProductsToChannelInput!) {
  306. assignProductsToChannel(input: $input) {
  307. ...ProductWithVariants
  308. }
  309. }
  310. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  311. `;
  312. export const REMOVE_PRODUCT_FROM_CHANNEL = gql`
  313. mutation RemoveProductsFromChannel($input: RemoveProductsFromChannelInput!) {
  314. removeProductsFromChannel(input: $input) {
  315. ...ProductWithVariants
  316. }
  317. }
  318. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  319. `;
  320. export const UPDATE_ASSET = gql`
  321. mutation UpdateAsset($input: UpdateAssetInput!) {
  322. updateAsset(input: $input) {
  323. ...Asset
  324. focalPoint {
  325. x
  326. y
  327. }
  328. }
  329. }
  330. ${ASSET_FRAGMENT}
  331. `;
  332. export const DELETE_ASSET = gql`
  333. mutation DeleteAsset($id: ID!, $force: Boolean) {
  334. deleteAsset(id: $id, force: $force) {
  335. result
  336. message
  337. }
  338. }
  339. `;
  340. export const UPDATE_CHANNEL = gql`
  341. mutation UpdateChannel($input: UpdateChannelInput!) {
  342. updateChannel(input: $input) {
  343. id
  344. code
  345. defaultLanguageCode
  346. currencyCode
  347. }
  348. }
  349. `;
  350. export const GET_CUSTOMER_HISTORY = gql`
  351. query GetCustomerHistory($id: ID!, $options: HistoryEntryListOptions) {
  352. customer(id: $id) {
  353. id
  354. history(options: $options) {
  355. totalItems
  356. items {
  357. id
  358. administrator {
  359. id
  360. }
  361. type
  362. data
  363. }
  364. }
  365. }
  366. }
  367. `;
  368. export const GET_ORDER = gql`
  369. query GetOrder($id: ID!) {
  370. order(id: $id) {
  371. ...OrderWithLines
  372. }
  373. }
  374. ${ORDER_WITH_LINES_FRAGMENT}
  375. `;
  376. export const CUSTOMER_GROUP_FRAGMENT = gql`
  377. fragment CustomerGroup on CustomerGroup {
  378. id
  379. name
  380. customers {
  381. items {
  382. id
  383. }
  384. totalItems
  385. }
  386. }
  387. `;
  388. export const CREATE_CUSTOMER_GROUP = gql`
  389. mutation CreateCustomerGroup($input: CreateCustomerGroupInput!) {
  390. createCustomerGroup(input: $input) {
  391. ...CustomerGroup
  392. }
  393. }
  394. ${CUSTOMER_GROUP_FRAGMENT}
  395. `;
  396. export const REMOVE_CUSTOMERS_FROM_GROUP = gql`
  397. mutation RemoveCustomersFromGroup($groupId: ID!, $customerIds: [ID!]!) {
  398. removeCustomersFromGroup(customerGroupId: $groupId, customerIds: $customerIds) {
  399. ...CustomerGroup
  400. }
  401. }
  402. ${CUSTOMER_GROUP_FRAGMENT}
  403. `;