zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 623 forks source link

not able to pass custom headers in WebSocket link #1265

Closed praneethreddyt closed 1 year ago

praneethreddyt commented 1 year ago

tried to pass custom headers in web-socket link. i have tried passing headers in headers and also in initial Payload. i am receiving "Sec-WebSocket-Protocol" header but not the custom headers.below is my code. thanks in advance. final WebSocketLink websocketLink = WebSocketLink( url, config: SocketClientConfig( autoReconnect: true, inactivityTimeout: Duration(seconds: 30), initialPayload:()=>{ "headers": { "Sec-WebSocket-Protocol": "graphql-ws", "device_id":"PKQ1", } }, headers :{ "device_id":"PKQ1", "Sec-WebSocket-Protocol": "graphql-ws", } ), );

vincenzopalazzo commented 1 year ago

You are using the header in the wrong way.

You may want take a look to this enum https://github.com/zino-hofmann/graphql-flutter/blob/main/packages/graphql/lib/src/links/websocket_link/websocket_client.dart#L162-L176 and Just grab the code on how it is used