Skip to content

Commit f26091c

Browse files
committed
Update README
1 parent 0cfc09d commit f26091c

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const { query, mutate } = createTestClient({
2121
apolloServer
2222
});
2323

24-
const response = await query(`{ currentUser { id } }`);
24+
const response = await query({
25+
query: `{ currentUser { id } }`
26+
});
2527

2628
expect(response.statusCode).toEqual(200);
2729

@@ -44,7 +46,8 @@ const UPDATE_USER = `
4446
}
4547
`;
4648

47-
const mutationResponse = await mutate(UPDATE_USER, {
49+
const mutationResponse = await mutate({
50+
mutation: UPDATE_USER,
4851
variables: { id: 1, email: 'nancy@foo.co' }
4952
});
5053

@@ -65,12 +68,12 @@ This allows you to test all the logic of your apollo server, including any logic
6568
### Mocking the `Request` object
6669

6770
`createTestClient` automatically mocks the `Request` object that will be passed to the `context` option of your `ApolloServer` constructor, so testing works out of the box.
68-
You can also extend the mocked Request object with additional keys by passing an `extendMockRequest` field to `createTestClient`:
71+
You can also extend the mocked Request object with additional keys by passing a `requestOptions` parameter to `createTestClient`:
6972

7073
```js
7174
const { query } = createTestClient({
7275
apolloServer,
73-
extendMockRequest: {
76+
requestOptions: {
7477
headers: {
7578
cookie: 'csrf=blablabla',
7679
referer: ''
@@ -81,7 +84,7 @@ const { query } = createTestClient({
8184

8285
This is useful when your apollo server `context` option is a callback that operates on the passed in `req` key, and you want to inject data into that `req` object.
8386

84-
As mentioned above, if you don't pass an `extendMockRequest` to `createTestClient`, we provide a default request mock object for you.
87+
As mentioned above, if you don't pass a `requestOptions` object to `createTestClient`, we provide a default request mock object for you.
8588

8689
### setOptions
8790

@@ -94,7 +97,7 @@ const { query, setOptions } = createTestClient({
9497

9598
setOptions({
9699
// If "request" is not specified, it's not modified
97-
request: {
100+
requestOptions: {
98101
headers: {
99102
cookie: 'csrf=blablabla',
100103
referer: ''
@@ -140,6 +143,6 @@ This package should work for consumers using `apollo-server-fastify`.
140143

141144
To issue a new release run `yarn release`.
142145

143-
## Acknowledgments
146+
## Acknowledgements
144147

145148
This project is inspired by <https://github.com/zapier/apollo-server-integration-testing>.

0 commit comments

Comments
 (0)