mhd999 / appsync-subscription

A plugin abstract subscribe to AppSync subscription topics.
MIT License
0 stars 1 forks source link

Subscription not working in flutter #1

Closed MrFarhan closed 1 year ago

MrFarhan commented 1 year ago

Got below error while using your code with my subscription.

flutter: NoSuchMethodError: The method '[]' was called on null. Receiver: null Tried calling: []("subscription")

mhd999 commented 1 year ago

Can you share your integration code?

MrFarhan commented 1 year ago

@mhd999 I have used the exact same code you mentioned in the readme

MrFarhan commented 1 year ago

Below is the code screenshot, I think we need to wrap this in Future builder or Stream to get the subscription data but I couldn't find any of them in your code, Pls correct me if I am wrong or made any mistake in the code :

fluttercode

mhd999 commented 1 year ago

Can you share the result of

curl --location --request POST 'https://XXXXXX.appsync-api.{REGION}.amazonaws.com/graphql' \
--header 'x-api-key: {API_KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"subscription {\n        onCreateOrder {\n          OrdersId\n        }\n}","variables":{}}'
MrFarhan commented 1 year ago

Got below error while using your code with my subscription.

flutter: NoSuchMethodError: The method '[]' was called on null. Receiver: null Tried calling: []("subscription")

I had to decline the project due to this issue, how ever the error while calling subscription is mentioned in my initial message

mhd999 commented 1 year ago

Hi,

the curl I shared in the previous comment should return a response similar to this:

    "extensions": {
        "subscription": {
            "mqttConnections":   [...],
             "newSubscriptions" : { ... }
            }
       }     

I don't think your AWS AppSync returns this response hence why the library can't parse the response to find the subscription topic.

If you are not able to share that response with me I can't debug the issue.

Samuel-ML commented 1 year ago

Hello, I'm facing this error

{ "errors" : [ { "errorType" : "BadRequestException", "message" : "Subscriptions over MQTT is not supported." } ] }