Accessing headers on Quarkus Graphql

1.3k Views Asked by At

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?.

1

There are 1 best solutions below

1
On BEST ANSWER

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")