Start containers with compose file in folder "docker":
docker-compose up
Access graphiql via your browser:
http://localhost:8080
This project is a boilerplate for using Spring Boot with GraphQL. It uses a docker container with mariadb as database backend for testing.
Based on:
- Spring Boot 2
- GraphQL Spring Boot starter
Installed docker daemon on local system.
- Java8 JDK
- Apache Maven
The backend spring boot application runs inside an openjdk container.
The database for this project runs inside a docker container. You can have a look on the schema in initial sql script file.
Do not run this container in a production enviroment!
Run docker-compose up
and don't forget to delete the container after you finished: docker-compose rm
and docker rmi -f docker_graphql_backend
.
For Linux just run the following:
docker-compose up && docker-compose rm && docker rmi -f docker_graphql_backend
You can access GraphiQL testconsole from:
http://localhost:8080/graphiql/
In the graphql schema-file (schema.graphqls) you can see what functions are available via graphQL
Example (get all categories with links).
Example 2 (get all links with category):
query {
getLinks {
Name
Url
Category {
Name
}
}
}
Example (add a new link). This query returns the saved link if everything works correctly.
mutation {
addLink(
Name:"NewLink"
Url:"https://myURL.com"
CategoryId:3
) {
Name,
Id
}
}
Example (update the name of a link based on the id). This query returns the modified link if everything works correctly.
mutation {
updateLink(
Id:1
Name:"New Website Name"
) {
Name
Id
}
}