I'm using Quarkus GraphQL in my project. Defined a class with @GraphQLApi and a @Query method inside it. I'm not sure how to access the HttpHeaders in the defined method when querying a request. I tried @HeaderParam but I'm getting a null value. There isn't much about the headers in the quarkus documentation either. Is there a way to get the headers from the @Query methods?.
Asked
Active
Viewed 1,104 times
1 Answers
4
The GraphQL API itself does not currently offer access to HTTP headers, but you can inject an instance of CurrentVertxRequest
and read the headers from there:
@Inject
CurrentVertxRequest request;
// and in your query method:
request.getCurrent().request().getHeader("My-Header")

Jan Martiška
- 1,151
- 5
- 7
-
You can also inject `RoutingContext` directly. It is returned by the getCurrent method. – jspetrak Feb 06 '23 at 21:12