Giter Site home page Giter Site logo

Comments (6)

n1ru4l avatar n1ru4l commented on June 11, 2024 1

@dan-lee @kefniark PR welcome for lifting the constraint 😇 Sorry for causing the troubles, we discussed it internally ans we dont see why we should not allow it for now, as the official spec is still pretty vague (aka non-existing 😅)!

Slightly related: I would also appreciate any comments and thoughs on graphql/graphql-over-http#167

from graphql-helix.

n1ru4l avatar n1ru4l commented on June 11, 2024

As mentioned on discord we never intended graphql-helix to be compatible with the protocol described via graphql-sse. The prior compatibility has been a pure coincidence.

The API for communicating with an SSE endpoint in browsers is EventSource. The EventSource ALWAYS sends a GET request to the SSE endpoint. There is no "official" SSE over HTTP spec yet. We made the assumption that SSE MUST be done over GET, however, this is assumption was wrong as the SSE specification does not really dictate the HTTP verb that should be used. It also seems like using GET for SSE is the common sense people agreed upon.

I don't really have an answer for this. I guess it might make sense to let people configure whether subscriptions are allowed via GET and/or POST?

This should probably also be a discussion on the GraphQL over HTTP repository

from graphql-helix.

kefniark avatar kefniark commented on June 11, 2024

Same here, using graphql-sse on few projects and running into the same issue.
I'm a bit confused by such modification, it looks quite arbitrary to me to enforce Get over Post for SSE Subscription, and I thought the whole point of graphql-helix was to be

Framework and runtime agnostic. Use whatever HTTP library you want

Anyway, as a workaround I just did what I was already doing with apollo before, moving the subscription out of the graphql-helix endpoint, and use a dedicated subscription endpoint managed by graphql-sse directly

    // graphql-helix on `/graphql`
    this.app.use(`/graphql`, async (req, res) => {
      const request = { body: req.body, headers: req.headers, method: req.method, query: req.query }

     // ... graphql-helix code

      sendResult(result, res, formatResult)
    })

    // graphql-sse on `/stream`
    const handler = createHandler({ schema, context: (req: Request) => ({ db, pubsub, req }) })
    this.app.use(`/stream`, [...middlewares], handler)

and on client side, the only modification is to change the subscription url.

from graphql-helix.

dan-lee avatar dan-lee commented on June 11, 2024

@kefniark My problem is that I am using Cloudflare Workers and the graphql-sse server handler relies on Node.js Request/Response APIs.

I don't really have an answer for this. I guess it might make sense to let people configure whether subscriptions are allowed via GET and/or POST?

@n1ru4l I think that would be best for now instead of closing the door completely.
I also think this needs a broader discussion to provide a more common standard.

from graphql-helix.

dan-lee avatar dan-lee commented on June 11, 2024

@n1ru4l I've opened PR #225 :)

from graphql-helix.

dan-lee avatar dan-lee commented on June 11, 2024

Fixed in v1.12.0

from graphql-helix.

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.