forked from crowetic/commerce
Added config obj to operations
This commit is contained in:
parent
22bd962b71
commit
5459c70fde
@ -4,7 +4,12 @@ import type {
|
||||
} from 'lib/bigcommerce/schema';
|
||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types';
|
||||
import { productInfoFragment } from '../fragments/product';
|
||||
import { getConfig, Images, ProductImageVariables } from '..';
|
||||
import {
|
||||
BigcommerceConfig,
|
||||
getConfig,
|
||||
Images,
|
||||
ProductImageVariables,
|
||||
} from '..';
|
||||
|
||||
export const getAllProductsQuery = /* GraphQL */ `
|
||||
query getAllProducts(
|
||||
@ -49,21 +54,24 @@ export type ProductVariables = Images &
|
||||
async function getAllProducts(opts?: {
|
||||
query?: string;
|
||||
variables?: ProductVariables;
|
||||
config?: BigcommerceConfig;
|
||||
}): Promise<GetAllProductsResult<GetAllProductsQuery>>;
|
||||
|
||||
async function getAllProducts<T, V = any>(opts: {
|
||||
query: string;
|
||||
variables?: V;
|
||||
config?: BigcommerceConfig;
|
||||
}): Promise<GetAllProductsResult<T>>;
|
||||
|
||||
async function getAllProducts({
|
||||
query = getAllProductsQuery,
|
||||
variables: vars,
|
||||
config = getConfig(),
|
||||
}: {
|
||||
query?: string;
|
||||
variables?: ProductVariables;
|
||||
config?: BigcommerceConfig;
|
||||
} = {}): Promise<GetAllProductsResult<GetAllProductsQuery>> {
|
||||
const config = getConfig();
|
||||
const variables: GetAllProductsQueryVariables = {
|
||||
...config.imageVariables,
|
||||
...vars,
|
||||
|
@ -4,7 +4,12 @@ import type {
|
||||
} from 'lib/bigcommerce/schema';
|
||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types';
|
||||
import { productInfoFragment } from '../fragments/product';
|
||||
import { getConfig, Images, ProductImageVariables } from '..';
|
||||
import {
|
||||
BigcommerceConfig,
|
||||
getConfig,
|
||||
Images,
|
||||
ProductImageVariables,
|
||||
} from '..';
|
||||
|
||||
export const getProductQuery = /* GraphQL */ `
|
||||
query getProduct(
|
||||
@ -45,21 +50,24 @@ export type ProductVariables = Images &
|
||||
async function getProduct(opts: {
|
||||
query?: string;
|
||||
variables: ProductVariables;
|
||||
config?: BigcommerceConfig;
|
||||
}): Promise<GetProductResult<GetProductQuery>>;
|
||||
|
||||
async function getProduct<T, V = any>(opts: {
|
||||
query: string;
|
||||
variables: V;
|
||||
config?: BigcommerceConfig;
|
||||
}): Promise<GetProductResult<T>>;
|
||||
|
||||
async function getProduct({
|
||||
query = getProductQuery,
|
||||
variables: vars,
|
||||
config = getConfig(),
|
||||
}: {
|
||||
query?: string;
|
||||
variables: ProductVariables;
|
||||
config?: BigcommerceConfig;
|
||||
}): Promise<GetProductResult<GetProductQuery>> {
|
||||
const config = getConfig();
|
||||
const variables: GetProductQueryVariables = {
|
||||
...config.imageVariables,
|
||||
...vars,
|
||||
|
Loading…
x
Reference in New Issue
Block a user