shared-definitions.ts 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. user {
  116. id
  117. verified
  118. }
  119. }
  120. totalItems
  121. }
  122. }
  123. `;
  124. export const GET_ASSET_LIST = gql`
  125. query GetAssetList($options: AssetListOptions) {
  126. assets(options: $options) {
  127. items {
  128. ...Asset
  129. }
  130. totalItems
  131. }
  132. }
  133. ${ASSET_FRAGMENT}
  134. `;
  135. export const CREATE_ROLE = gql`
  136. mutation CreateRole($input: CreateRoleInput!) {
  137. createRole(input: $input) {
  138. ...Role
  139. }
  140. }
  141. ${ROLE_FRAGMENT}
  142. `;
  143. export const CREATE_COLLECTION = gql`
  144. mutation CreateCollection($input: CreateCollectionInput!) {
  145. createCollection(input: $input) {
  146. ...Collection
  147. }
  148. }
  149. ${COLLECTION_FRAGMENT}
  150. `;
  151. export const UPDATE_COLLECTION = gql`
  152. mutation UpdateCollection($input: UpdateCollectionInput!) {
  153. updateCollection(input: $input) {
  154. ...Collection
  155. }
  156. }
  157. ${COLLECTION_FRAGMENT}
  158. `;
  159. export const GET_CUSTOMER = gql`
  160. query GetCustomer($id: ID!, $orderListOptions: OrderListOptions) {
  161. customer(id: $id) {
  162. ...Customer
  163. orders(options: $orderListOptions) {
  164. items {
  165. id
  166. code
  167. state
  168. total
  169. currencyCode
  170. updatedAt
  171. }
  172. totalItems
  173. }
  174. }
  175. }
  176. ${CUSTOMER_FRAGMENT}
  177. `;
  178. export const ATTEMPT_LOGIN = gql`
  179. mutation AttemptLogin($username: String!, $password: String!, $rememberMe: Boolean) {
  180. login(username: $username, password: $password, rememberMe: $rememberMe) {
  181. user {
  182. ...CurrentUser
  183. }
  184. }
  185. }
  186. ${CURRENT_USER_FRAGMENT}
  187. `;
  188. export const GET_COUNTRY_LIST = gql`
  189. query GetCountryList($options: CountryListOptions) {
  190. countries(options: $options) {
  191. items {
  192. id
  193. code
  194. name
  195. enabled
  196. }
  197. totalItems
  198. }
  199. }
  200. `;
  201. export const UPDATE_COUNTRY = gql`
  202. mutation UpdateCountry($input: UpdateCountryInput!) {
  203. updateCountry(input: $input) {
  204. ...Country
  205. }
  206. }
  207. ${COUNTRY_FRAGMENT}
  208. `;
  209. export const GET_FACET_LIST = gql`
  210. query GetFacetList($options: FacetListOptions) {
  211. facets(options: $options) {
  212. items {
  213. ...FacetWithValues
  214. }
  215. totalItems
  216. }
  217. }
  218. ${FACET_WITH_VALUES_FRAGMENT}
  219. `;
  220. export const DELETE_PRODUCT = gql`
  221. mutation DeleteProduct($id: ID!) {
  222. deleteProduct(id: $id) {
  223. result
  224. }
  225. }
  226. `;
  227. export const GET_PRODUCT_SIMPLE = gql`
  228. query GetProductSimple($id: ID, $slug: String) {
  229. product(slug: $slug, id: $id) {
  230. id
  231. slug
  232. }
  233. }
  234. `;
  235. export const GET_STOCK_MOVEMENT = gql`
  236. query GetStockMovement($id: ID!) {
  237. product(id: $id) {
  238. id
  239. variants {
  240. ...VariantWithStock
  241. }
  242. }
  243. }
  244. ${VARIANT_WITH_STOCK_FRAGMENT}
  245. `;
  246. export const GET_RUNNING_JOBS = gql`
  247. query GetRunningJobs($options: JobListOptions) {
  248. jobs(options: $options) {
  249. items {
  250. id
  251. queueName
  252. state
  253. isSettled
  254. duration
  255. }
  256. totalItems
  257. }
  258. }
  259. `;
  260. export const CREATE_PROMOTION = gql`
  261. mutation CreatePromotion($input: CreatePromotionInput!) {
  262. createPromotion(input: $input) {
  263. ...Promotion
  264. }
  265. }
  266. ${PROMOTION_FRAGMENT}
  267. `;
  268. export const ME = gql`
  269. query Me {
  270. me {
  271. ...CurrentUser
  272. }
  273. }
  274. ${CURRENT_USER_FRAGMENT}
  275. `;
  276. export const CREATE_CHANNEL = gql`
  277. mutation CreateChannel($input: CreateChannelInput!) {
  278. createChannel(input: $input) {
  279. id
  280. code
  281. token
  282. currencyCode
  283. defaultLanguageCode
  284. defaultShippingZone {
  285. id
  286. }
  287. defaultTaxZone {
  288. id
  289. }
  290. pricesIncludeTax
  291. }
  292. }
  293. `;
  294. export const DELETE_PRODUCT_VARIANT = gql`
  295. mutation DeleteProductVariant($id: ID!) {
  296. deleteProductVariant(id: $id) {
  297. result
  298. message
  299. }
  300. }
  301. `;
  302. export const ASSIGN_PRODUCT_TO_CHANNEL = gql`
  303. mutation AssignProductsToChannel($input: AssignProductsToChannelInput!) {
  304. assignProductsToChannel(input: $input) {
  305. ...ProductWithVariants
  306. }
  307. }
  308. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  309. `;
  310. export const REMOVE_PRODUCT_FROM_CHANNEL = gql`
  311. mutation RemoveProductsFromChannel($input: RemoveProductsFromChannelInput!) {
  312. removeProductsFromChannel(input: $input) {
  313. ...ProductWithVariants
  314. }
  315. }
  316. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  317. `;
  318. export const UPDATE_ASSET = gql`
  319. mutation UpdateAsset($input: UpdateAssetInput!) {
  320. updateAsset(input: $input) {
  321. ...Asset
  322. focalPoint {
  323. x
  324. y
  325. }
  326. }
  327. }
  328. ${ASSET_FRAGMENT}
  329. `;
  330. export const DELETE_ASSET = gql`
  331. mutation DeleteAsset($id: ID!, $force: Boolean) {
  332. deleteAsset(id: $id, force: $force) {
  333. result
  334. message
  335. }
  336. }
  337. `;