An intermediate GraphQL Java program where the schema is defined by a hybrid of the SDL file and programmatically in Java code.
Follow these instructions to build and run the program.
- Pre-requisite: Java 21
- Build the program distribution:
-
./gradlew :cli:installDist
-
- Run the program:
-
cli/build/install/cli/bin/cli ' { javaInfo(component: VERSION) }'
- It should print something like this:
23:24:52 [main] INFO dgroomes.graphql.GraphqlUtil - {javaInfo=The Java version is: 21.0.3}
-
- Alias the build and run commands for happier development:
-
alias go="./gradlew :cli:installDist && cli/build/install/cli/bin/cli"
- For example, try the following command to build and run the program in one short step.
-
go ' { javaInfo(component: RUNTIME_MODE) }'
-
- Try one of the dynamic Java components:
-
go ' { javaInfo(component: PACKAGE_ORG_SLF4J) }'
- It should print out all the classes in the
org.slf4jpackage. ThePACKAGE_ORG_SLF4Jenum value was defined programmatically at runtime. In other words,PACKAGE_ORG_SLF4Jis not defined in the SDL fileschema.graphqls! The ability to define the GraphQL schema partly in a static SDL file and partly at runtime showcases GraphQL andgraphql-java's flexibility. Pretty neat! The response will look something like the following. -
18:06:59 [main] INFO dgroomes.graphql.GraphqlUtil - {javaInfo=org.slf4j.ILoggerFactory org.slf4j.IMarkerFactory org.slf4j.Logger org.slf4j.LoggerFactory org.slf4j.MDC org.slf4j.MDC$MDCCloseable ... omitted...
-