Knotx / knotx-example-project

Example Project contains samples of various Knot.x modules implementations and usages
https://knotx.io
Apache License 2.0
4 stars 12 forks source link

Provide example for GraphQL usage #52

Closed Voycawojka closed 4 years ago

Voycawojka commented 5 years ago

Is your feature request related to a problem? Please describe. There is no example of GraphQL usage with !x.

Describe the solution you'd like Possible implementation revolves around using !x tasks in GraphQL data fetchers. Requires:

Java GraphQL provides needed implementation itself while Vert.x wrapper provides HTTP handler for GraphQL.

We can implement graphql handler factory (implementing RoutingHandlerFactory) that would configure GraphQL object and return GraphQLHandler from Vertx. GraphQL schema could be provided via configuration in operations.conf (either as a string or as a path to a file with the schema).

GraphQL uses data fetchers as an integration layer. Each type defined in schema needs to have a data fetcher assigned. In the java implementation it needs to be assigned to the GraphQL object before passing it to the http handler (so fetchers need to be assigned in graphql handler factory). Data fetcher is just an object implementing DataFetcher. The idea is to have it run !x tasks. This way !x is still responsible for providing data from integrations.

FragmentsEngine (directly or indirectly via FragmentsHandler) could be used to process tasks defined in configuration. DataFetcher logic would probably be universal or almost universal. It would be better to have it universal if possible. This way there would be no need for hardcoding any connections between schema types and data fetchers.

Describe alternatives you've considered If some genericity can be extracted then GraphQL support could be implemented in !x.

Additional context No context, but here's a cat emoji: 🐱