serverless-appsync-simulator icon indicating copy to clipboard operation
serverless-appsync-simulator copied to clipboard

Simulating Subscriptions

Open Mudassir-23 opened this issue 5 years ago • 8 comments

@bboure I really appreciate your efforts in contributing to serverless-appsync-plugin and creating this awesome serverless-appsync-simulator plugin.

I'm facing problem testing subscriptions, I'm assuming subscription endpoint is ws://${IP_ADRESS}:20003/graphql

when I subscribe, a message "listening" continues to show up but on mutation, nothing would happen with a subscription(no data is received).

I'm using graphql explorer to test subscription.

Mudassir-23 avatar May 14 '20 10:05 Mudassir-23

Hi @Mudassir-23 To be honest, I have not used the subscription feature yet.

I will try to find some time to test and see if there are issues.

In any case, the problem is possibly in https://github.com/aws-amplify/amplify-cli since, this plugin is only a wrapper of it.

If you have some time and want to help, you can also try to debug and try to find the source of the problem

bboure avatar May 14 '20 10:05 bboure

Historically AppSync was using MQTT not WebSocket to deliver subscriptions. That said support of WebSockets as a transport protocol was added quite recently: https://aws.amazon.com/about-aws/whats-new/2020/04/aws-appsync-enables-support-for-generic-websockets-clients-graphql-real-time-subscriptions/ There might be already some support for subscriptions in Amplify CLI, e.g. I see issue opened just today: https://github.com/aws-amplify/amplify-cli/issues/5798

Let's see if I can find some time and figure out what contribution needs to be done here.

ElvenMonky avatar Nov 06 '20 22:11 ElvenMonky

Hi, any planned updates in implementing subscriptions?

skix123 avatar Apr 08 '21 18:04 skix123

@bboure Subscription with serverless-appsync-simulator work fine, its just that graphiql interface doesn't support the subscription testing yet. I was able to test subscription in dev through this example https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/aws-appsync%403.0.4/tutorials/react-offline-realtime-todos/src/App.js. I'm planning to clean up this example to make it generic and easy to understand, will post the link here soon. Again, I really appreciate your efforts in developing this plugin.

Mudassir-23 avatar Jul 24 '21 16:07 Mudassir-23

Hi @Mudassir-23 , Any way possible you can post more easier example here ?

ehtesham1996 avatar Nov 20 '21 11:11 ehtesham1996

It seems GraphiQL has supported subscriptions with a custom fetcher for some time now according to this blog post.

adamduren avatar May 17 '22 20:05 adamduren

There is an update in the amplify project According to the CHANGELOG they have fixed mocking WS.

Note this changes are available in the latest version but for this we need to swicth from amplify-appsync-simulator to @aws-amplify/amplify-appsync-simulator

We tried today in our team via yarn resolutions "amplify-appsync-simulator": "npm:@aws-amplify/amplify-appsync-simulator@^2.6.1" and with a postinstall patch in ./node_modules/amplify-appsync-simulator/lib/data-loader/index.js

// Disabled since causing conflict somehow
//addDataLoader("AMAZON_ELASTICSEARCH"

This looks working fine, would love to see an update on this 😉

Hideman85 avatar Oct 13 '22 12:10 Hideman85

Thank you @Hideman85

If you got this working, please feel free to open a PR, that would be great.

Thanks

bboure avatar Oct 13 '22 13:10 bboure