A simple GraphQL Java program where the schema is defined in a Schema Definition Language (SDL) file.
This is an "echo" program that echoes a message back to you, but with some flair! Read the source code to learn more.
Follow these instructions to build and run the app:
- Pre-requisite: Java 21
- Build the app:
-
./gradlew installDist
-
- Build and run the app:
-
build/install/sdl/bin/sdl ' { echo(message: "hello world!", echoFlavor: LOUD) }'
- You should notice that the "hello world!" message got echoed back in a loud way!
-
- Alias the build and run commands for happier development:
-
alias go="./gradlew installDist && build/install/sdl/bin/sdl"
- For example, try the following command to build and run the program in one short step.
-
go ' { echo(message: "hello world!", echoFlavor: LOUD) }'
- Next, try the
NORMAL
echo flavor. -
go ' { echo(message: "anyone there?", echoFlavor: NORMAL) }'
-
- DONE Write a simple GraphQL Java program that uses GraphQL Java
- Write the GraphQL schema file
- Write the GraphQL boilerplate code
- DONE Example requests
- This is an illustrative program that should be invoked from the command line. Make some example GraphQL requests by passing them as string arguments to the program.
While GraphQL is usually implemented in a web services context, there's no stopping you from using it another context like a CLI or a desktop application.