mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
saleor: unify GraphQL naming approach
This commit is contained in:
parent
df3d85f86e
commit
f530704efe
@ -15,7 +15,7 @@ export default useLogin as UseLogin<typeof handler>
|
|||||||
|
|
||||||
export const handler: MutationHook<null, {}, MutationTokenCreateArgs> = {
|
export const handler: MutationHook<null, {}, MutationTokenCreateArgs> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
query: mutation.sessionCreate,
|
query: mutation.SessionCreate,
|
||||||
},
|
},
|
||||||
async fetcher({ input: { email, password }, options, fetch }) {
|
async fetcher({ input: { email, password }, options, fetch }) {
|
||||||
if (!(email && password)) {
|
if (!(email && password)) {
|
||||||
|
@ -9,7 +9,7 @@ export default useLogout as UseLogout<typeof handler>
|
|||||||
|
|
||||||
export const handler: MutationHook<null> = {
|
export const handler: MutationHook<null> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
query: mutation.sessionDestroy,
|
query: mutation.SessionDestroy,
|
||||||
},
|
},
|
||||||
async fetcher({ options, fetch }) {
|
async fetcher({ options, fetch }) {
|
||||||
await fetch({
|
await fetch({
|
||||||
|
@ -21,7 +21,7 @@ export const handler: MutationHook<
|
|||||||
AccountRegisterInput
|
AccountRegisterInput
|
||||||
> = {
|
> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
query: mutation.accountRegister
|
query: mutation.AccountCreate
|
||||||
},
|
},
|
||||||
async fetcher({
|
async fetcher({
|
||||||
input: { email, password },
|
input: { email, password },
|
||||||
|
@ -17,7 +17,7 @@ import { Mutation, MutationCheckoutLinesAddArgs } from '../schema'
|
|||||||
export default useAddItem as UseAddItem<typeof handler>
|
export default useAddItem as UseAddItem<typeof handler>
|
||||||
|
|
||||||
export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
||||||
fetchOptions: { query: mutation.checkoutLineAdd },
|
fetchOptions: { query: mutation.CheckoutLineAdd },
|
||||||
async fetcher({ input: item, options, fetch }) {
|
async fetcher({ input: item, options, fetch }) {
|
||||||
if (
|
if (
|
||||||
item.quantity &&
|
item.quantity &&
|
||||||
|
@ -7,7 +7,7 @@ import useCommerceCart, {
|
|||||||
import { Cart } from '../types'
|
import { Cart } from '../types'
|
||||||
import { SWRHook } from '@commerce/utils/types'
|
import { SWRHook } from '@commerce/utils/types'
|
||||||
import { checkoutCreate, checkoutToCart, getCheckoutId } from '../utils'
|
import { checkoutCreate, checkoutToCart, getCheckoutId } from '../utils'
|
||||||
import { getCheckoutQuery } from '../utils/queries'
|
import * as query from '../utils/queries'
|
||||||
|
|
||||||
export default useCommerceCart as UseCart<typeof handler>
|
export default useCommerceCart as UseCart<typeof handler>
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export const handler: SWRHook<
|
|||||||
{ isEmpty?: boolean }
|
{ isEmpty?: boolean }
|
||||||
> = {
|
> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
query: getCheckoutQuery,
|
query: query.CheckoutOne,
|
||||||
},
|
},
|
||||||
async fetcher({ input: { cartId: checkoutId }, options, fetch }) {
|
async fetcher({ input: { cartId: checkoutId }, options, fetch }) {
|
||||||
let checkout
|
let checkout
|
||||||
|
@ -29,7 +29,7 @@ export type RemoveItemInput<T = any> = T extends LineItem
|
|||||||
export default useRemoveItem as UseRemoveItem<typeof handler>
|
export default useRemoveItem as UseRemoveItem<typeof handler>
|
||||||
|
|
||||||
export const handler = {
|
export const handler = {
|
||||||
fetchOptions: { query: mutation.checkoutLineDelete },
|
fetchOptions: { query: mutation.CheckoutLineDelete },
|
||||||
async fetcher({
|
async fetcher({
|
||||||
input: { itemId },
|
input: { itemId },
|
||||||
options,
|
options,
|
||||||
|
@ -26,7 +26,7 @@ export type UpdateItemInput<T = any> = T extends LineItem
|
|||||||
export default useUpdateItem as UseUpdateItem<typeof handler>
|
export default useUpdateItem as UseUpdateItem<typeof handler>
|
||||||
|
|
||||||
export const handler = {
|
export const handler = {
|
||||||
fetchOptions: { query: mutation.checkoutLineUpdate },
|
fetchOptions: { query: mutation.CheckoutLineUpdate },
|
||||||
async fetcher({
|
async fetcher({
|
||||||
input: { itemId, item },
|
input: { itemId, item },
|
||||||
options,
|
options,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { getConfig, SaleorConfig } from '../api'
|
import { getConfig, SaleorConfig } from '../api'
|
||||||
import { PageCountableEdge } from '../schema'
|
import { PageCountableEdge } from '../schema'
|
||||||
import { getAllPagesQuery } from '../utils/queries'
|
import * as query from '../utils/queries'
|
||||||
|
|
||||||
type Variables = {
|
type Variables = {
|
||||||
first?: number
|
first?: number
|
||||||
@ -26,7 +26,7 @@ const getAllPages = async (options?: {
|
|||||||
let { config, variables = { first: 100 } } = options ?? {}
|
let { config, variables = { first: 100 } } = options ?? {}
|
||||||
config = getConfig(config)
|
config = getConfig(config)
|
||||||
const { locale } = config
|
const { locale } = config
|
||||||
const { data } = await config.fetch(getAllPagesQuery, { variables })
|
const { data } = await config.fetch(query.PageMany, { variables })
|
||||||
|
|
||||||
const pages = data.pages?.edges?.map(
|
const pages = data.pages?.edges?.map(
|
||||||
({ node: { title: name, slug, ...node } }: PageCountableEdge) => ({
|
({ node: { title: name, slug, ...node } }: PageCountableEdge) => ({
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { getConfig, SaleorConfig } from '../api'
|
import { getConfig, SaleorConfig } from '../api'
|
||||||
import { getPageQuery } from '../utils/queries'
|
|
||||||
import { Page } from './get-all-pages'
|
import { Page } from './get-all-pages'
|
||||||
|
|
||||||
|
import * as query from '../utils/queries'
|
||||||
|
|
||||||
type Variables = {
|
type Variables = {
|
||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
@ -18,9 +19,7 @@ const getPage = async (options: {
|
|||||||
config = getConfig(config)
|
config = getConfig(config)
|
||||||
const { locale } = config
|
const { locale } = config
|
||||||
|
|
||||||
const { data } = await config.fetch(getPageQuery, {
|
const { data } = await config.fetch(query.PageOne, { variables })
|
||||||
variables,
|
|
||||||
})
|
|
||||||
const page = data.page
|
const page = data.page
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { getConfig, SaleorConfig } from '../api'
|
import { getConfig, SaleorConfig } from '../api'
|
||||||
import { getCustomerIdQuery } from '../utils/queries'
|
import * as query from '../utils/queries'
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
|
||||||
async function getCustomerId({
|
async function getCustomerId({
|
||||||
@ -11,7 +11,7 @@ async function getCustomerId({
|
|||||||
}): Promise<number | undefined> {
|
}): Promise<number | undefined> {
|
||||||
config = getConfig(config)
|
config = getConfig(config)
|
||||||
|
|
||||||
const { data } = await config.fetch(getCustomerIdQuery, {
|
const { data } = await config.fetch(query.CustomerOne, {
|
||||||
variables: {
|
variables: {
|
||||||
customerAccesToken:
|
customerAccesToken:
|
||||||
customerAccesToken || Cookies.get(config.customerCookie),
|
customerAccesToken || Cookies.get(config.customerCookie),
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
|
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
|
||||||
import { Customer } from '@commerce/types'
|
import { Customer } from '@commerce/types'
|
||||||
import { SWRHook } from '@commerce/utils/types'
|
import { SWRHook } from '@commerce/utils/types'
|
||||||
import { getCustomerQuery } from '../utils'
|
|
||||||
|
import * as query from '../utils/queries'
|
||||||
|
|
||||||
export default useCustomer as UseCustomer<typeof handler>
|
export default useCustomer as UseCustomer<typeof handler>
|
||||||
|
|
||||||
export const handler: SWRHook<Customer | null> = {
|
export const handler: SWRHook<Customer | null> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
query: getCustomerQuery,
|
query: query.CustomerCurrent,
|
||||||
},
|
},
|
||||||
async fetcher({ options, fetch }) {
|
async fetcher({ options, fetch }) {
|
||||||
const data = await fetch<any | null>({
|
const data = await fetch<any | null>({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { CollectionCountableEdge } from '../schema'
|
import { CollectionCountableEdge } from '../schema'
|
||||||
import { getConfig, SaleorConfig } from '../api'
|
import { getConfig, SaleorConfig } from '../api'
|
||||||
import { getSiteCollectionsQuery } from '../utils/queries'
|
import * as query from '../utils/queries'
|
||||||
|
|
||||||
const getAllCollections = async (options?: {
|
const getAllCollections = async (options?: {
|
||||||
variables?: any
|
variables?: any
|
||||||
@ -10,7 +10,7 @@ const getAllCollections = async (options?: {
|
|||||||
let { config, variables = { first: 100 } } = options ?? {}
|
let { config, variables = { first: 100 } } = options ?? {}
|
||||||
config = getConfig(config)
|
config = getConfig(config)
|
||||||
|
|
||||||
const { data } = await config.fetch(getSiteCollectionsQuery, { variables })
|
const { data } = await config.fetch(query.CollectionMany, { variables })
|
||||||
const edges = data.collections?.edges ?? []
|
const edges = data.collections?.edges ?? []
|
||||||
|
|
||||||
const categories = edges.map(
|
const categories = edges.map(
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import { GraphQLFetcherResult } from '@commerce/api'
|
import { GraphQLFetcherResult } from '@commerce/api'
|
||||||
|
import { Product } from '@commerce/types'
|
||||||
|
|
||||||
import { getConfig, SaleorConfig } from '../api'
|
import { getConfig, SaleorConfig } from '../api'
|
||||||
import { ProductCountableEdge } from '../schema'
|
import { ProductCountableEdge } from '../schema'
|
||||||
import { getAllProductsQuery } from '../utils/queries'
|
|
||||||
import { normalizeProduct } from '../utils/normalize'
|
import { normalizeProduct } from '../utils/normalize'
|
||||||
import { Product } from '@commerce/types'
|
|
||||||
|
import * as query from '../utils/queries'
|
||||||
|
|
||||||
type Variables = {
|
type Variables = {
|
||||||
first?: number
|
first?: number
|
||||||
@ -22,10 +24,7 @@ const getAllProducts = async (options: {
|
|||||||
let { config, variables = { first: 100 } } = options ?? {}
|
let { config, variables = { first: 100 } } = options ?? {}
|
||||||
config = getConfig(config)
|
config = getConfig(config)
|
||||||
|
|
||||||
const { data }: GraphQLFetcherResult = await config.fetch(
|
const { data }: GraphQLFetcherResult = await config.fetch(query.ProductMany, { variables })
|
||||||
getAllProductsQuery,
|
|
||||||
{ variables }
|
|
||||||
)
|
|
||||||
|
|
||||||
const products =
|
const products =
|
||||||
data.products?.edges?.map(({ node: p }: ProductCountableEdge) =>
|
data.products?.edges?.map(({ node: p }: ProductCountableEdge) =>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { GraphQLFetcherResult } from '@commerce/api'
|
import { GraphQLFetcherResult } from '@commerce/api'
|
||||||
import { getConfig, SaleorConfig } from '../api'
|
import { getConfig, SaleorConfig } from '../api'
|
||||||
import { normalizeProduct, getProductQuery } from '../utils'
|
import { normalizeProduct } from '../utils'
|
||||||
|
import * as query from '../utils/queries';
|
||||||
|
|
||||||
type Variables = {
|
type Variables = {
|
||||||
slug: string
|
slug: string
|
||||||
@ -18,9 +19,7 @@ const getProduct = async (options: {
|
|||||||
let { config, variables } = options ?? {}
|
let { config, variables } = options ?? {}
|
||||||
config = getConfig(config)
|
config = getConfig(config)
|
||||||
|
|
||||||
const { data }: GraphQLFetcherResult = await config.fetch(getProductQuery, {
|
const { data }: GraphQLFetcherResult = await config.fetch(query.ProductOneBySlug, { variables })
|
||||||
variables,
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
product: data?.product ? normalizeProduct(data.product) : null,
|
product: data?.product ? normalizeProduct(data.product) : null,
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
import { SWRHook } from '@commerce/utils/types'
|
import { SWRHook } from '@commerce/utils/types'
|
||||||
|
import { Product } from '@commerce/types'
|
||||||
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
||||||
|
|
||||||
import { ProductCountableEdge } from '../schema'
|
import { ProductCountableEdge } from '../schema'
|
||||||
import {
|
import {
|
||||||
getAllProductsQuery,
|
|
||||||
getCollectionProductsQuery,
|
|
||||||
getSearchVariables,
|
getSearchVariables,
|
||||||
normalizeProduct,
|
normalizeProduct,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
|
||||||
import { Product } from '@commerce/types'
|
import * as query from '../utils/queries'
|
||||||
|
|
||||||
export default useSearch as UseSearch<typeof handler>
|
export default useSearch as UseSearch<typeof handler>
|
||||||
|
|
||||||
@ -31,13 +30,13 @@ export const handler: SWRHook<
|
|||||||
SearchProductsInput
|
SearchProductsInput
|
||||||
> = {
|
> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
query: getAllProductsQuery,
|
query: query.ProductMany
|
||||||
},
|
},
|
||||||
async fetcher({ input, options, fetch }) {
|
async fetcher({ input, options, fetch }) {
|
||||||
const { categoryId, brandId } = input
|
const { categoryId, brandId } = input
|
||||||
|
|
||||||
const data = await fetch({
|
const data = await fetch({
|
||||||
query: categoryId ? getCollectionProductsQuery : options.query,
|
query: categoryId ? query.CollectionOne : options.query,
|
||||||
method: options?.method,
|
method: options?.method,
|
||||||
variables: getSearchVariables(input),
|
variables: getSearchVariables(input),
|
||||||
})
|
})
|
||||||
|
@ -6,7 +6,7 @@ export const checkoutAttach = async (
|
|||||||
{ variables, headers }: any,
|
{ variables, headers }: any,
|
||||||
): Promise<CheckoutCustomerAttach> => {
|
): Promise<CheckoutCustomerAttach> => {
|
||||||
const data = await fetch({
|
const data = await fetch({
|
||||||
query: mutation.AttachCheckout,
|
query: mutation.CheckoutAttach,
|
||||||
variables,
|
variables,
|
||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,7 @@ import { CHECKOUT_ID_COOKIE } from '@framework/const'
|
|||||||
export const checkoutCreate = async (
|
export const checkoutCreate = async (
|
||||||
fetch: any
|
fetch: any
|
||||||
): Promise<CheckoutCreate> => {
|
): Promise<CheckoutCreate> => {
|
||||||
const data = await fetch({ query: mutation.checkoutCreate })
|
const data = await fetch({ query: mutation.CheckoutCreate })
|
||||||
const checkout = data.checkoutCreate?.checkout
|
const checkout = data.checkoutCreate?.checkout
|
||||||
const checkoutId = checkout?.id
|
const checkoutId = checkout?.id
|
||||||
const checkoutToken = checkout?.token
|
const checkoutToken = checkout?.token
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export const checkoutDetailsFragment = `
|
export const CheckoutDetails = `
|
||||||
id
|
id
|
||||||
token
|
token
|
||||||
created
|
created
|
||||||
@ -46,13 +46,3 @@ export const checkoutDetailsFragment = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const getCheckoutQuery = /* GraphQL */ `
|
|
||||||
query($checkoutId: UUID!) {
|
|
||||||
checkout(token: $checkoutId) {
|
|
||||||
... on Checkout {
|
|
||||||
${checkoutDetailsFragment}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
2
framework/saleor/utils/fragments/index.ts
Normal file
2
framework/saleor/utils/fragments/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export { ProductConnection } from './product';
|
||||||
|
export { CheckoutDetails } from './checkout-details';
|
29
framework/saleor/utils/fragments/product.ts
Normal file
29
framework/saleor/utils/fragments/product.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
export const ProductConnection = /* GraphQL */ `
|
||||||
|
fragment ProductConnection on ProductCountableConnection {
|
||||||
|
pageInfo {
|
||||||
|
hasNextPage
|
||||||
|
hasPreviousPage
|
||||||
|
}
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
description
|
||||||
|
slug
|
||||||
|
pricing {
|
||||||
|
priceRange {
|
||||||
|
start {
|
||||||
|
net {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
media {
|
||||||
|
url
|
||||||
|
alt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
@ -1,6 +1,6 @@
|
|||||||
import { SaleorConfig } from '../api'
|
import { SaleorConfig } from '../api'
|
||||||
import { CollectionCountableEdge } from '../schema'
|
import { CollectionCountableEdge } from '../schema'
|
||||||
import { getSiteCollectionsQuery } from './queries/'
|
import * as query from './queries';
|
||||||
|
|
||||||
export type Category = {
|
export type Category = {
|
||||||
entityId: string
|
entityId: string
|
||||||
@ -9,7 +9,7 @@ export type Category = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getCategories = async (config: SaleorConfig): Promise<Category[]> => {
|
const getCategories = async (config: SaleorConfig): Promise<Category[]> => {
|
||||||
const { data } = await config.fetch(getSiteCollectionsQuery, {
|
const { data } = await config.fetch(query.CollectionMany, {
|
||||||
variables: {
|
variables: {
|
||||||
first: 100,
|
first: 100,
|
||||||
},
|
},
|
||||||
|
@ -7,7 +7,7 @@ export const getSearchVariables = ({
|
|||||||
categoryId,
|
categoryId,
|
||||||
sort,
|
sort,
|
||||||
}: SearchProductsInput) => {
|
}: SearchProductsInput) => {
|
||||||
const sortBy = { direction: 'ASC', ...getSortVariables(sort, !!categoryId), channel: "default-channel"};
|
const sortBy = { field: "NAME", direction: 'ASC', ...getSortVariables(sort, !!categoryId), channel: "default-channel"};
|
||||||
return {
|
return {
|
||||||
categoryId,
|
categoryId,
|
||||||
filter: { search },
|
filter: { search },
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { SaleorConfig } from '../api'
|
import { SaleorConfig } from '../api'
|
||||||
import fetchAllProducts from '../api/utils/fetch-all-products'
|
|
||||||
import { getAllProductVendors } from './queries'
|
|
||||||
|
|
||||||
export type Brand = {
|
export type Brand = {
|
||||||
entityId: string
|
entityId: string
|
||||||
|
@ -26,7 +26,7 @@ export const handleAutomaticLogin = async (
|
|||||||
Mutation,
|
Mutation,
|
||||||
MutationTokenCreateArgs
|
MutationTokenCreateArgs
|
||||||
>({
|
>({
|
||||||
query: mutation.sessionCreate,
|
query: mutation.SessionCreate,
|
||||||
variables: { ...input },
|
variables: { ...input },
|
||||||
})
|
})
|
||||||
handleLogin(tokenCreate!)
|
handleLogin(tokenCreate!)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export const accountRegister = /* GraphQL */ `
|
export const AccountCreate = /* GraphQL */ `
|
||||||
mutation customerCreate($input: AccountRegisterInput!) {
|
mutation AccountCreate($input: AccountRegisterInput!) {
|
||||||
accountRegister(input: $input) {
|
accountRegister(input: $input) {
|
||||||
errors {
|
errors {
|
||||||
code
|
code
|
@ -1,5 +1,5 @@
|
|||||||
export const AttachCheckout = /* GraphQl */ `
|
export const CheckoutAttach = /* GraphQl */ `
|
||||||
mutation AttachCheckout($checkoutId: ID!) {
|
mutation CheckoutAttach($checkoutId: ID!) {
|
||||||
checkoutCustomerAttach(checkoutId: $checkoutId) {
|
checkoutCustomerAttach(checkoutId: $checkoutId) {
|
||||||
errors {
|
errors {
|
||||||
message
|
message
|
@ -1,7 +1,7 @@
|
|||||||
import { checkoutDetailsFragment } from '../queries/get-checkout-query'
|
import * as fragment from '../fragments'
|
||||||
|
|
||||||
export const checkoutCreate = /* GraphQL */ `
|
export const CheckoutCreate = /* GraphQL */ `
|
||||||
mutation createCheckout {
|
mutation CheckoutCreate {
|
||||||
checkoutCreate(input: {
|
checkoutCreate(input: {
|
||||||
email: "customer@example.com",
|
email: "customer@example.com",
|
||||||
lines: [],
|
lines: [],
|
||||||
@ -13,7 +13,7 @@ export const checkoutCreate = /* GraphQL */ `
|
|||||||
message
|
message
|
||||||
}
|
}
|
||||||
checkout {
|
checkout {
|
||||||
${checkoutDetailsFragment}
|
${fragment.CheckoutDetails}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
framework/saleor/utils/mutations/checkout-line-add.ts
Normal file
16
framework/saleor/utils/mutations/checkout-line-add.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import * as fragment from '../fragments'
|
||||||
|
|
||||||
|
export const CheckoutLineAdd = /* GraphQL */ `
|
||||||
|
mutation CheckoutLineAdd($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) {
|
||||||
|
checkoutLinesAdd(checkoutId: $checkoutId, lines: $lineItems) {
|
||||||
|
errors {
|
||||||
|
code
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
checkout {
|
||||||
|
${fragment.CheckoutDetails}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
@ -1,16 +0,0 @@
|
|||||||
import { checkoutDetailsFragment } from '../queries/get-checkout-query'
|
|
||||||
|
|
||||||
export const checkoutLineAdd = /* GraphQL */ `
|
|
||||||
mutation checkoutLineItemAdd($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) {
|
|
||||||
checkoutLinesAdd(checkoutId: $checkoutId, lines: $lineItems) {
|
|
||||||
errors {
|
|
||||||
code
|
|
||||||
field
|
|
||||||
message
|
|
||||||
}
|
|
||||||
checkout {
|
|
||||||
${checkoutDetailsFragment}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
@ -1,19 +0,0 @@
|
|||||||
import { checkoutDetailsFragment } from '../queries/get-checkout-query'
|
|
||||||
|
|
||||||
export const checkoutLineDelete = /* GraphQL */ `
|
|
||||||
mutation checkoutLineItemRemove($checkoutId: ID!, $lineId: ID!) {
|
|
||||||
checkoutLineDelete(
|
|
||||||
checkoutId: $checkoutId
|
|
||||||
lineId: $lineId
|
|
||||||
) {
|
|
||||||
errors {
|
|
||||||
code
|
|
||||||
field
|
|
||||||
message
|
|
||||||
}
|
|
||||||
checkout {
|
|
||||||
${checkoutDetailsFragment}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
@ -1,16 +0,0 @@
|
|||||||
import { checkoutDetailsFragment } from '../queries/get-checkout-query'
|
|
||||||
|
|
||||||
export const checkoutLineUpdate = /* GraphQL */ `
|
|
||||||
mutation checkoutLineItemUpdate($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) {
|
|
||||||
checkoutLinesUpdate(checkoutId: $checkoutId, lines: $lineItems) {
|
|
||||||
errors {
|
|
||||||
code
|
|
||||||
field
|
|
||||||
message
|
|
||||||
}
|
|
||||||
checkout {
|
|
||||||
${checkoutDetailsFragment}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
19
framework/saleor/utils/mutations/checkout-line-remove.ts
Normal file
19
framework/saleor/utils/mutations/checkout-line-remove.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import * as fragment from '../fragments'
|
||||||
|
|
||||||
|
export const CheckoutLineDelete = /* GraphQL */ `
|
||||||
|
mutation CheckoutLineDelete($checkoutId: ID!, $lineId: ID!) {
|
||||||
|
checkoutLineDelete(
|
||||||
|
checkoutId: $checkoutId
|
||||||
|
lineId: $lineId
|
||||||
|
) {
|
||||||
|
errors {
|
||||||
|
code
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
checkout {
|
||||||
|
${fragment.CheckoutDetails}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
16
framework/saleor/utils/mutations/checkout-line-update.ts
Normal file
16
framework/saleor/utils/mutations/checkout-line-update.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import * as fragment from '../fragments';
|
||||||
|
|
||||||
|
export const CheckoutLineUpdate = /* GraphQL */ `
|
||||||
|
mutation CheckoutLineUpdate($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) {
|
||||||
|
checkoutLinesUpdate(checkoutId: $checkoutId, lines: $lineItems) {
|
||||||
|
errors {
|
||||||
|
code
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
checkout {
|
||||||
|
${fragment.CheckoutDetails}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
@ -1,8 +1,8 @@
|
|||||||
export { accountRegister } from './customer-create'
|
export { AccountCreate } from './account-create'
|
||||||
export { checkoutCreate } from './checkout-create'
|
export { CheckoutCreate } from './checkout-create'
|
||||||
export { checkoutLineAdd } from './checkout-line-item-add'
|
export { CheckoutLineAdd } from './checkout-line-add'
|
||||||
export { checkoutLineUpdate } from './checkout-line-item-update'
|
export { CheckoutLineUpdate } from './checkout-line-update'
|
||||||
export { checkoutLineDelete } from './checkout-line-item-remove'
|
export { CheckoutLineDelete } from './checkout-line-remove'
|
||||||
export { sessionCreate } from './customer-access-token-create'
|
export { SessionCreate } from './session-create'
|
||||||
export { sessionDestroy } from './customer-access-token-delete'
|
export { SessionDestroy } from './session-destroy'
|
||||||
export { AttachCheckout } from './attach-checkout'
|
export { CheckoutAttach } from './checkout-attach'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export const sessionCreate = /* GraphQL */ `
|
export const SessionCreate = /* GraphQL */ `
|
||||||
mutation tokenCreate($email: String!, $password: String!) {
|
mutation SessionCreate($email: String!, $password: String!) {
|
||||||
tokenCreate(email: $email, password: $password) {
|
tokenCreate(email: $email, password: $password) {
|
||||||
token
|
token
|
||||||
refreshToken
|
refreshToken
|
@ -1,5 +1,5 @@
|
|||||||
export const sessionDestroy = /* GraphQL */ `
|
export const SessionDestroy = /* GraphQL */ `
|
||||||
mutation customerAccessTokenDelete {
|
mutation SessionDestroy {
|
||||||
tokensDeactivateAll {
|
tokensDeactivateAll {
|
||||||
errors {
|
errors {
|
||||||
field
|
field
|
11
framework/saleor/utils/queries/checkout-one.ts
Normal file
11
framework/saleor/utils/queries/checkout-one.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import * as fragment from '../fragments';
|
||||||
|
|
||||||
|
export const CheckoutOne = /* GraphQL */ `
|
||||||
|
query CheckoutOne($checkoutId: UUID!) {
|
||||||
|
checkout(token: $checkoutId) {
|
||||||
|
... on Checkout {
|
||||||
|
${fragment.CheckoutDetails}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
@ -1,5 +1,5 @@
|
|||||||
export const getSiteCollectionsQuery = /* GraphQL */ `
|
export const CollectionMany = /* GraphQL */ `
|
||||||
query getSiteCollections($first: Int!, $channel: String = "default-channel") {
|
query CollectionMany($first: Int!, $channel: String = "default-channel") {
|
||||||
collections(first: $first, channel: $channel) {
|
collections(first: $first, channel: $channel) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
@ -1,6 +1,6 @@
|
|||||||
import { productConnection } from './get-all-products-query'
|
import * as fragment from '../fragments'
|
||||||
|
|
||||||
export const getCollectionProductsQuery = /* GraphQL */ `
|
export const CollectionOne = /* GraphQL */ `
|
||||||
query getProductsFromCollection(
|
query getProductsFromCollection(
|
||||||
$categoryId: ID!
|
$categoryId: ID!
|
||||||
$first: Int = 100
|
$first: Int = 100
|
||||||
@ -9,9 +9,9 @@ export const getCollectionProductsQuery = /* GraphQL */ `
|
|||||||
collection(id: $categoryId, channel: $channel) {
|
collection(id: $categoryId, channel: $channel) {
|
||||||
id
|
id
|
||||||
products(first: $first) {
|
products(first: $first) {
|
||||||
...productConnection
|
...ProductConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
${productConnection}
|
${fragment.ProductConnection}
|
||||||
`
|
`
|
11
framework/saleor/utils/queries/customer-current.ts
Normal file
11
framework/saleor/utils/queries/customer-current.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
export const CustomerCurrent = /* GraphQL */ `
|
||||||
|
query CustomerCurrent {
|
||||||
|
me {
|
||||||
|
id
|
||||||
|
email
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
dateJoined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
7
framework/saleor/utils/queries/customer-one.ts
Normal file
7
framework/saleor/utils/queries/customer-one.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export const CustomerOne = /* GraphQL */ `
|
||||||
|
query CustomerOne($customerAccessToken: String!) {
|
||||||
|
customer(customerAccessToken: $customerAccessToken) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
@ -1,43 +0,0 @@
|
|||||||
export const productConnection = /* GraphQL */ `
|
|
||||||
fragment productConnection on ProductCountableConnection {
|
|
||||||
pageInfo {
|
|
||||||
hasNextPage
|
|
||||||
hasPreviousPage
|
|
||||||
}
|
|
||||||
edges {
|
|
||||||
node {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
description
|
|
||||||
slug
|
|
||||||
pricing {
|
|
||||||
priceRange {
|
|
||||||
start {
|
|
||||||
net {
|
|
||||||
amount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
media {
|
|
||||||
url
|
|
||||||
alt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
export const getAllProductsQuery = /* GraphQL */ `
|
|
||||||
query getAllProducts(
|
|
||||||
$first: Int = 100
|
|
||||||
$filter: ProductFilterInput
|
|
||||||
$sortBy: ProductOrder
|
|
||||||
$channel: String = "default-channel"
|
|
||||||
) {
|
|
||||||
products(first: $first, channel: $channel, filter: $filter, sortBy: $sortBy) {
|
|
||||||
...productConnection
|
|
||||||
}
|
|
||||||
}
|
|
||||||
${productConnection}
|
|
||||||
`
|
|
@ -1,7 +0,0 @@
|
|||||||
export const getCustomerIdQuery = /* GraphQL */ `
|
|
||||||
query getCustomerId($customerAccessToken: String!) {
|
|
||||||
customer(customerAccessToken: $customerAccessToken) {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
@ -1,12 +0,0 @@
|
|||||||
export const getCustomerQuery = /* GraphQL */ `
|
|
||||||
query getCustomer {
|
|
||||||
me {
|
|
||||||
id
|
|
||||||
email
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
dateJoined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
export default getCustomerQuery
|
|
@ -1,9 +0,0 @@
|
|||||||
export const getPageQuery = /* GraphQL */ `
|
|
||||||
query($id: ID!) {
|
|
||||||
page(id: $id) {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
slug
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
@ -1,11 +1,14 @@
|
|||||||
export { getSiteCollectionsQuery } from './get-all-collections-query'
|
export { CollectionMany } from './collection-many'
|
||||||
export { getProductQuery } from './get-product-query'
|
export { ProductOneBySlug } from './product-one-by-slug'
|
||||||
export { getAllProductsQuery } from './get-all-products-query'
|
export { ProductMany } from './product-many'
|
||||||
|
export { CollectionOne } from './collection-one'
|
||||||
|
export { CheckoutOne } from './checkout-one'
|
||||||
|
export { PageMany } from './page-many'
|
||||||
|
export { PageOne } from './page-one'
|
||||||
|
export { CustomerCurrent } from './customer-current'
|
||||||
|
|
||||||
|
// getCustomerIdQuery
|
||||||
|
export { CustomerOne } from './customer-one'
|
||||||
|
|
||||||
export { getAllProductsPathsQuery } from './get-all-products-paths-query'
|
export { getAllProductsPathsQuery } from './get-all-products-paths-query'
|
||||||
export { getAllProductVendors } from './get-all-product-vendors-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'
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export const getAllPagesQuery = /* GraphQL */ `
|
export const PageMany = /* GraphQL */ `
|
||||||
query getAllPages($first: Int = 100) {
|
query PageMany($first: Int = 100) {
|
||||||
pages(first: $first) {
|
pages(first: $first) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
9
framework/saleor/utils/queries/page-one.ts
Normal file
9
framework/saleor/utils/queries/page-one.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export const PageOne = /* GraphQL */ `
|
||||||
|
query PageOne($id: ID!) {
|
||||||
|
page(id: $id) {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
slug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
15
framework/saleor/utils/queries/product-many.ts
Normal file
15
framework/saleor/utils/queries/product-many.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import * as fragment from '../fragments';
|
||||||
|
|
||||||
|
export const ProductMany = /* GraphQL */ `
|
||||||
|
query ProductMany(
|
||||||
|
$first: Int = 100
|
||||||
|
$filter: ProductFilterInput
|
||||||
|
$sortBy: ProductOrder
|
||||||
|
$channel: String = "default-channel"
|
||||||
|
) {
|
||||||
|
products(first: $first, channel: $channel, filter: $filter, sortBy: $sortBy) {
|
||||||
|
...ProductConnection
|
||||||
|
}
|
||||||
|
}
|
||||||
|
${fragment.ProductConnection}
|
||||||
|
`
|
@ -1,5 +1,5 @@
|
|||||||
export const getProductQuery = /* GraphQL */ `
|
export const ProductOneBySlug = /* GraphQL */ `
|
||||||
query getProductBySlug($slug: String!, $channel: String = "default-channel") {
|
query ProductOneBySlug($slug: String!, $channel: String = "default-channel") {
|
||||||
product(slug: $slug, channel: $channel) {
|
product(slug: $slug, channel: $channel) {
|
||||||
id
|
id
|
||||||
slug
|
slug
|
Loading…
x
Reference in New Issue
Block a user