-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apollo-server-testing createTestClient types #2172
Comments
It would be great if the query<T, TVariables = OperationVariables>(options: QueryOptions<TVariables>): Promise<ApolloQueryResult<T>>; |
As a workaround, you can add a declare module 'apollo-server-testing' {
import { ApolloServerBase } from 'apollo-server-core';
import { print, DocumentNode } from 'graphql';
import { GraphQLResponse } from 'graphql-extensions';
type StringOrAst = string | DocumentNode;
// A query must not come with a mutation (and vice versa).
type Query<TVariables> = {
query: StringOrAst;
mutation?: undefined;
variables?: TVariables;
};
type Mutation<TVariables> = {
mutation: StringOrAst;
query?: undefined;
variables?: TVariables;
};
export const createTestClient: <TVariables>(
server: ApolloServerBase,
) => {
query: (query: Query<TVariables>) => Promise<GraphQLResponse>;
mutate: (mutation: Mutation<TVariables>) => Promise<GraphQLResponse>;
};
} |
feinoujc
added a commit
to feinoujc/apollo-server
that referenced
this issue
Feb 12, 2019
feinoujc
added a commit
to feinoujc/apollo-server
that referenced
this issue
Feb 12, 2019
4 tasks
feinoujc
added a commit
to feinoujc/apollo-server
that referenced
this issue
Feb 16, 2019
feinoujc
added a commit
to feinoujc/apollo-server
that referenced
this issue
Feb 20, 2019
Merged
feinoujc
added a commit
to feinoujc/apollo-server
that referenced
this issue
Apr 13, 2019
feinoujc
added a commit
to feinoujc/apollo-server
that referenced
this issue
Apr 17, 2019
abernix
pushed a commit
that referenced
this issue
Apr 25, 2019
* [apollo-server-testing] add complete typing for ...rest args fixes #2172 * simpler type definition * Update CHANGELOG.md * Update CHANGELOG.md
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Writing the below in typescript complains with
'variables' does not exist in type 'Query | Mutation'
Looking in
createTestClient.ts
shows thatclient.query
is writtenwith
As it is currently written
args
is later passed through correctly toserver.executeOperation
, however the typings imply that args can only ever be an empty object when in fact it should allow the following additional fields (from the interfaceGraphQLRequest
inrequestPipelineAPI.ts
)It may be a good idea to implement it like this
So as to be less coupled to any changes to
GraphQLRequest
The text was updated successfully, but these errors were encountered: