diff --git a/docs/source/api/apollo-server.md b/docs/source/api/apollo-server.md index 36fdc322e0c..26de3c21e7f 100644 --- a/docs/source/api/apollo-server.md +++ b/docs/source/api/apollo-server.md @@ -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`>