Search code examples
graphqljava-ee-6quarkussmallrye

Quarkus GraphQL: How to change the default endpoint?


I am using the dependency as shown below in a Quarkus application. Default the endpoint is /graphql. But since I am running this application in a k8s environment behind a ingress, this is not ideal. Anyone has an idea how to change this default endpoint to something like: /<service-name>/graphql?

<dependency>
  <groupId>io.smallrye</groupId>
  <artifactId>smallrye-graphql-servlet</artifactId>
  <version>1.0.1</version>
</dependency>

Solution

  • If you're using the SmallRye GraphQL extension, you can control the endpoint path using application.properties:

    quarkus.smallrye-graphql.root-path=/my-path-to-graphql                                                                                                                                                                        
    

    You can also use variables (with ${variableName} syntax) in the value, so you can inject your service name there.

    But to be using that extension you need to adjust the dependency to

       <dependency>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-smallrye-graphql</artifactId>
        </dependency>
    

    Note that it's only available since Quarkus 1.5.0.