forked from crowetic/commerce
33 lines
801 B
TypeScript
33 lines
801 B
TypeScript
export interface CommerceAPIConfig {
|
|
commerceUrl: string
|
|
apiToken: string
|
|
cartCookie: string
|
|
cartCookieMaxAge: number
|
|
fetch<Data = any, Variables = any>(
|
|
query: string,
|
|
queryData?: CommerceAPIFetchOptions<Variables>,
|
|
fetchOptions?: RequestInit
|
|
): Promise<GraphQLFetcherResult<Data>>
|
|
}
|
|
|
|
export type GraphQLFetcher<
|
|
Data extends GraphQLFetcherResult = GraphQLFetcherResult,
|
|
Variables = any
|
|
> = (
|
|
query: string,
|
|
queryData?: CommerceAPIFetchOptions<Variables>,
|
|
fetchOptions?: RequestInit
|
|
) => Promise<Data>
|
|
|
|
export interface GraphQLFetcherResult<Data = any> {
|
|
data: Data
|
|
res: Response
|
|
}
|
|
|
|
export interface CommerceAPIFetchOptions<Variables> {
|
|
variables?: Variables
|
|
preview?: boolean
|
|
}
|
|
|
|
// TODO: define interfaces for all the available operations and API endpoints
|