mercurius-integration-testing
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -10,8 +10,11 @@ /// <reference types="node" /> | ||
}; | ||
export declare type QueryOptions<TVariables = Record<string, any>> = { | ||
variables?: TVariables; | ||
export declare type QueryOptions<TVariables extends Record<string, unknown> | undefined = undefined> = { | ||
operationName?: string | null; | ||
headers?: IncomingHttpHeaders; | ||
cookies?: Record<string, string>; | ||
}; | ||
} & (TVariables extends object ? { | ||
variables: TVariables; | ||
} : { | ||
variables?: Record<string, any>; | ||
}); | ||
export declare function createMercuriusTestClient( | ||
@@ -46,3 +49,3 @@ /** | ||
* | ||
* @param query Query to be sent. It can be a `graphql-tag` or a string. | ||
* @param query Query to be sent. It can be a DocumentNode or string. | ||
* @param queryOptions Query specific options, including: | ||
@@ -54,7 +57,7 @@ * - variables | ||
*/ | ||
query: <TData extends Record<string, unknown> = Record<string, any>, TVariables extends Record<string, unknown> = Record<string, unknown>>(query: TypedDocumentNode<TData, TVariables> | DocumentNode | string, queryOptions?: QueryOptions<TVariables>) => Promise<GQLResponse<TData>>; | ||
query: <TData extends Record<string, unknown> = Record<string, any>, TVariables extends Record<string, unknown> | undefined = undefined>(query: TypedDocumentNode<TData, TVariables> | DocumentNode | string, ...queryOptions: TVariables extends object ? [QueryOptions<TVariables>] : [QueryOptions<TVariables>?]) => Promise<GQLResponse<TData>>; | ||
/** | ||
* Mutation function. | ||
* | ||
* @param mutation Mutation to be sent. It can be a `graphql-tag` or a string. | ||
* @param mutation Mutation to be sent. It can be a DocumentNode or string. | ||
* @param mutationOptions Query specific options, including: | ||
@@ -66,3 +69,3 @@ * - variables | ||
*/ | ||
mutate: <TData extends Record<string, unknown> = Record<string, any>, TVariables extends Record<string, unknown> = Record<string, unknown>>(mutation: TypedDocumentNode<TData, TVariables> | DocumentNode | string, mutationOptions?: QueryOptions<TVariables>) => Promise<GQLResponse<TData>>; | ||
mutate: <TData extends Record<string, unknown> = Record<string, any>, TVariables extends Record<string, unknown> | undefined = undefined>(mutation: TypedDocumentNode<TData, TVariables> | DocumentNode | string, ...mutationOptions: TVariables extends object ? [QueryOptions<TVariables>] : [QueryOptions<TVariables>?]) => Promise<GQLResponse<TData>>; | ||
/** | ||
@@ -103,9 +106,27 @@ * Set new global headers to this test client instance. | ||
*/ | ||
subscribe: <TData extends Record<string, unknown> = any, TVariables extends Record<string, unknown> | undefined = undefined>(opts: { | ||
query: string | DocumentNode; | ||
subscribe: <TData extends Record<string, unknown> = Record<string, any>, TVariables extends Record<string, unknown> | undefined = undefined>(opts: { | ||
/** | ||
* Subscription query, can be a DocumentNode or string | ||
*/ | ||
query: string | DocumentNode | TypedDocumentNode<TData, TVariables>; | ||
/** | ||
* Initial payload, usually for authorization | ||
*/ | ||
initPayload?: (() => Record<string, any> | Promise<Record<string, any>>) | Record<string, any>; | ||
/** | ||
* Subscription data function | ||
*/ | ||
onData(response: GQLResponse<TData>): void; | ||
/** | ||
* Subscription specific headers | ||
*/ | ||
headers?: IncomingHttpHeaders; | ||
/** | ||
* Subscription specific cookies | ||
*/ | ||
cookies?: Record<string, string>; | ||
operationName?: string; | ||
/** | ||
* query operationName | ||
*/ | ||
operationName?: string | null; | ||
} & (TVariables extends object ? { | ||
@@ -112,0 +133,0 @@ variables: TVariables; |
@@ -43,3 +43,5 @@ "use strict"; | ||
const url = opts.url || '/graphql'; | ||
const query = async (query, queryOptions = {}) => { | ||
const query = async (query, queryOptions = { | ||
variables: {}, | ||
}) => { | ||
await readyPromise; | ||
@@ -46,0 +48,0 @@ const { variables = {}, operationName = null, headers: querySpecificHeaders = {}, cookies: querySpecificCookies = {}, } = queryOptions; |
@@ -9,3 +9,3 @@ /// <reference types="node" /> | ||
variables: Record<string, unknown>; | ||
operationName: string | undefined; | ||
operationName: string | undefined | null; | ||
}; | ||
@@ -62,4 +62,4 @@ handler: (data: unknown) => Promise<void>; | ||
payload: any; | ||
}) => void | Promise<void>, operationName?: string, connectionInit?: Record<string, any>): Promise<void>; | ||
}) => void | Promise<void>, operationName?: string | null, connectionInit?: Record<string, any>): Promise<void>; | ||
} | ||
export {}; |
{ | ||
"name": "mercurius-integration-testing", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35956
668