Table of Contents
- Intro
- Requirements and Downloads
- Enable GraphQL Servlet
- Enable GraphiQL
- Supported GraphQL-Java Libraries
- Contributions
- Licenses
Repository contains:
graphql-spring-boot-starterto turn your boot application into GraphQL server (see graphql-java-servlet)graphiql-spring-boot-starterto embedGraphiQLtool for schema introspection and query debugging (see graphiql)
Requirements:
- Java 1.8
- Spring Framework Boot > 1.3.x (web)
Gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.graphql-java:graphql-spring-boot-starter:3.6.0'
// to embed GraphiQL tool
compile 'com.graphql-java:graphiql-spring-boot-starter:3.6.0'
}Maven:
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>3.6.0</version>
</dependency>
<!-- to embed GraphiQL tool -->
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphiql-spring-boot-starter</artifactId>
<version>3.6.0</version>
</dependency>The servlet becomes accessible at /graphql if graphql-spring-boot-starter added as a dependency to a boot application.
A GraphQL schema is automatically discovered based on which graphql-java schema libraries are currently on the classpath.
See the graphql-java-servlet usage docs for the avaiable endpoints exposed.
Available Spring Boot configuration parameters (either application.yml or application.properties):
graphql:
servlet:
mapping: /graphql
enabled: true
corsEnabled: trueBy default a global CORS filter is enabled for /graphql/** context.
The corsEnabled can be set to false to disable it.
GraphiQL becomes accessible at the root /graphiql if graphiql-spring-boot-starter is added as a dependency to a boot application.
Note that GraphQL server must be available at /graphql/* context to be discovered by GraphiQL.
Available Spring Boot configuration parameters (either application.yml or application.properties):
graphiql:
mapping: /graphiql
enabled: trueThe following libraries have auto-configuration classes for creating a GraphQLSchema.
https://github.com/graphql-java/graphql-java-tools
All GraphQLResolver and GraphQLScalar beans, along with a bean of type SchemaParserDictionary (to provide all other classes), will be used to create a GraphQLSchema. Any files on the classpath named *.graphqls will be used to provide the schema definition. See the Readme for more info.
https://github.com/oembedler/spring-graphql-common
See the Readme for usage instructions.
graphql:
spring-graphql-common:
clientMutationIdName: clientMutationId
injectClientMutationId: true
allowEmptyClientMutationId: false
mutationInputArgumentName: input
outputObjectNamePrefix: Payload
inputObjectNamePrefix: Input
schemaMutationObjectName: Mutation
Contributions are welcome. Please respect the Code of Conduct.
graphql-spring-boot-starter and graphiql-spring-boot-starter are licensed under the MIT License. See LICENSE for details.