how to build an application with light-4j that supports both Rest and GraphQL

217 Views Asked by At

I am building a new Rest service with several endpoints and also want to support GraphQL endpoint in the same instance, it is possible to do that with Light-4j?

1

There are 1 best solutions below

0
Steve Hu On

In the handler.yml, you can define two chains of middleware handlers. One for REST endpoints and one for GraphQL endpoints.

Here is one example that has two chains defined.

https://github.com/networknt/light-config-test/blob/master/light-router/local-portal/config/handler.yml

In fact, for all the GraphQL example, there are two Rest endpoints generated from the light-codegen for server info and health check.

Take a look at this example and you can add more Rest endpoints.

https://github.com/networknt/light-example-4j/blob/release/graphql/mutation-idl/src/main/resources/config/handler.yml