A custom link is no longer necessary – use SocketClientConfig.connect instead.
If you want to view the outdated, probably no-longer working solution, see the previous version
A custom link is no longer necessary – use SocketClientConfig.connect instead.
If you want to view the outdated, probably no-longer working solution, see the previous version
@kateile As of 4.1.0-beta.1
you should be able to just pass a custom connect
wrapper to the SocketClientConfig
:
To supply custom headers to an IO client:
connect: (url, protocols) =>
IOWebSocketChannel.connect(url, protocols: protocols, headers: myCustomHeaders)
I am using 4.1.0-beta.1
along with gql_dio_link:^0.0.4
and dio: 3.0.10
and everything is fine. Dio 4 introduce some major fix for web and options for more secure cookies storage, and we uses session/cookies based auth. So migrating to dio 4
and latest gql_dio_link
seems inevitable to me. Now the problem I am facing is turning this to work with ^5.0.0-nullsafety.2
because using 4.1.0-beta.1
seems incompatible with(I get solving version failed) other latest gql-dart dependencies. And version 5.0.0 uses different web socket package. My problem is I wish to upgrade packages but upgrading will break web socket since I can't pass headers.
@kateile I admit I didn't read all that but gql_dio_link
's been migrated to nullsafe+v4 so hopefully that will solve your issue.
I still face some issues. Please see my comment here
I did some little mistakes and I finally solved. Thank you so much
good to hear 👍
how do i apply this solustion to WSclient ?
final WSLink _webSocketLink = WSLink('ws://IP_ADDRESS/graphql',
config: SocketClientConfig(
autoReconnect: true,
inactivityTimeout: null,
),
headers: {"authorization": "exampletoken"});
final Link _link = _webSocketLink;
final GraphQLClient _client = GraphQLClient(
link: _link,
cache: GraphQLCache(),
);
i did try but still unable to connect
any idea @kateile?
please help
@dunods Use SocketClientConfig.connect
– this is outdated and probably won't work now
@micimize .. im using the old version graphql_flutter: ^4.0.0
and still yet that code didnt work out.. any idea how to make it work
probably some dev environment setup issue, but I really recommend upgrading at least to 4.1.0-beta.1
.
I no longer contribute to graphql_flutter
so I don't have the details fresh in my head anymore
I love this workaround. any idea on how to make it work with ^5.0.0-nullsafety.2?