Open ZRunner opened 2 years ago
Mh! I'm new with amplify but I can reproduce it maybe this weekend.
Sorry about that!
+1 It will be very useful for using your lib in flutter instead of AWS Amplify which is very far from your implementation of GraphQL...
We are evaluating on how to manage this issue, I will work on it 🫡
We have a problem with ws right now, and we are introducing integration testing, after this, if the problem is not solved we will build an Amplify to reproduce and work on this problem!
Thanks to report it
final httpLink = HttpLink(AppConstants.urlHttpLink); //'http://somelink.com'
final wsLink = WebSocketLink(
AppConstants.urlWsLink, // 'wss://somelink.com/'
config: SocketClientConfig(
autoReconnect: true,
initialPayload: () async {
final token = await _getRealToken();
return {
'authToken': token,
};
},
),
);
final authLink = AuthLink(
getToken: _getToken,
);
final Link link = Link.split(
(request) => request.isSubscription,
authLink.concat(wsLink),
authLink.concat(httpLink),
);
_client = GraphQLClient(
link: link,
cache: GraphQLCache(
store: InMemoryStore(),
),
);
This works for me @ZRunner I don't know why it doesn't work with you. Yes it already spam my console about disconnecting, but it reconnects and getting messages
@temirlanalmassov
Will be useful have the version of the package that you are using
@temirlanalmassov where I can find web socket link?
@temirlanalmassov
Will be useful have the version of the package that you are using
graphql_flutter: ^5.1.0
@temirlanalmassov where I can find web socket link?
I think you can ask it from your BackEnd side.
static const urlHttpLink = 'https://$domain/graphql/';
static const urlWsLink = 'wss://$domain/ws/graphql/';
For example I am using it like this
graphql_flutter: ^5.1.0
@temirlanalmassov I suggest to use the last beta version, and also I'm starting to reproduce the problem with a AWS amplify project I hope to have this up and running soon.
But in the meanwhile, there can you check what happens if you change the protocol that the library is using to initiate the connection?
@temirlanalmassov I think you are wrong about the API, look to the AWS docs https://docs.aws.amazon.com/appsync/latest/devguide/real-time-websocket-client.html#handshake-details-to-establish-the-websocket-connection
In addition, this looks like an error with the old protocol, and I need to make double-check if AWS has a custom protocol or it is based on a well-known protocol.
I was able to reproduce but I will research these days on what protocol is supported by AWS and try to fix this asap.
For the moment it is reproduced in https://github.com/zino-hofmann/graphql-flutter/pull/1206
@ZRunner Did you get this to work?
@ZRunner Did you get this to work?
My company has decided to move to react native due to the lack of maturity of the Flutter ecosystem. So I'm afraid I won't be of any help here, sorry.
@ZRunner thats ok! good luck with react native!
i ended up simply creating 2 client instances and it worked fine!
thanks for responding quickly! :)
I cannot seem to be able to use GraphQL subscriptions with my AWS server, by using Cognito authentication.
Queries and mutations work fine as far as I can tell, but I couldn't find how to connect to the amplify websocket.
Here is the code I tried, based on this comment: https://github.com/zino-hofmann/graphql-flutter/issues/682#issuecomment-759078492 (which I had to edit because Cognito tokens are not static)
Link.split()
method, my console is spammed withflutter: Disconnected from websocket.
Link.concat()
method, I get a HttpLinkServerException:GraphQLError(message: Subscriptions over MQTT is not supported., locations: null, path: null, extensions: null)
Naturally in both ways my Subscription widget doesn't work (infinite loading state).
Device / execution context