ServerAPI/src/main/java/xyz/etztech/serverapi/web/README.md

1.1 KiB

Adding a new endpoint

  1. Create a new <endpoint>API class in 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 for an example.
  2. Add a method to return the needed data to IProvider.
  3. Add a new REST endpoint to the Web::start method.
  4. Add a new GraphQL method to GraphQL
    • Make sure to correctly add the appropriate GraphQL annotation.
  5. Modify both ServerAPI and MockProvider to fulfill the IProvider interface.

Testing

ServerRunner should start up the API using MockProvider.

If possible, a real test on a running Minecraft server would ideal!