Skip to content
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] add complete typing for ...rest args #2307

Merged
merged 5 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### vNEXT

- Allow `GraphQLRequestListener` callbacks in plugins to depend on `this`. [PR #2470](https://github.com/apollographql/apollo-server/pull/2470)
- `apollo-server-testing`: Add `variables` and `operationName` to `Query` and `Mutation` types. [PR #2307](https://github.com/apollographql/apollo-server/pull/2307) [Issue #2172](https://github.com/apollographql/apollo-server/issue/2172)
- `apollo-datasource-rest`: Correctly allow a TTL value of `0` to represent "not-cacheable". [PR #2588](https://github.com/apollographql/apollo-server/pull/2588)
- `apollo-datasource-rest`: Fix `Invalid argument` in IE11, when `this.headers` is `undefined`. [PR #2607](https://github.com/apollographql/apollo-server/pull/2607)

Expand Down
3 changes: 2 additions & 1 deletion packages/apollo-server-testing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

### vNEXT

* `apollo-server-testing`: Added createTestClient function
* `apollo-server-testing`: Add `variables` and `operationName` prop to `Query` and `Mutation` types. [PR #2307](https://github.com/apollographql/apollo-server/pull/2307) [Issue #2172](https://github.com/apollographql/apollo-server/issue/2172)
* `apollo-server-testing`: Added `createTestClient` function.
18 changes: 16 additions & 2 deletions packages/apollo-server-testing/src/createTestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@ import { print, DocumentNode } from 'graphql';
type StringOrAst = string | DocumentNode;

// A query must not come with a mutation (and vice versa).
type Query = { query: StringOrAst; mutation?: undefined };
type Mutation = { mutation: StringOrAst; query?: undefined };
type Query = {
query: StringOrAst;
mutation?: undefined;
variables?: {
[name: string]: any;
};
operationName?: string;
};
type Mutation = {
mutation: StringOrAst;
query?: undefined;
variables?: {
[name: string]: any;
};
operationName?: string;
};

export default (server: ApolloServerBase) => {
const executeOperation = server.executeOperation.bind(server);
Expand Down