From 81b9aa9e2b27bbd4880af36fc3dfe0932cb09c9e Mon Sep 17 00:00:00 2001 From: feinoujc Date: Tue, 12 Feb 2019 14:58:38 -0500 Subject: [PATCH] [apollo-server-testing] add complete typing for ...rest args fixes #2172 --- packages/apollo-server-testing/CHANGELOG.md | 2 ++ packages/apollo-server-testing/src/createTestClient.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/apollo-server-testing/CHANGELOG.md b/packages/apollo-server-testing/CHANGELOG.md index a64c146b38f..f892c0ed3ee 100644 --- a/packages/apollo-server-testing/CHANGELOG.md +++ b/packages/apollo-server-testing/CHANGELOG.md @@ -2,4 +2,6 @@ ### vNEXT +* Add variables prop to Query and Mutation types. Fixes #2172 + * `apollo-server-testing`: Added createTestClient function diff --git a/packages/apollo-server-testing/src/createTestClient.ts b/packages/apollo-server-testing/src/createTestClient.ts index 9a4c78ad907..b8ee4c02121 100644 --- a/packages/apollo-server-testing/src/createTestClient.ts +++ b/packages/apollo-server-testing/src/createTestClient.ts @@ -1,6 +1,8 @@ import { ApolloServerBase } from 'apollo-server-core'; import { print, DocumentNode } from 'graphql'; +type Omit = Pick>; + type StringOrAst = string | DocumentNode; // A query must not come with a mutation (and vice versa). @@ -9,7 +11,12 @@ type Mutation = { mutation: StringOrAst; query?: undefined }; export default (server: ApolloServerBase) => { const executeOperation = server.executeOperation.bind(server); - const test = ({ query, mutation, ...args }: Query | Mutation) => { + const test = ({ + query, + mutation, + ...args + }: (Query | Mutation) & + Omit[0], 'query'>) => { const operation = query || mutation; if (!operation || (query && mutation)) {