From a7eed7fe888b124fa93258cbf10dfcad9f6afa16 Mon Sep 17 00:00:00 2001 From: Andrew Schmadel Date: Mon, 17 Jun 2019 17:16:49 -0400 Subject: [PATCH 1/3] add typings for test client --- packages/apollo-server-testing/src/createTestClient.ts | 9 +++++++-- packages/apollo-server-testing/src/index.ts | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/apollo-server-testing/src/createTestClient.ts b/packages/apollo-server-testing/src/createTestClient.ts index 616f7f66f42..d2814ff7ddd 100644 --- a/packages/apollo-server-testing/src/createTestClient.ts +++ b/packages/apollo-server-testing/src/createTestClient.ts @@ -1,4 +1,4 @@ -import { ApolloServerBase } from 'apollo-server-core'; +import { ApolloServerBase, GraphQLResponse } from 'apollo-server-core'; import { print, DocumentNode } from 'graphql'; type StringOrAst = string | DocumentNode; @@ -21,7 +21,12 @@ type Mutation = { operationName?: string; }; -export default (server: ApolloServerBase) => { +export interface ApolloServerTestClient { + query: (query: Query) => Promise; + mutate: (mutation: Mutation) => Promise; +} + +export default (server: ApolloServerBase): ApolloServerTestClient => { const executeOperation = server.executeOperation.bind(server); const test = ({ query, mutation, ...args }: Query | Mutation) => { const operation = query || mutation; diff --git a/packages/apollo-server-testing/src/index.ts b/packages/apollo-server-testing/src/index.ts index acd8c5f2b2b..acb7619a674 100644 --- a/packages/apollo-server-testing/src/index.ts +++ b/packages/apollo-server-testing/src/index.ts @@ -1 +1,4 @@ -export { default as createTestClient } from './createTestClient'; +export { + default as createTestClient, + ApolloServerTestClient, +} from './createTestClient'; From 7179745899b9dda23908dd663f5492046cdf7247 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Tue, 25 Jun 2019 20:51:47 +0300 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4ac243c72c..0930a5c04a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ - `apollo-engine-reporting`: Set `forbiddenOperation` and `registeredOperation` later in the request lifecycle [PR #2828](https://github.com/apollographql/apollo-server/pull/2828) - `apollo-server-core`: Add queryHash to GraphQLExecutor for federation [PR #2822](https://github.com/apollographql/apollo-server/pull/2822) +- `apollo-server-testing` Add TypeScript types for `apollo-server-testing` client. [PR #2871](https://github.com/apollographql/apollo-server/pull/2871) + ### v2.6.2 - `apollo-engine-reporting-protobuf`: Update protobuff to include `forbiddenOperations` and `registeredOperations` [PR #2768](https://github.com/apollographql/apollo-server/pull/2768) From f38027ef03ac5b0d2467394dc60f327f32a0efb5 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Tue, 25 Jun 2019 20:52:40 +0300 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b15e15ce9a0..89d830f2b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The version headers in this history reflect the versions of Apollo Server itself > The changes noted within this `vNEXT` section have not been released yet. New PRs and commits which introduce changes should include an entry in this `vNEXT` section as part of their development. When a release is being prepared, a new header will be (manually) created below and the the appropriate changes within that release will be moved into the new section. - `apollo-server-core`: Avoid duplicate `cacheControl` directives being added via `isDirectiveDefined`. [PR #2762](https://github.com/apollographql/apollo-server/pull/2762) (was reverted in 2.6.1 because previous implementation released in 2.6.0 broke passing in typedefs as a string) +- `apollo-server-testing`: Add TypeScript types for `apollo-server-testing` client. [PR #2871](https://github.com/apollographql/apollo-server/pull/2871) ### v2.6.5 @@ -34,8 +35,6 @@ The version headers in this history reflect the versions of Apollo Server itself - `apollo-server-core`: Add `queryHash` to `GraphQLExecutor` for federation. [PR #2822](https://github.com/apollographql/apollo-server/pull/2822) - `@apollo/federation`: Preserve descriptions from SDL of federated services. [PR #2830](https://github.com/apollographql/apollo-server/pull/2830) -- `apollo-server-testing` Add TypeScript types for `apollo-server-testing` client. [PR #2871](https://github.com/apollographql/apollo-server/pull/2871) - ### v2.6.2 - `apollo-engine-reporting-protobuf`: Update protobuf to include `forbiddenOperations` and `registeredOperations`. [PR #2768](https://github.com/apollographql/apollo-server/pull/2768)