A simple GraphQL server with queries that allow the easy testing of your GraphQL clients.
Motivation: wildmountainfarms/wild-graphql-datasource#10
- https://docs.spring.io/spring-boot/reference/web/spring-graphql.html
- You will use this: https://start.spring.io/
- Building container images: https://docs.spring.io/spring-boot/reference/packaging/container-images/index.html
- Language: I knew I wanted to build this with Java or Kotlin, as they are the languages I most enjoy working with. I chose Java because I wanted to experiment with all the feature so of modern Java versions.
- Framework: Spring is the obvious choice, but what to put on top of it?
- DGS (by Netflix) - the first working version of GraphQL Echo uses this. I chose it because it had codegen support
- I chose not to use this because its codegen support was not as good as I had hoped, and DGS feels kind of deprecated in favor of Spring for GraphQL.
- If I needed a client library, I probably would have chosen to use this and its codegen support
- Spring for GraphQL - great integration with Spring and well supported
- DGS (by Netflix) - the first working version of GraphQL Echo uses this. I chose it because it had codegen support
Install plugins:
- https://plugins.jetbrains.com/plugin/17852-dgs
- https://plugins.jetbrains.com/plugin/22807-spring-graphql
Building the project is as simple as understanding what Gradle tasks you need to call. Typically, you might want to test building the docker image. You can build the docker image like so:
./gradlew bootBuildImage -Pplatform=linux/amd64Note that you may need to run these commands for multiplatform building:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch-builder --use --bootstrap --driver docker-container
# Confirm available platforms with:
docker buildx inspect --bootstrapTo combine the images, play around with docker manifest create.
# This command is used as a reference, and not something for you to run exactly as is
# https://docs.docker.com/reference/cli/docker/manifest/#working-with-insecure-registries
# Note --insecure is required whenever any image ref is pointing to a http registry
# Note that each image reference will be referred to via its registry, so you cannot reference local images here
# Note that all image references must be from the same registry
docker manifest create --insecure localhost:5000/asdf/asdf:latest --amend localhost:5000/asdf/asdf:arm --amend localhost:5000/asdf/asdf:amd- Run
GraphQLEchoApplicationin IntelliJ, or run the:app:bootRungradle task in your terminal - Navigate to http://localhost:8080/graphiql?path=/graphql to test the endpoint
https://gradle.org/releases/
# replace 9.0.0 with your desired version
./gradlew wrapper --gradle-version=9.0.0 && ./gradlew wrapper