enisdenjo / graphql-ws

Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
https://the-guild.dev/graphql/ws
MIT License
1.72k stars 155 forks source link

Example/documentation for client.iterate are incorrect? #576

Open ddebrunner opened 1 month ago

ddebrunner commented 1 month ago

The example client iterator code is here:

https://github.com/enisdenjo/graphql-ws/blob/master/website/src/pages/get-started.mdx?plain=1#L195-L196

and reads as though the value returned from query.next() is the data element of the GraphQL response.

But using the client query.next() with a GraphQL server returns a higher level object:

{"value":{"data":{"user":{"id":"100","name":"Pascale","email":"veldaparker@weimann.biz"}}},"done":false}

The tests added by #486 also show that the value returned is the higher-level object: https://github.com/enisdenjo/graphql-ws/blob/master/src/__tests__/client.ts#L2355-L2361

Maybe I'm missing something, I'm not a javascript/typescript expert so maybe there's some magic going on with the test harness and expect, but I found the mismatch confusing with what value was expected to be returned.

enisdenjo commented 1 month ago

Ah you're right! There should be data. You interested in making a PR? 😄