Is anyone using GraphQL with http4k? Have you inte...
# http4k
k
Is anyone using GraphQL with http4k? Have you integrated it successfully with the `Request`/`Response` flow that http4k servers/clients use?
I've seen https://github.com/aPureBase/KGraphQL so far which looks like it could be useful
y
I’ve used graphql-java + http4k in a side project once. There’s a bit of glue code that you have to write, but it’s pretty straghtforward otherwise.
Integrating it with http4k is very straightforward
A graphql endpoint takes a plain ol’ JSON request, and returns a plain ol’ JSON response.
The cookbook example for defining json endpoints in http4k was more than sufficient.
d
@yen that's great to hear that it was simple! Is that side project anywhere public that we can see it? Would love to see how you integrated and if there's anything we can do to provide tools/patterns/a new module for others to reuse. (No worries if not of course 🙃)
y
My project isn’t open-source unfortunately. I can point you to the GraphQL docs, which outline the shape of the POST request: https://graphql.org/learn/serving-over-http/#post-request The only thing I used http4k for is to extract the fields, and pass them along into graphql-java’s execution engine
r
I added a graphql api next to a rest api just to try it out. I actually never used graphql before this, so could really bad: https://github.com/webDevAndSausages/world-of-webdevandsausages/blob/master/packages/wds-event-tool/src/main/kotlin/org/webdevandsausages/events/graphql/GraphqlRouter.kt
so yeah that is with the KGraphQL mentioned above