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 620 forks source link

There is no way to refresh AUTH token on socket reconnect #1323

Open vytautas-pranskunas- opened 1 year ago

vytautas-pranskunas- commented 1 year ago

Hello,

I have socket that uses Beare token to connect and call different endpoints. If token is expired i cannot find a way to refresh it. FOr regular GQL requests i am using fresh_graphql library. I have tried to use it for websockets also but with no luck:

 link = Link.split(
      (request) => request.isSubscription,
      authTokenService.graphQLFreshLink.concat(websocketLink),
      link,
    );

Also i cannot sind any callback on connection error.

Could you help?

vincenzopalazzo commented 1 year ago

Mh, is this a Link job? maybe we should add a way in our ws link, but currently, I had no time to allocate to it. Maybe at the end of June

vytautas-pranskunas- commented 1 year ago

Hi, any progress on this? My sockets are dying after 30 minutes without requests :( for example client waits for response from chat and BAMMM - socket is not able to re-auth :( I would appreciate if you find time for this :)

Thanks

vytautas-pranskunas- commented 1 year ago

Mh, is this a Link job? maybe we should add a way in our ws link, but currently, I had no time to allocate to it. Maybe at the end of June

p.s. i think it is link job.. fresh_graphql does exactly that :) But if you add native support for both sockets and regular GQL queries it would be even better :)

vincenzopalazzo commented 1 year ago

thanks for linking it

I will try to include the support when the 5.2 will be out https://pub.dev/packages/fresh_graphql

vytautas-pranskunas- commented 1 year ago

Hi, Thanks. Any idea about time of 5.2 release?

vincenzopalazzo commented 1 year ago

No if all goes slowly as is going I think end of the 2023 Q4 OR 2024 Q1

vytautas-pranskunas- commented 1 year ago

Woow that's really long time... maybe it would be a chance to release 5.1.x with just that? I am not an expert of your code base but if it is doable with normal link using fresh link then I wonder why it is not working same with socket... maybe there is a matter of simple fix / improvement...

vincenzopalazzo commented 1 year ago

PR are welcome for this

vytautas-pranskunas- commented 1 year ago

I have managed to solve this issue... Just not sure with tests :D I will try to write tests and docs tomorrow. Hope this PR will be accepted quick. Jsut pls tell me upfront what should i do when creating PR, merge, rebase or any other things.. because as far as i remeber last time i was doing PR here it was trouble for me pushing forward, reverting, rebasing and so on... I get used to simple merge :)

vincenzopalazzo commented 1 year ago

I written the docs with all the rules https://github.com/zino-hofmann/graphql-flutter/blob/main/docs/dev/MAINTAINERS.md

vytautas-pranskunas- commented 1 year ago

I will do PR in few minutes. It would be great if you could look ASAP :)

vincenzopalazzo commented 1 year ago

I will put on my queue for sure

vytautas-pranskunas- commented 1 year ago

@vincenzopalazzo i have created PR: https://github.com/zino-hofmann/graphql-flutter/pull/1364 If something not right from Git or docs perspective (not ciriticle) please accept that because I really have no time to play with it any longer :)

p.s. i see that formatting job failed.. but i have different formatting rules... :(

vincenzopalazzo commented 1 year ago

They may are not critical for you :)

vytautas-pranskunas- commented 1 year ago

Formattng is not critical for me.. other than that everything is keeping in mind nesting which i refactored a bit :) Please let me knowwhen it can be merged :)