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