Spring Boot GraphQL Tutorial #2 - Creating your first Schema and Query

Опубликовано: 25 Октябрь 2024
на канале: Philip Starritt
46,420
305

Its time to create your first schema!

Here I give an overview of the graphql-java-tools library which allows you to use the graphql schema language to build a graphql schema. This library takes a schema first approach and allows us to bring our own java object (matching the schema types) to fill in the implementation. This approach allows us to have complete control over the schema and have a good overview of what types are available.

Graphql tools by default will look for all **/*.graphqls files on the classpath and it will automatically combine and compile them into one graphql schema at application runtime. This is available at localhost:port/graphql/schema.json.

We then create our first graphql schema file with root type query.
Then we create a matching GraphqlQueryResolver which will match the root queries.
We then start graphql playground to view and play with our first graphql query.

Cheers!
Philip

links:

GraphQL Playground: https://github.com/prisma-labs/graphq...

GraphQL Java tools: https://github.com/graphql-java-kicks...

Graphql Java Kickstarter repository: https://github.com/graphql-java-kicks...

GraphQL Spring Boot: https://github.com/graphql-java-kicks...

GraphQL Java: https://github.com/graphql-java/graph...

Spring Boot: https://spring.io/projects/spring-boot