Git Product home page Git Product logo

Comments (9)

ghostdogpr avatar ghostdogpr commented on June 15, 2024

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.

ghostdogpr avatar ghostdogpr commented on June 15, 2024

@jmpicnic did the workaround resolve the problem? I have a PR ready, I'll merge if you confirm 👍

from caliban.

jmpicnic avatar jmpicnic commented on June 15, 2024

I am building it this week. I'll have results over the weekend.

from caliban.

jmpicnic avatar jmpicnic commented on June 15, 2024

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.

ghostdogpr avatar ghostdogpr commented on June 15, 2024

@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.

jmpicnic avatar jmpicnic commented on June 15, 2024

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.

jmpicnic avatar jmpicnic commented on June 15, 2024

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.

ghostdogpr avatar ghostdogpr commented on June 15, 2024

@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.

jmpicnic avatar jmpicnic commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.