Comments (9)
Very good point. I think a function ARG => ZStream[R, E, A]
is the right way to model this.
Currently I'm forcing the field to be a ZStream
by requiring an instance of the SubscriptionSchema
typeclass (which only exist for ZStream
and Unit
). I am going to add one for ARG => ZStream[R, E, A]
but in the meantime you can provide it yourself with this code:
implicit def functionSubscriptionSchema[R, E, A, ARG]: SubscriptionSchema[ARG => ZStream[R, E, A]] =
new SubscriptionSchema[ARG => ZStream[R, E, A]] {}
from caliban.
@jmpicnic did the workaround resolve the problem? I have a PR ready, I'll merge if you confirm 👍
from caliban.
I am building it this week. I'll have results over the weekend.
from caliban.
One follow up question. I have not seen much by way of examples of Caliban with akka-http. I got it working for regular queries and mutations, but I was wondering if you know of any examples that integrates wtih their streaming infrastructure.
from caliban.
@jmpicnic I don't think there are any examples out there yet because Caliban is very new. Actually it would be great to have a caliban-akka
module just like there is caliban-http4s
.
For streaming I imagine the implementation would be similar to https://github.com/ghostdogpr/caliban/blob/master/http4s/src/main/scala/caliban/Http4sAdapter.scala#L104 but using https://doc.akka.io/docs/akka-http/current/server-side/websocket-support.html
I'll make an issue for it, maybe an external contributor would pick it.
from caliban.
Yes, that is the path I am following. If I end up with something re-usable, I'll send it to contribute it.
Thanks
Miguel
from caliban.
Although I am stuck in actually getting the ZIO streams reliably feed the Akka Streams on events, I have confirmed through old-fashioned print traces that the conditions for the subscriptions come through the websocket channel and make it all the way to the application logic using the implicit function that you suggested. I tested it with the Chrome "Simple Web Socket Client" chrome plug in, opening a connection and sending the "subscription { ... }" message through it.
I have not been able to connect through a full GQL plugin like Altair. It seems it is not sending the payload through the connection once it is open. I will turn my attention to that once I figure the inter-stream stuff.
I suspect that a good chunk of this is due to my not knowing enough of ZIO and Akka Streams, as the interaction of zio effects and scala futures, and how/when to have them triggered is still a headache for me. Fun learning trip though.
from caliban.
@jmpicnic thanks for confirming. I will merge the PR and release a new version of caliban with it.
Regarding ZIO Stream interop with Akka Streams, I haven't used it myself but maybe the interop-reactive-streams project may help: https://github.com/zio/interop-reactive-streams (since Akka also supports it).
I managed to get subscriptions working in Altair, so let me know if you have any issue later on with this.
from caliban.
Thanks a lot. I think the issue with Altair is on the akka-http side, but not sure. I am still too new to be confident of my diagnosis :-).
Thanks again for all the help.
PS. My company is moving to gRpc as the inter-service comm protocol, so I'll be taking a longish detour through that.
from caliban.
Related Issues (20)
- Full compliance with GraphQL over HTTP spec
- Example shuts down immediately HOT 1
- GraphQL instances get combined incorrectly if one or both root queries are somehow deferred HOT 4
- Codegen: Support union types as scala 3 union types HOT 3
- recursive types + semi-auto derivation + federation does not work HOT 4
- interfaces' field description derived incorrectly HOT 3
- Scala 3 different schema derivation
- `rename` fails when applied to derived recursive schema
- Interfaces are not rendered properly when renamed via `.rename`
- `@defer` fields not working as expected when backed by `DataSource`s
- Scala 3 different schema derivation nested types
- Scala 3 different schema derivation enum names HOT 2
- Scala 3 schema derivation duplicate types in union
- Scala 3 different schema derivation nested enum items missing
- Codegen: Incorrect order of description in server sealed trait generation HOT 1
- Outdated `SchemaReporting` docs
- Allow executing mutations / subscriptions in parallel / batched mode
- Support for IO in the tapir interop adapter HOT 12
- Add an apollo rover template HOT 1
- `SchemaComparison` from `caliban-tools` does not detect changes in base interfaces HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caliban.