Giter VIP home page Giter VIP logo

Comments (7)

enisdenjo avatar enisdenjo commented on June 4, 2024 1

Sure, a recommendation sounds good. But please make it 4403: Forbidden instead because that is what the library uses if you return false in the onConnect hook:

return socket.close(CloseCode.Forbidden, 'Forbidden');

from graphql-ws.

enisdenjo avatar enisdenjo commented on June 4, 2024

Simply closing the websocket is not ideal, since that is a separate protocol layer.

Why not? This is the reason why there is no positive rejection. You have an abundance of user-land close codes (4000-4999) that can be accompanied with any 123 character reason.

Furthermore, you can close the connection at any time (even after acknowledging the connection, or before even considering the connection) and it is very convenient to do so within graphql-ws hooks.

We could specify that the standard way is to close the websocket with some specific error code.

The standard is to close the connection with a close event. GraphQL over WebSocket is a subprotocol under WebSockets, meaning - the conventions of WebSockets are recommended and implied. The spec should be kept as light as possible, it should aim to standardise the GraphQL relevant transport with enough constraints but very small overhead.

from graphql-ws.

kristjanvalur avatar kristjanvalur commented on June 4, 2024

Okay, still user-land error codes are always ambiguous. When writing an implementation conforming to a protocol and expecting good interoperability, it is great to have rules and recommendations and as little ambiguity as possible. The protocol already defines a few 4xxx codes to use.

Could we agree on a websocket close code in this case? Would you accept a PR where this recommendation on how to reject a connection_init request is made explicit? Maybe the 4401: Unauthorized message?

from graphql-ws.

enisdenjo avatar enisdenjo commented on June 4, 2024

🎉 This issue has been resolved in version 5.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from graphql-ws.

enisdenjo avatar enisdenjo commented on June 4, 2024

My bad, I referenced the wrong issue when merging #456.

from graphql-ws.

kristjanvalur avatar kristjanvalur commented on June 4, 2024

Ok, created a PR. There is code out there written in different programming languages which is trying to follow the spec, and not necessarily reverse engineering the .ts source :)

from graphql-ws.

enisdenjo avatar enisdenjo commented on June 4, 2024

🎉 This issue has been resolved in version 5.12.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

from graphql-ws.

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.