Add extensions to the response map
The GraphQL specification states:
The response map may also contain an entry with key extensions. This entry, if set, must have a map as its value. This entry is reserved for implementors to extend the protocol however they see fit, and hence there are no additional restrictions on its contents.
express-graphql gives a good use case in their README.
The example they give is to use the extensions field for adding the amount of time consumed by running the provided query, which could perhaps be used by your development tools.
app.use('/graphql', graphqlHTTP(request => {
const startTime = Date.now();
return {
schema: MyGraphQLSchema,
graphiql: true,
extensions({ document, variables, operationName, result }) {
return { runTime: Date.now() - startTime };
}
};
}));
When querying this endpoint, it would include this information in the result, for example:
{
"data": { ... }
"extensions": {
"runTime": 135
}
}
What do you think of implementing this into this project?
@jamhall I love it! Will absolutely do :)
@viniychuk - Awesome! Look forward to using it :)
+1 ... This would be super helpful. Looking forward to it
+1 Also looking forward to using this.