CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-springframework-boot--spring-boot-starter-graphql

Starter for building GraphQL applications with Spring GraphQL

Pending
Overview
Eval results
Files

configuration-properties.mddocs/

Configuration Properties

Spring Boot GraphQL Starter provides extensive configuration options through Spring Boot's configuration properties mechanism. All properties use the spring.graphql prefix and support environment-specific overrides.

Main Configuration Class

@ConfigurationProperties("spring.graphql")
public class GraphQlProperties {
    private final Http http = new Http();
    private final Graphiql graphiql = new Graphiql();
    private final Rsocket rsocket = new Rsocket();
    private final Schema schema = new Schema();
    private final Websocket websocket = new Websocket();
    
    // Getters for all nested properties
    public Http getHttp() { return this.http; }
    public Graphiql getGraphiql() { return this.graphiql; }
    public Schema getSchema() { return this.schema; }
    public Websocket getWebsocket() { return this.websocket; }
    public Rsocket getRsocket() { return this.rsocket; }
}

HTTP Configuration

Configure HTTP endpoint settings and transport-specific options.

public static class Http {
    private String path = "/graphql";
    private final Sse sse = new Sse();
    
    public String getPath() { return this.path; }
    public void setPath(String path) { this.path = path; }
    public Sse getSse() { return this.sse; }
}

Configuration Examples

# HTTP endpoint path (default: /graphql)
spring.graphql.http.path=/api/graphql

# Server-Sent Events configuration
spring.graphql.http.sse.keep-alive=30s
spring.graphql.http.sse.timeout=60s

Server-Sent Events (SSE)

public static class Sse {
    private Duration keepAlive;
    private Duration timeout;
    
    public Duration getKeepAlive() { return this.keepAlive; }
    public void setKeepAlive(Duration keepAlive) { this.keepAlive = keepAlive; }
    public Duration getTimeout() { return this.timeout; }
    public void setTimeout(Duration timeout) { this.timeout = timeout; }
}

Schema Configuration

Control GraphQL schema loading, validation, and development features.

public static class Schema {
    private String[] locations = {"classpath:graphql/**/"};
    private String[] fileExtensions = {".graphqls", ".gqls"};
    private Resource[] additionalFiles = {};
    private final Inspection inspection = new Inspection();
    private final Introspection introspection = new Introspection();
    private final Printer printer = new Printer();
    
    // Getters and setters
    public String[] getLocations() { return this.locations; }
    public void setLocations(String[] locations) { this.locations = appendSlashIfNecessary(locations); }
    public String[] getFileExtensions() { return this.fileExtensions; }
    public void setFileExtensions(String[] fileExtensions) { this.fileExtensions = fileExtensions; }
    public Resource[] getAdditionalFiles() { return this.additionalFiles; }
    public void setAdditionalFiles(Resource[] additionalFiles) { this.additionalFiles = additionalFiles; }
}

Schema Loading Configuration

# Schema file locations (default: classpath:graphql/**/)
spring.graphql.schema.locations=classpath:schemas/,classpath:types/

# Supported file extensions (default: .graphqls, .gqls)
spring.graphql.schema.file-extensions=.graphqls,.gqls,.graphql

# Additional schema files
spring.graphql.schema.additional-files=classpath:extra-schema.graphqls

Schema Inspection

public static class Inspection {
    private boolean enabled = true;
    
    public boolean isEnabled() { return this.enabled; }
    public void setEnabled(boolean enabled) { this.enabled = enabled; }
}
# Enable schema-to-application mapping validation (default: true)
spring.graphql.schema.inspection.enabled=true

Schema Introspection

public static class Introspection {
    private boolean enabled = true;
    
    public boolean isEnabled() { return this.enabled; }
    public void setEnabled(boolean enabled) { this.enabled = enabled; }
}
# Enable field introspection at schema level (default: true)
# Disable in production for security
spring.graphql.schema.introspection.enabled=false

Schema Printer

public static class Printer {
    private boolean enabled = false;
    
    public boolean isEnabled() { return this.enabled; }
    public void setEnabled(boolean enabled) { this.enabled = enabled; }
}
# Enable schema printer endpoint at /graphql/schema (default: false)
spring.graphql.schema.printer.enabled=true

GraphiQL Configuration

Configure the built-in GraphiQL development interface.

public static class Graphiql {
    private String path = "/graphiql";
    private boolean enabled = false;
    
    public String getPath() { return this.path; }
    public void setPath(String path) { this.path = path; }
    public boolean isEnabled() { return this.enabled; }
    public void setEnabled(boolean enabled) { this.enabled = enabled; }
}

Configuration Examples

# Enable GraphiQL UI (default: false)
spring.graphql.graphiql.enabled=true

# GraphiQL endpoint path (default: /graphiql)
spring.graphql.graphiql.path=/graphql-ui

WebSocket Configuration

Configure WebSocket transport for GraphQL subscriptions.

