This is an example of how to use the Warhorn API in a Java application.
This example clears a Warhorn event registration to sign up for games. At the discretion of the caller, it can also assign an event role to the registration. The example shows how to use GraphQL queries and mutations to read and write data through the API.
$ ./gradlew build
BUILD SUCCESSFUL in 309ms
7 actionable tasks: 7 up-to-date
Yes, this did actually run the tests!
Before running the program, you must store a Warhorn API access token in the WARHORN_API_TOKEN
environment variable.
The command line arguments are as follows:
slug
: the unique identifier for the event (found in Warhorn event page URLs)email
: the email address of the user whose registration you want to findrole
: the name of an event role to assign to the registration (optional)
Note that the app is actually run by Gradle. It requires you to wrap this program's command line arguments in an --args
command line argument of its own. Also note that you need to wrap this program's arguments in double quotes. See the example below.
$ export WARHORN_API_TOKEN=<your API token>
$ ./gradlew run --args "test-event text@example.com GM"
> Task :app:run
✅ An active, uncleared registration was found for test@example.com at Test Event.
✅ The registration was cleared for signup.
✅ The GM role was assigned to the registration.
BUILD SUCCESSFUL in 2s
3 actionable tasks: 1 executed, 2 up-to-date
The GraphQL code in this repository is a simplified "extract" from GraphQL Spring Webclient. Many thanks to the contributors!
I chose not to use that library directly because I'm not working in a Spring Boot context and I didn't want to drag along all of that baggage. Understanding and reproducing a streamlined version of the original work was also a nice way to dip my toe back into Java after 10+ years off.