Skip to content

Commit c211170

Browse files
committed
Update docs
1 parent 146b1ad commit c211170

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,18 @@ Works for any nested selections (data) and any nested inputs (variables).
274274
It will include `__typename` in data by default. This can be deactivated as an option:
275275

276276
```js
277-
apolloMock(documentNode, variables, data, { addTypename: false });
277+
apolloMock(documentNode, variables, result, { addTypename: false });
278278
```
279279

280280
When used together with `codegenTypedDocuments` the data and variables are type checked (type inference).
281281

282+
To mock errors, you can provide `errors` in `result` (`GraphQLError`) or pass an `Error` instead of `result`:
283+
284+
```js
285+
apolloMock(documentNode, variables, { errors: [new GraphQLError("Already exists")] });
286+
apolloMock(documentNode, variables, new Error("Network error"));
287+
```
288+
282289
### Install
283290

284291
```sh

0 commit comments

Comments
 (0)