softwaremill / tapir

Rapid development of self-documenting APIs
https://tapir.softwaremill.com
Apache License 2.0
1.35k stars 405 forks source link

GraphQL support #52

Closed kell18 closed 4 years ago

kell18 commented 5 years ago

Hello! Intriguing project! :) Are there any plans or thoughts to add GraphQL-server support? Thank you!

adamw commented 5 years ago

Not yet, so far I'm focusing on bringing the basics into a useable form :) But that's definitely an idea worth exploring. If you would have some thoughts on how this could look like, please share!

kell18 commented 5 years ago

Sure! I will explore the project and look at how it could be implemented.

kell18 commented 4 years ago

Hi, I didn't forget ;) Just not enough time. I've tried with at Sangria, but after release of the Caliban project I've switched to it, seems much easier to integrate and to use (and more flexible since it's a new project as well). I will do a small draft proposal next thing to discuss the concept and need for that in general.

adamw commented 4 years ago

@kell18 :D Great to hear!

jan0sch commented 4 years ago

Nice, it would be great to have this. :heart:

ghostdogpr commented 4 years ago

@kell18 that sounds interesting! I’m the author of Caliban. Having to integrate with many backends is a bit of pain so exposing a tapir integration could be nice. This is the approach I’m gonna take for caliban-client with only supporting sttp and let users choose their backend. One thing missing though would be WebSocket support for graphql subscriptions. Anyway, I’d be happy to collaborate on this!

kell18 commented 4 years ago

@ghostdogpr Hi! That sounds great! Actually I took this ticket to try out Tapir and GraphQL, but I didn't have experience with any of that. So it's more like a hobby ticket for me, please grab it if you have bigger plans on it.

But before going there - I think you want to do the opposite of what I'm doing, you want to generate Tapir endpoint form Caliban types, right? It seems like a different task, since, you have your Caliban types as input and you want to generate Tapir Endpoint (probably one, or quite a few) to serve GQL business. As I see the purpose here to abstract over ways to serve Caliban GQL on the server.

In my case, I have Tapir Endpoints as an input and I want to generate some GQL schema. And the purpose here is to reuse the same endpoints for multiple clients with different needs (GQL, simple endpoints, etc).

Edit: I just thought that I actually will need the part you're interested in - serving GQL with Tapir Endpoint. I'll need that later on when schema mapping from Tapir to Caliban would be ready, but for me, it's not a priority for now :)

Is it correct? Let me know what you think :)

kell18 commented 4 years ago

Anyways, on the field of generating GraphQL from Tapir endpoints, what I already did is a simple working example with Sangria (seemed a bit easier for me to start with since it looked more like GraphQL inside, so I learned something about GQL at first).

My plan is to try to do the same for Caliban within the next months, compare them and prepare a draft PR for Tapir. @ghostdogpr If you think that it'd be useful to you as well - you can take over this or we also can pair up maybe to share some basic ideas, it might help to us to go faster.

ghostdogpr commented 4 years ago

@kell18 you’re right, I was thinking of caliban to tapir, but tapir to caliban makes sense as well. The first one is more of a way to easily enable interop with all tapir backends, while the latter is a quick way to bootstrap a graphql API from a REST one. Both have value.

My current priority is caliban-client, so I’m okay to let you work on it at your pace. I can give you an overview of how Caliban schemas works when you’re ready to start (we can get in touch on Discord maybe?) and review code as your progress. How does it sound?

kell18 commented 4 years ago

@ghostdogpr Yes, that sounds great! I'll drop you a message on Discord then :) Sorry for the long delays.

ghostdogpr commented 4 years ago

GraphQL API generation from Tapir endpoints is now live in Caliban! Here's the documentation. I will submit a PR to mention it in Tapir docs.

adamw commented 4 years ago

Since there's Caliban integration closing this