Add operation name to subscribe message #440
-
StoryAs a client I want to fast navigate in many messages in browser Network tab for web socket like: You can see, there are a lot of messages sent via web socket, and without operation name it is too hard to observe all of them and find the needed one for debug So I prepare code adjustments for that purpose: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Moved to #440 (comment). |
Beta Was this translation helpful? Give feedback.
-
@enisdenjo, what if I will have multiple messages with same ID (operation name)? Will it affect any internal implementations (maybe sync requests and responses or similar)? |
Beta Was this translation helpful? Give feedback.
-
Similar to #398. I wouldn't add a new field to the subscribe message, I'd recommend instead using the You can add something random to disambiguate the IDs during development. Roughly: import { createClient } from 'graphql-ws';
const client = createClient({
url: 'ws://dev-gen-id:4000/graphql',
generateID: ({ operationName }) =>
// operationName plus a random 4 character hash
`${operationName}_${Math.random().toString(36).slice(-4)}`,
}); Do note that the GraphQL over WebSocket Protocol disallows multiple active operations with the same ID. |
Beta Was this translation helpful? Give feedback.
Similar to #398.
I wouldn't add a new field to the subscribe message, I'd recommend instead using the
generateID
client option to ease up lookups during development. The argument receives the operation payload so you can construct whatever you want.You can add something random to disambiguate the IDs during development. Roughly:
Do note that the GraphQL over WebSocket Protocol disallows multiple active operations with the …