diff --git a/framework/saleor/auth/use-login.tsx b/framework/saleor/auth/use-login.tsx index 32c2d6b22..a8c240106 100644 --- a/framework/saleor/auth/use-login.tsx +++ b/framework/saleor/auth/use-login.tsx @@ -1,8 +1,9 @@ import { useCallback } from 'react' + import type { MutationHook } from '@commerce/utils/types' import { CommerceError } from '@commerce/utils/errors' import useCustomer from '../customer/use-customer' -import tokenCreateMutation from '../utils/mutations/customer-access-token-create' +import * as mutation from '../utils/mutations' import { Mutation, MutationTokenCreateArgs, @@ -14,7 +15,7 @@ export default useLogin as UseLogin export const handler: MutationHook = { fetchOptions: { - query: tokenCreateMutation, + query: mutation.sessionCreate, }, async fetcher({ input: { email, password }, options, fetch }) { if (!(email && password)) { diff --git a/framework/saleor/auth/use-logout.tsx b/framework/saleor/auth/use-logout.tsx index 97b40ec96..79f6f9623 100644 --- a/framework/saleor/auth/use-logout.tsx +++ b/framework/saleor/auth/use-logout.tsx @@ -2,14 +2,14 @@ import { useCallback } from 'react' import type { MutationHook } from '@commerce/utils/types' import useLogout, { UseLogout } from '@commerce/auth/use-logout' import useCustomer from '../customer/use-customer' -import customerAccessTokenDeleteMutation from '../utils/mutations/customer-access-token-delete' +import * as mutation from '../utils/mutations' import { setToken } from '../utils/customer-token' export default useLogout as UseLogout export const handler: MutationHook = { fetchOptions: { - query: customerAccessTokenDeleteMutation, + query: mutation.sessionDestroy, }, async fetcher({ options, fetch }) { await fetch({ diff --git a/framework/saleor/auth/use-signup.tsx b/framework/saleor/auth/use-signup.tsx index 43695e7b8..cff7c0412 100644 --- a/framework/saleor/auth/use-signup.tsx +++ b/framework/saleor/auth/use-signup.tsx @@ -9,7 +9,7 @@ import { MutationAccountRegisterArgs } from '../schema' -import { customerCreateMutation } from '../utils/mutations' +import * as mutation from '../utils/mutations' import { handleAutomaticLogin, throwUserErrors } from '../utils' export default useSignup as UseSignup @@ -21,7 +21,7 @@ export const handler: MutationHook< AccountRegisterInput > = { fetchOptions: { - query: customerCreateMutation, + query: mutation.accountRegister }, async fetcher({ input: { email, password }, diff --git a/framework/saleor/cart/use-add-item.tsx b/framework/saleor/cart/use-add-item.tsx index f5b59bf45..7f5653fe5 100644 --- a/framework/saleor/cart/use-add-item.tsx +++ b/framework/saleor/cart/use-add-item.tsx @@ -3,20 +3,21 @@ import type { MutationHook } from '@commerce/utils/types' import { CommerceError } from '@commerce/utils/errors' import useAddItem, { UseAddItem } from '@commerce/cart/use-add-item' import useCart from './use-cart' + +import * as mutation from '../utils/mutations' + import { - checkoutLineItemAddMutation, getCheckoutId, checkoutToCart, } from '../utils' + import { Cart, CartItemBody } from '../types' import { Mutation, MutationCheckoutLinesAddArgs } from '../schema' export default useAddItem as UseAddItem export const handler: MutationHook = { - fetchOptions: { - query: checkoutLineItemAddMutation, - }, + fetchOptions: { query: mutation.checkoutLineAdd }, async fetcher({ input: item, options, fetch }) { if ( item.quantity && diff --git a/framework/saleor/cart/use-cart.tsx b/framework/saleor/cart/use-cart.tsx index 1abbce011..aca7329ba 100644 --- a/framework/saleor/cart/use-cart.tsx +++ b/framework/saleor/cart/use-cart.tsx @@ -7,7 +7,7 @@ import useCommerceCart, { import { Cart } from '../types' import { SWRHook } from '@commerce/utils/types' import { checkoutCreate, checkoutToCart, getCheckoutId } from '../utils' -import getCheckoutQuery from '../utils/queries/get-checkout-query' +import { getCheckoutQuery } from '../utils/queries' export default useCommerceCart as UseCart diff --git a/framework/saleor/cart/use-remove-item.tsx b/framework/saleor/cart/use-remove-item.tsx index af9cc87a5..e9f8d2b5c 100644 --- a/framework/saleor/cart/use-remove-item.tsx +++ b/framework/saleor/cart/use-remove-item.tsx @@ -10,8 +10,8 @@ import useRemoveItem, { UseRemoveItem, } from '@commerce/cart/use-remove-item' import useCart from './use-cart' +import * as mutation from '../utils/mutations' import { - checkoutLineItemRemoveMutation, getCheckoutId, checkoutToCart, } from '../utils' @@ -29,9 +29,7 @@ export type RemoveItemInput = T extends LineItem export default useRemoveItem as UseRemoveItem export const handler = { - fetchOptions: { - query: checkoutLineItemRemoveMutation, - }, + fetchOptions: { query: mutation.checkoutLineDelete }, async fetcher({ input: { itemId }, options, diff --git a/framework/saleor/cart/use-update-item.tsx b/framework/saleor/cart/use-update-item.tsx index 0361bdd97..d81b407ba 100644 --- a/framework/saleor/cart/use-update-item.tsx +++ b/framework/saleor/cart/use-update-item.tsx @@ -14,9 +14,11 @@ import useCart from './use-cart' import { handler as removeItemHandler } from './use-remove-item' import type { Cart, LineItem, UpdateCartItemBody } from '../types' import { checkoutToCart } from '../utils' -import { getCheckoutId, checkoutLineItemUpdateMutation } from '../utils' +import { getCheckoutId } from '../utils' import { Mutation, MutationCheckoutLinesUpdateArgs } from '../schema' +import * as mutation from '../utils/mutations' + export type UpdateItemInput = T extends LineItem ? Partial> : UpdateItemInputBase @@ -24,9 +26,7 @@ export type UpdateItemInput = T extends LineItem export default useUpdateItem as UseUpdateItem export const handler = { - fetchOptions: { - query: checkoutLineItemUpdateMutation, - }, + fetchOptions: { query: mutation.checkoutLineUpdate }, async fetcher({ input: { itemId, item }, options, diff --git a/framework/saleor/common/get-page.ts b/framework/saleor/common/get-page.ts index bbe74cd85..b036a54f5 100644 --- a/framework/saleor/common/get-page.ts +++ b/framework/saleor/common/get-page.ts @@ -1,5 +1,5 @@ import { getConfig, SaleorConfig } from '../api' -import getPageQuery from '../utils/queries/get-page-query' +import { getPageQuery } from '../utils/queries' import { Page } from './get-all-pages' type Variables = { diff --git a/framework/saleor/customer/get-customer-id.ts b/framework/saleor/customer/get-customer-id.ts index c86de180b..67ff40976 100644 --- a/framework/saleor/customer/get-customer-id.ts +++ b/framework/saleor/customer/get-customer-id.ts @@ -1,5 +1,5 @@ import { getConfig, SaleorConfig } from '../api' -import getCustomerIdQuery from '../utils/queries/get-customer-id-query' +import { getCustomerIdQuery } from '../utils/queries' import Cookies from 'js-cookie' async function getCustomerId({ diff --git a/framework/saleor/product/get-all-collections.ts b/framework/saleor/product/get-all-collections.ts index 22e242495..ff683f4bc 100644 --- a/framework/saleor/product/get-all-collections.ts +++ b/framework/saleor/product/get-all-collections.ts @@ -1,6 +1,6 @@ import { CollectionCountableEdge } from '../schema' import { getConfig, SaleorConfig } from '../api' -import getAllCollectionsQuery from '../utils/queries/get-all-collections-query' +import { getSiteCollectionsQuery } from '../utils/queries' const getAllCollections = async (options?: { variables?: any @@ -10,7 +10,7 @@ const getAllCollections = async (options?: { let { config, variables = { first: 100 } } = options ?? {} config = getConfig(config) - const { data } = await config.fetch(getAllCollectionsQuery, { variables }) + const { data } = await config.fetch(getSiteCollectionsQuery, { variables }) const edges = data.collections?.edges ?? [] const categories = edges.map( diff --git a/framework/saleor/product/get-all-product-paths.ts b/framework/saleor/product/get-all-product-paths.ts index 65d72cc6f..e2c289561 100644 --- a/framework/saleor/product/get-all-product-paths.ts +++ b/framework/saleor/product/get-all-product-paths.ts @@ -1,7 +1,7 @@ import { getConfig, SaleorConfig } from '../api' import fetchAllProducts from '../api/utils/fetch-all-products' import { ProductCountableEdge } from '../schema' -import getAllProductsPathsQuery from '../utils/queries/get-all-products-paths-query' +import { getAllProductsPathsQuery } from '../utils/queries' type ProductPath = { path: string diff --git a/framework/saleor/utils/checkout-create.ts b/framework/saleor/utils/checkout-create.ts index 1c2aec6a7..3e634bc9c 100644 --- a/framework/saleor/utils/checkout-create.ts +++ b/framework/saleor/utils/checkout-create.ts @@ -1,16 +1,13 @@ import Cookies from 'js-cookie' -import checkoutCreateMutation from './mutations/checkout-create' +import * as mutation from './mutations' import { CheckoutCreate } from '../schema' import { CHECKOUT_ID_COOKIE } from '@framework/const' export const checkoutCreate = async ( fetch: any ): Promise => { - const data = await fetch({ - query: checkoutCreateMutation, - }) - + const data = await fetch({ query: mutation.checkoutCreate }) const checkout = data.checkoutCreate?.checkout const checkoutId = checkout?.id const checkoutToken = checkout?.token diff --git a/framework/saleor/utils/get-vendors.ts b/framework/saleor/utils/get-vendors.ts index 4814646ec..48ba89404 100644 --- a/framework/saleor/utils/get-vendors.ts +++ b/framework/saleor/utils/get-vendors.ts @@ -1,6 +1,6 @@ import { SaleorConfig } from '../api' import fetchAllProducts from '../api/utils/fetch-all-products' -import getAllProductVendors from './queries/get-all-product-vendors-query' +import { getAllProductVendors } from './queries' export type Brand = { entityId: string diff --git a/framework/saleor/utils/handle-login.ts b/framework/saleor/utils/handle-login.ts index 1b4afc9af..39cc804c2 100644 --- a/framework/saleor/utils/handle-login.ts +++ b/framework/saleor/utils/handle-login.ts @@ -1,7 +1,7 @@ import { FetcherOptions } from '@commerce/utils/types' import { CreateToken, Mutation, MutationTokenCreateArgs } from '../schema' import { setToken, setCSRFToken } from './customer-token' -import { customerAccessTokenCreateMutation } from './mutations' +import * as mutation from './mutations' import throwUserErrors from './throw-user-errors' const handleLogin = (data: CreateToken) => { @@ -26,7 +26,7 @@ export const handleAutomaticLogin = async ( Mutation, MutationTokenCreateArgs >({ - query: customerAccessTokenCreateMutation, + query: mutation.sessionCreate, variables: { ...input }, }) handleLogin(tokenCreate!) diff --git a/framework/saleor/utils/mutations/associate-customer-with-checkout.ts b/framework/saleor/utils/mutations/associate-customer-with-checkout.ts index 61179ac59..66346a4d7 100644 --- a/framework/saleor/utils/mutations/associate-customer-with-checkout.ts +++ b/framework/saleor/utils/mutations/associate-customer-with-checkout.ts @@ -1,18 +1,12 @@ -const associateCustomerWithCheckoutMutation = /* GraphQl */ ` - mutation associateCustomerWithCheckout($checkoutId: ID!, $customerAccessToken: String!) { - checkoutCustomerAssociateV2(checkoutId: $checkoutId, customerAccessToken: $customerAccessToken) { - checkout { - id - } - checkoutUserErrors { - code - field +export const checkoutCustomerAttach = /* GraphQl */ ` + mutation associateCustomerWithCheckout($checkoutId: ID!) { + checkoutCustomerAttach(checkoutId: $checkoutId) { + errors { message } - customer { + checkout { id } } } ` -export default associateCustomerWithCheckoutMutation diff --git a/framework/saleor/utils/mutations/checkout-create.ts b/framework/saleor/utils/mutations/checkout-create.ts index cf971d654..ddc4bbb21 100644 --- a/framework/saleor/utils/mutations/checkout-create.ts +++ b/framework/saleor/utils/mutations/checkout-create.ts @@ -1,6 +1,6 @@ import { checkoutDetailsFragment } from '../queries/get-checkout-query' -const checkoutCreateMutation = /* GraphQL */ ` +export const checkoutCreate = /* GraphQL */ ` mutation createCheckout { checkoutCreate(input: { email: "customer@example.com", @@ -18,4 +18,3 @@ const checkoutCreateMutation = /* GraphQL */ ` } } ` -export default checkoutCreateMutation diff --git a/framework/saleor/utils/mutations/checkout-line-item-add.ts b/framework/saleor/utils/mutations/checkout-line-item-add.ts index 56472dc4d..9291495c8 100644 --- a/framework/saleor/utils/mutations/checkout-line-item-add.ts +++ b/framework/saleor/utils/mutations/checkout-line-item-add.ts @@ -1,6 +1,6 @@ import { checkoutDetailsFragment } from '../queries/get-checkout-query' -const checkoutLineItemAddMutation = /* GraphQL */ ` +export const checkoutLineAdd = /* GraphQL */ ` mutation checkoutLineItemAdd($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) { checkoutLinesAdd(checkoutId: $checkoutId, lines: $lineItems) { errors { @@ -14,4 +14,3 @@ const checkoutLineItemAddMutation = /* GraphQL */ ` } } ` -export default checkoutLineItemAddMutation diff --git a/framework/saleor/utils/mutations/checkout-line-item-remove.ts b/framework/saleor/utils/mutations/checkout-line-item-remove.ts index 1eda0e86c..8f55cd2a0 100644 --- a/framework/saleor/utils/mutations/checkout-line-item-remove.ts +++ b/framework/saleor/utils/mutations/checkout-line-item-remove.ts @@ -1,6 +1,6 @@ import { checkoutDetailsFragment } from '../queries/get-checkout-query' -const checkoutLineItemRemoveMutation = /* GraphQL */ ` +export const checkoutLineDelete = /* GraphQL */ ` mutation checkoutLineItemRemove($checkoutId: ID!, $lineId: ID!) { checkoutLineDelete( checkoutId: $checkoutId @@ -17,4 +17,3 @@ const checkoutLineItemRemoveMutation = /* GraphQL */ ` } } ` -export default checkoutLineItemRemoveMutation diff --git a/framework/saleor/utils/mutations/checkout-line-item-update.ts b/framework/saleor/utils/mutations/checkout-line-item-update.ts index 958921d15..c23f6c65c 100644 --- a/framework/saleor/utils/mutations/checkout-line-item-update.ts +++ b/framework/saleor/utils/mutations/checkout-line-item-update.ts @@ -1,6 +1,6 @@ import { checkoutDetailsFragment } from '../queries/get-checkout-query' -const checkoutLineItemUpdateMutation = /* GraphQL */ ` +export const checkoutLineUpdate = /* GraphQL */ ` mutation checkoutLineItemUpdate($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) { checkoutLinesUpdate(checkoutId: $checkoutId, lines: $lineItems) { errors { @@ -14,4 +14,3 @@ const checkoutLineItemUpdateMutation = /* GraphQL */ ` } } ` -export default checkoutLineItemUpdateMutation diff --git a/framework/saleor/utils/mutations/customer-access-token-create.ts b/framework/saleor/utils/mutations/customer-access-token-create.ts index 0643b9227..88dfaf4b8 100644 --- a/framework/saleor/utils/mutations/customer-access-token-create.ts +++ b/framework/saleor/utils/mutations/customer-access-token-create.ts @@ -1,4 +1,4 @@ -const tokenCreateMutation = /* GraphQL */ ` +export const sessionCreate = /* GraphQL */ ` mutation tokenCreate($email: String!, $password: String!) { tokenCreate(email: $email, password: $password) { token @@ -12,4 +12,3 @@ const tokenCreateMutation = /* GraphQL */ ` } } ` -export default tokenCreateMutation; diff --git a/framework/saleor/utils/mutations/customer-access-token-delete.ts b/framework/saleor/utils/mutations/customer-access-token-delete.ts index c9c3338c4..cf308bc44 100644 --- a/framework/saleor/utils/mutations/customer-access-token-delete.ts +++ b/framework/saleor/utils/mutations/customer-access-token-delete.ts @@ -1,4 +1,4 @@ -const customerAccessTokenDeleteMutation = /* GraphQL */ ` +export const sessionDestroy = /* GraphQL */ ` mutation customerAccessTokenDelete { tokensDeactivateAll { errors { @@ -8,5 +8,3 @@ const customerAccessTokenDeleteMutation = /* GraphQL */ ` } } ` - -export default customerAccessTokenDeleteMutation diff --git a/framework/saleor/utils/mutations/customer-create.ts b/framework/saleor/utils/mutations/customer-create.ts index f0a47be8f..79fed9c1a 100644 --- a/framework/saleor/utils/mutations/customer-create.ts +++ b/framework/saleor/utils/mutations/customer-create.ts @@ -1,4 +1,4 @@ -const customerCreateMutation = /* GraphQL */ ` +export const accountRegister = /* GraphQL */ ` mutation customerCreate($input: AccountRegisterInput!) { accountRegister(input: $input) { errors { @@ -13,4 +13,3 @@ const customerCreateMutation = /* GraphQL */ ` } } ` -export default customerCreateMutation diff --git a/framework/saleor/utils/mutations/index.ts b/framework/saleor/utils/mutations/index.ts index 3a16d7cec..7ae8dbd5e 100644 --- a/framework/saleor/utils/mutations/index.ts +++ b/framework/saleor/utils/mutations/index.ts @@ -1,7 +1,7 @@ -export { default as customerCreateMutation } from './customer-create' -export { default as checkoutCreateMutation } from './checkout-create' -export { default as checkoutLineItemAddMutation } from './checkout-line-item-add' -export { default as checkoutLineItemUpdateMutation } from './checkout-line-item-update' -export { default as checkoutLineItemRemoveMutation } from './checkout-line-item-remove' -export { default as customerAccessTokenCreateMutation } from './customer-access-token-create' -export { default as customerAccessTokenDeleteMutation } from './customer-access-token-delete' +export { accountRegister } from './customer-create' +export { checkoutCreate } from './checkout-create' +export { checkoutLineAdd } from './checkout-line-item-add' +export { checkoutLineUpdate } from './checkout-line-item-update' +export { checkoutLineDelete } from './checkout-line-item-remove' +export { sessionCreate } from './customer-access-token-create' +export { sessionDestroy } from './customer-access-token-delete' diff --git a/framework/saleor/utils/queries/get-all-collections-query.ts b/framework/saleor/utils/queries/get-all-collections-query.ts index c664ab1a1..67856c6c5 100644 --- a/framework/saleor/utils/queries/get-all-collections-query.ts +++ b/framework/saleor/utils/queries/get-all-collections-query.ts @@ -1,4 +1,4 @@ -const getSiteCollectionsQuery = /* GraphQL */ ` +export const getSiteCollectionsQuery = /* GraphQL */ ` query getSiteCollections($first: Int!, $channel: String = "default-channel") { collections(first: $first, channel: $channel) { edges { @@ -11,4 +11,3 @@ const getSiteCollectionsQuery = /* GraphQL */ ` } } ` -export default getSiteCollectionsQuery diff --git a/framework/saleor/utils/queries/get-all-pages-query.ts b/framework/saleor/utils/queries/get-all-pages-query.ts index 21912ddb8..879e9202d 100644 --- a/framework/saleor/utils/queries/get-all-pages-query.ts +++ b/framework/saleor/utils/queries/get-all-pages-query.ts @@ -10,5 +10,4 @@ export const getAllPagesQuery = /* GraphQL */ ` } } } -` -export default getAllPagesQuery +` \ No newline at end of file diff --git a/framework/saleor/utils/queries/get-all-product-vendors-query.ts b/framework/saleor/utils/queries/get-all-product-vendors-query.ts index be08b8ec6..d24dab42d 100644 --- a/framework/saleor/utils/queries/get-all-product-vendors-query.ts +++ b/framework/saleor/utils/queries/get-all-product-vendors-query.ts @@ -1,4 +1,4 @@ -const getAllProductVendors = /* GraphQL */ ` +export const getAllProductVendors = /* GraphQL */ ` query getAllProductVendors($first: Int = 250, $cursor: String) { products(first: $first, after: $cursor) { pageInfo { @@ -13,5 +13,4 @@ const getAllProductVendors = /* GraphQL */ ` } } } -` -export default getAllProductVendors +` \ No newline at end of file diff --git a/framework/saleor/utils/queries/get-all-products-paths-query.ts b/framework/saleor/utils/queries/get-all-products-paths-query.ts index 7773104fc..0933977c5 100644 --- a/framework/saleor/utils/queries/get-all-products-paths-query.ts +++ b/framework/saleor/utils/queries/get-all-products-paths-query.ts @@ -1,4 +1,4 @@ -const getAllProductsPathsQuery = /* GraphQL */ ` +export const getAllProductsPathsQuery = /* GraphQL */ ` query getAllProductPaths( $first: Int = 100 $cursor: String @@ -18,4 +18,3 @@ const getAllProductsPathsQuery = /* GraphQL */ ` } } ` -export default getAllProductsPathsQuery diff --git a/framework/saleor/utils/queries/get-all-products-query.ts b/framework/saleor/utils/queries/get-all-products-query.ts index f17082c59..36858228d 100644 --- a/framework/saleor/utils/queries/get-all-products-query.ts +++ b/framework/saleor/utils/queries/get-all-products-query.ts @@ -28,7 +28,7 @@ export const productConnection = /* GraphQL */ ` } ` -const getAllProductsQuery = /* GraphQL */ ` +export const getAllProductsQuery = /* GraphQL */ ` query getAllProducts( $first: Int = 100 $filter: ProductFilterInput @@ -40,4 +40,3 @@ const getAllProductsQuery = /* GraphQL */ ` } ${productConnection} ` -export default getAllProductsQuery diff --git a/framework/saleor/utils/queries/get-checkout-query.ts b/framework/saleor/utils/queries/get-checkout-query.ts index 524718bb8..92faab911 100644 --- a/framework/saleor/utils/queries/get-checkout-query.ts +++ b/framework/saleor/utils/queries/get-checkout-query.ts @@ -47,7 +47,7 @@ export const checkoutDetailsFragment = ` } ` -const getCheckoutQuery = /* GraphQL */ ` +export const getCheckoutQuery = /* GraphQL */ ` query($checkoutId: UUID!) { checkout(token: $checkoutId) { ... on Checkout { @@ -56,4 +56,3 @@ const getCheckoutQuery = /* GraphQL */ ` } } ` -export default getCheckoutQuery diff --git a/framework/saleor/utils/queries/get-collection-products-query.ts b/framework/saleor/utils/queries/get-collection-products-query.ts index 04766caa4..7631a81ab 100644 --- a/framework/saleor/utils/queries/get-collection-products-query.ts +++ b/framework/saleor/utils/queries/get-collection-products-query.ts @@ -1,6 +1,6 @@ import { productConnection } from './get-all-products-query' -const getCollectionProductsQuery = /* GraphQL */ ` +export const getCollectionProductsQuery = /* GraphQL */ ` query getProductsFromCollection( $categoryId: ID! $first: Int = 250 @@ -21,4 +21,3 @@ const getCollectionProductsQuery = /* GraphQL */ ` } } ` -export default getCollectionProductsQuery diff --git a/framework/saleor/utils/queries/get-customer-id-query.ts b/framework/saleor/utils/queries/get-customer-id-query.ts index 076ceb10b..1c197137e 100644 --- a/framework/saleor/utils/queries/get-customer-id-query.ts +++ b/framework/saleor/utils/queries/get-customer-id-query.ts @@ -1,8 +1,7 @@ -export const getCustomerQuery = /* GraphQL */ ` +export const getCustomerIdQuery = /* GraphQL */ ` query getCustomerId($customerAccessToken: String!) { customer(customerAccessToken: $customerAccessToken) { id } } ` -export default getCustomerQuery diff --git a/framework/saleor/utils/queries/get-customer-query.ts b/framework/saleor/utils/queries/get-customer-query.ts index 6a12c0fcc..ec77c89d0 100644 --- a/framework/saleor/utils/queries/get-customer-query.ts +++ b/framework/saleor/utils/queries/get-customer-query.ts @@ -1,19 +1,11 @@ -// FIXME move to `mutations/` @zaiste export const getCustomerQuery = /* GraphQL */ ` - mutation getCustomer($customerAccessToken: String!) { - tokenRefresh(csrfToken: $customerAccessToken) { - token - user { - id - email - firstName - lastName - dateJoined - } - errors { - code - message - } + query getCustomer { + me { + id + email + firstName + lastName + dateJoined } } ` diff --git a/framework/saleor/utils/queries/get-page-query.ts b/framework/saleor/utils/queries/get-page-query.ts index 5cdf6cfc5..7cd9f1203 100644 --- a/framework/saleor/utils/queries/get-page-query.ts +++ b/framework/saleor/utils/queries/get-page-query.ts @@ -7,4 +7,3 @@ export const getPageQuery = /* GraphQL */ ` } } ` -export default getPageQuery diff --git a/framework/saleor/utils/queries/get-product-query.ts b/framework/saleor/utils/queries/get-product-query.ts index 15591edc0..7a8b68d6d 100644 --- a/framework/saleor/utils/queries/get-product-query.ts +++ b/framework/saleor/utils/queries/get-product-query.ts @@ -1,4 +1,4 @@ -const getProductQuery = /* GraphQL */ ` +export const getProductQuery = /* GraphQL */ ` query getProductBySlug($slug: String!, $channel: String = "default-channel") { product(slug: $slug, channel: $channel) { id @@ -42,4 +42,3 @@ const getProductQuery = /* GraphQL */ ` } ` -export default getProductQuery diff --git a/framework/saleor/utils/queries/index.ts b/framework/saleor/utils/queries/index.ts index e19be9c8c..93052314c 100644 --- a/framework/saleor/utils/queries/index.ts +++ b/framework/saleor/utils/queries/index.ts @@ -1,10 +1,11 @@ -export { default as getSiteCollectionsQuery } from './get-all-collections-query' -export { default as getProductQuery } from './get-product-query' -export { default as getAllProductsQuery } from './get-all-products-query' -export { default as getAllProductsPathtsQuery } from './get-all-products-paths-query' -export { default as getAllProductVendors } from './get-all-product-vendors-query' -export { default as getCollectionProductsQuery } from './get-collection-products-query' -export { default as getCheckoutQuery } from './get-checkout-query' -export { default as getAllPagesQuery } from './get-all-pages-query' -export { default as getPageQuery } from './get-page-query' -export { default as getCustomerQuery } from './get-customer-query' +export { getSiteCollectionsQuery } from './get-all-collections-query' +export { getProductQuery } from './get-product-query' +export { getAllProductsQuery } from './get-all-products-query' +export { getAllProductsPathsQuery } from './get-all-products-paths-query' +export { getAllProductVendors } from './get-all-product-vendors-query' +export { getCollectionProductsQuery } from './get-collection-products-query' +export { getCheckoutQuery } from './get-checkout-query' +export { getAllPagesQuery } from './get-all-pages-query' +export { getPageQuery } from './get-page-query' +export { getCustomerQuery } from './get-customer-query' +export { getCustomerIdQuery } from './get-customer-id-query'