Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extensions to the response map #94

Open
jamhall opened this issue Dec 4, 2016 · 4 comments
Open

Add extensions to the response map #94

jamhall opened this issue Dec 4, 2016 · 4 comments
Assignees
Milestone

Comments

@jamhall
Copy link

jamhall commented Dec 4, 2016

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?

@viniychuk
Copy link
Member

@jamhall I love it! Will absolutely do :)

@jamhall
Copy link
Author

jamhall commented Dec 4, 2016

@viniychuk - Awesome! Look forward to using it :)

@StymiedSloth
Copy link

+1 ...
This would be super helpful. Looking forward to it

@viniychuk viniychuk self-assigned this Dec 12, 2016
@viniychuk viniychuk modified the milestone: Execution Context + Configs Dec 12, 2016
@clintburgos
Copy link

+1
Also looking forward to using this.

@viniychuk viniychuk modified the milestones: Execution Context + Configs, 1.6 — Directives & Extensions Oct 20, 2017
@portey portey self-assigned this Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants