'GraphQL Java: Graphql Java with springboot not loading the playground at http://localhost:3001/playground

I have a java spring boot graphql project.

My dependencies in the pom.xml:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.graphql-java-kickstart</groupId>
            <artifactId>graphql-spring-boot-starter</artifactId>
            <version>12.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.graphql-java-kickstart</groupId>
            <artifactId>playground-spring-boot-starter</artifactId>
            <version>5.10.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

When i run the application and visit http://localhost:3001/playground i get an empty page saying

"Loading GraphQL Playground"

What may be possibly my problem here.



Solution 1:[1]

You can use only this dependency for graphQL playground interfaces and remove the playground-spring-boot-starter:

<dependency>
        <groupId>com.graphql-java-kickstart</groupId>
        <artifactId>graphql-spring-boot-starter</artifactId>
        <version>12.0.0</version>
</dependency>

In your application.yml you need to explicit set the static path for interface files (the path is /vendor/playground/):

static-path:
  base: <YOUR-CONTEXT-PATH>/vendor/playground/

Here is a example of some options to enable GraphQL playground, notice that the context-path here is /api:

graphql:
  playground:
    endpoint: /graphql
    subscriptionEndpoint: /subscriptions
    enabled: true
    pageTitle: Playground
    cdn:
      enabled: false
      version: latest
    static-path:
      base: /api/vendor/playground/

I had the same issue and the settings above worked for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Allan Nobre