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

How to get HTTP request headers? #156

Open
tuanlt2 opened this issue Jan 20, 2021 · 2 comments
Open

How to get HTTP request headers? #156

tuanlt2 opened this issue Jan 20, 2021 · 2 comments

Comments

@tuanlt2
Copy link

tuanlt2 commented Jan 20, 2021

I am using Micronaut GraphQL with Kickstart tool (https://github.com/graphql-java-kickstart/graphql-java-tools).
How can I get HTTP request headers in GraphQL resolvers?

@jamesdh
Copy link

jamesdh commented Feb 3, 2021

@tuanlt2 take a look at the GraphQLExecutionInputCustomizer interface.

@donbeave
Copy link
Contributor

@tuanlt2 please check jwt-security example: https://github.com/micronaut-projects/micronaut-graphql/tree/master/examples/jwt-security.

It uses custom GraphQLExecutionInputCustomizer implementation: https://github.com/micronaut-projects/micronaut-graphql/blob/bb9004086874f450e7f7502a3c16107c0346b7ae/examples/jwt-security/src/main/java/example/graphql/RequestResponseCustomizer.java

And after that inside the resolver, you can get the request object from the context:

HttpRequest httpRequest = graphQLContext.get("httpRequest");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants