Open
Description
Hello! 😊
I was trying to use the MockedProvider
to test a connected component. However, there's no way for me to use the variables from the query to generate a dynamic response. Would it be possible to add this feature for the mock provider?
Alternatively, the mock
prop can be a object with a signature like....
// This is probably an incorrect typed definition :)
{
callback: (
request: DocumentNode | TypedDocumentNode<TData, TVariables>,
variables?: TVariables,
addTypeName?: boolean,
) => {
result?: FetchResult<TData>,
error?: ApolloError
},
delay?: number |
(
(request?: DocumentNode | TypedDocumentNode<TData, TVariables>,
variables?: { [key: string]: any }) => number)
} |
ReadonlyArray<MockedResponse>
It will use the request and its variables to create a dynamic server response. If provided, it would also delay the response by number of milliseconds specified by the delay
. If delay
is a callback, it will calculate the delay amount using the request
and variables
for each request.
Activity