public static class Websocket {
    private String path;
    private Duration connectionInitTimeout = Duration.ofSeconds(60);
    private Duration keepAlive;
    
    public String getPath() { return this.path; }
    public void setPath(String path) { this.path = path; }
    public Duration getConnectionInitTimeout() { return this.connectionInitTimeout; }
    public void setConnectionInitTimeout(Duration timeout) { this.connectionInitTimeout = timeout; }
    public Duration getKeepAlive() { return this.keepAlive; }
    public void setKeepAlive(Duration keepAlive) { this.keepAlive = keepAlive; }
}

Configuration Examples

# Enable WebSocket support by setting path
spring.graphql.websocket.path=/graphql-ws

# Connection initialization timeout (default: 60s)
spring.graphql.websocket.connection-init-timeout=30s

# Keep-alive interval for WebSocket connections
spring.graphql.websocket.keep-alive=10s

RSocket Configuration

Configure RSocket transport for GraphQL over RSocket.

public static class Rsocket {
    private String mapping;
    
    public String getMapping() { return this.mapping; }
    public void setMapping(String mapping) { this.mapping = mapping; }
}

Configuration Examples

# RSocket message handler mapping
spring.graphql.rsocket.mapping=graphql

CORS Configuration

Configure Cross-Origin Resource Sharing for GraphQL endpoints.

@ConfigurationProperties("spring.graphql.cors")
public class GraphQlCorsProperties {
    private List<String> allowedOrigins;
    private List<String> allowedOriginPatterns;
    private List<String> allowedHeaders;
    private List<String> allowedMethods;
    private List<String> exposedHeaders;
    private Boolean allowCredentials;
    private Duration maxAge;
    
    // Standard CORS configuration methods
    public CorsConfiguration toCorsConfiguration() {
        // Converts properties to Spring's CorsConfiguration
    }
}

CORS Configuration Examples

# CORS configuration for GraphQL endpoints
spring.graphql.cors.allowed-origins=http://localhost:3000,https://example.com
spring.graphql.cors.allowed-methods=GET,POST
spring.graphql.cors.allowed-headers=*
spring.graphql.cors.allow-credentials=true
spring.graphql.cors.max-age=3600

Deprecated Properties

Legacy Path Configuration

// Deprecated in Spring Boot 3.5.0
@DeprecatedConfigurationProperty(replacement = "spring.graphql.http.path", since = "3.5.0")
@Deprecated(since = "3.5.0", forRemoval = true)
public String getPath() {
    return getHttp().getPath();
}

Legacy SSE Configuration

@Deprecated(since = "3.5.1", forRemoval = true)
public static final class DeprecatedSse {
    @DeprecatedConfigurationProperty(replacement = "spring.graphql.http.sse.timeout", since = "3.5.0")
    @Deprecated(since = "3.5.0", forRemoval = true)
    public Duration getTimeout() {
        return this.sse.getTimeout();
    }
}

Environment-Specific Configuration

Development Configuration

# application-dev.yml
spring:
  graphql:
    http:
      path: /graphql
    graphiql:
      enabled: true
      path: /graphiql
    schema:
      inspection:
        enabled: true
      introspection:
        enabled: true
      printer:
        enabled: true
    websocket:
      path: /graphql-ws
      keep-alive: 30s

Production Configuration

# application-prod.yml
spring:
  graphql:
    http:
      path: /api/graphql
      sse:
        timeout: 30s
        keep-alive: 15s
    graphiql:
      enabled: false
    schema:
      inspection:
        enabled: false
      introspection:
        enabled: false
      printer:
        enabled: false
    cors:
      allowed-origins: 
        - https://app.example.com
        - https://admin.example.com
      allowed-methods: POST
      allow-credentials: true
      max-age: 3600

Configuration Validation

The starter validates configuration properties at startup:

  • Schema locations must be valid resource patterns
  • File extensions must start with a dot
  • Timeout and duration values must be positive
  • CORS configuration must be complete if specified

Invalid configurations result in clear error messages during application startup.

Integration with Spring Boot Features

Actuator Integration

# Expose GraphQL endpoint info via actuator
management.endpoints.web.exposure.include=health,info,graphql
management.endpoint.graphql.enabled=true

Configuration Metadata

The starter provides configuration metadata for IDE autocompletion and validation:

{
  "properties": [
    {
      "name": "spring.graphql.http.path",
      "type": "java.lang.String",
      "description": "Path at which to expose a GraphQL request HTTP endpoint.",
      "defaultValue": "/graphql"
    }
  ]
}

This enables rich IDE support with autocompletion, validation, and documentation tooltips.

Install with Tessl CLI

npx tessl i tessl/maven-org-springframework-boot--spring-boot-starter-graphql

docs

configuration-properties.md

core-infrastructure.md

data-integration.md

index.md

observability-integration.md

security-integration.md

testing-support.md

transport-support.md

web-integration.md

tile.json