shared-definitions.ts 9.1 KB

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