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

Subscriptions never connect to Amplify mock server #550

Open KieranLafferty opened 4 years ago

KieranLafferty commented 4 years ago

Describe the bug I feel like I've tried absolutely everything including going deep into the implementation of the subscription implementation

To Reproduce Steps to reproduce the behavior:

  1. Create an Amplify project with amplify add api and add model and a subscription query
  2. Run amplify mock to get a local instance of the amplify running
    ✔ Generated GraphQL operations successfully and saved at graphql
    ✔ Code generated successfully and saved in file API.swift
    AppSync Mock endpoint is running at http://192.168.86.21:20002
  3. Create a client provider according to the example in the repo https://github.com/zino-app/graphql-flutter/blob/ba98de9216b36656d9acb5d69e728199fef7fd9f/examples/starwars/lib/client_provider.dart
  4. Configure ClientProvider as follows
    ClientProvider(
    uri: "http://localhost:20002/graphql",
    subscriptionUri: "ws://localhost:20002/graphql",
    ...
    )
  5. Use Subscription widget configured with correctly with the subscription query created in 1.
  6. Observe the following error
    flutter: Connecting to websocket: ws://localhost:20002/graphql...
    flutter: There was an error causing connection lost: WebSocketException: Connection to 'http://localhost:20002/graphql#' was not upgraded to websocket
    flutter: Disconnected from websocket.
    flutter: Scheduling to connect in 5 seconds...

Expected behavior Should connect properly and establish a connection

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

I'm tempted to think that the subscription websocket address I am using is incorrect. When I connect through GraphiQL it shows the following message on amplify mock logs when I execute a subscription operation:

register {
  clientId: 'e6fdf792c0dd99ca7c3f1764b9937cd6',
  subscriptionId: 'e6fdf792c0dd99ca7c3f1764b9937cd6/onCreateMessage/'
}

I feel like I've gone over everything with a fine toothed comb by this point and desperately need help to get unblocked. Thank you for any info that anyone can provide

joekendal commented 3 years ago

@KieranLafferty what happened to this in the end? did you get it working with Amplify and mock Amplify?

brianschardt commented 3 years ago

I am having this issue with GCP cloud run.