Skip to content

Commit

Permalink
Add API docs for rootValue
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed Aug 21, 2018
1 parent 7243787 commit ecbe10a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/source/api/apollo-server.md
Expand Up @@ -51,6 +51,21 @@ new ApolloServer({
authScope: getScope(req.headers.authorization)
}),
});
```

* `rootValue`: <`Any`> | <`Function`>

A value or function called with the parsed `Document`, creating the root value passed to the graphql executor. The function is useful if you wish to provide a different root value based on the query operation type.

```js
new ApolloServer({
typeDefs,
resolvers,
rootValue: (documentAST) => ({
const op = getOperationAST(documentNode)
return op === 'mutation' ? mutationRoot : queryRoot;
})
});
```

* `mocks`: <`Object`> | <`Boolean`>
Expand Down

0 comments on commit ecbe10a

Please sign in to comment.