Comments (10)
There, you can now pass whatever you want for the payload. 😄
from graphql-ws.
BTW, the client now fails immediately for some fatal close event codes. This should improve the DX by bringing a problem up sooner.
from graphql-ws.
Nothing should be failing silently. Are you sure the socket is not closed with the error in the close event reason? Keep in mind that the client will retry a few times if the connection gets closed (you might not see the error immediately).
If its indeed failing silently, please make a test or a repro and I will be more than happy to look at it and bring up a fix! (Please make an additional issue)
Furthermore, the server validates messages because they should follow the Protocol's shapes. I'd say the validation for the next
message is very forgiving - it requires the data
or the errors
field to be an object in the payload
:
Lines 120 to 127 in 0d2f974
Message you provided is failing because the
data
field is a string. How does a query that gives you just a string in the data object look like? (just curious 😄)
It does make sense to support whatever for the data
field - fix is coming!
from graphql-ws.
The example above shows such a query, with the schema and Query Object type 😅
You are right, the client connection gets closed and it will retry connecting. However, since this is a error in general related to the server, I would actually also expect to see that issue logged to the console.
The close reason for socket is also not detailed enough imho. like is the message sent by the client invalid or the one sent back and what exactly is invalid? For a nice DX A more detailed message could be returned.
I would propose to not explicitly check whether payload has a data or errors property. That seems to be an implementation detail of execute to me
from graphql-ws.
You can hook up onto the closed
event for the client and log all socket closes.
I check just the basics, the simplest form of graphql-js
's ExecuteResult
(any data
or object errors
). The message has a super simple form, so it should be rather easy to detect why the message is malformed - hence vague error.
I plan on making the client retry connections on some errors only - classify the fatal ones and report them immediately.
Furthermore, all of server-side error handling issues will go away as soon as #64 lands. You will have full control of error handling and reporting then. Once this lands, tracking if the malformed issue originates from the back or front should be easy. Will keep your insights in mind though!
from graphql-ws.
defer and stream AsyncIterables returned from execute will emit a final { hasNext: false }
execution result. See src/execution/tests/stream-test.js here: graphql/graphql-js@dec5554#diff-a370dc23e95e90e2b04fe67a3a933e6eb09296c64b4eae7509cd3ae93edaf2ae
from graphql-ws.
Oh! Well, thats enough for me. I'll just make it so that the validation makes sure that the payload
is present. You can pass whatever you want.
from graphql-ws.
Awesome 👏 Thanks for considering this!
from graphql-ws.
Thank you for bringing it up!
from graphql-ws.
🎉 This issue has been resolved in version 1.13.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
from graphql-ws.
Related Issues (20)
- Warning when importing module with rollup
- limitCloseReason crash with Cannot read properties of undefined HOT 2
- On Normal Closure the app doesn't retry even when shouldRetry set to true
- Websocket event "connection_ack" with "payload" as null result into closed connection HOT 3
- Invalid message Error in subscription
- Support for "graphql-ws" sub protocol
- graphql-transport-ws rejection specification HOT 7
- Cannot return null for non-nullable field Subscription.greeting
- "realTimeConsumptionEnabled": false HOT 1
- Docs folder is missing HOT 1
- Npm and tsc build fails on 5.13.0 due to bun-types HOT 2
- graphql-yoga integration example breaks for mutations HOT 2
- JWT Expired gives fatal error. How to refresh the JWT token for an open GraphQL subscription? HOT 4
- Refresh JWT Token in connection init
- Malformed authorization headers on [email protected] only on iOS HOT 4
- Socket could not reconnect after IOS app comeback from background
- wrong protocol in connection
- Detecting when a websocket connection is down
- [ReactNative] Slow refresh subscription causes websocket close with {"isTrusted": false, "message": null} HOT 18
- Retry on different URL HOT 1
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 graphql-ws.