22 lines
1.1 KiB
Markdown
22 lines
1.1 KiB
Markdown
# Adding a new endpoint
|
|
|
|
1. Create a new `<endpoint>API` class in [api](api).
|
|
* Make sure to correctly add the appropriate JSON and GraphQL annotations.
|
|
Look at other classes for examples.
|
|
* **NOTE:** If anything returned could be null, make sure to instead provide an appropriate zero-value property,
|
|
otherwise GraphQL will choke.
|
|
See [PluginAPI::new](api/PluginAPI.java) for an example.
|
|
2. Add a method to return the needed data to [IProvider](IProvider.java).
|
|
3. Add a new REST endpoint to the [Web::start](Web.java) method.
|
|
4. Add a new GraphQL method to [GraphQL](GraphQL.java)
|
|
* Make sure to correctly add the appropriate GraphQL annotation.
|
|
5. Modify both [ServerAPI](../ServerAPI.java)
|
|
and [MockProvider](../../../../../../test/java/xyz/etztech/serverapi/MockProvider.java)
|
|
to fulfill the [IProvider](IProvider.java) interface.
|
|
|
|
# Testing
|
|
|
|
[ServerRunner](../../../../../../test/java/xyz/etztech/serverapi/ServerRunner.java) should start up the API using
|
|
[MockProvider](../../../../../../test/java/xyz/etztech/serverapi/MockProvider.java).
|
|
|
|
If possible, a real test on a running Minecraft server would ideal! |