aws-mobile-appsync-sdk-js: AppSync generated graphql subscription not running
Appsync generated graphql subscription is not working (tested using console). I think this is a big issue because when you start learning you expect at least generated things to work
//fails, generated by appsync
subscription OnCreateNotes($id: ID, $title: String, $body: String) { onCreateNotes(id: $id, title: $title, body: $body) { id title body } }
//works
subscription onNewCreateNotes { onNewCreateNotes { __typename id title body } }
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 10
- Comments: 26 (7 by maintainers)
not working for me still, any workaround for this ?
Same problem here, was this solved? I can’t get anything as passing variables into subscribeToMore, even if I use undefined/null value, nothing happened.
I’m kind of wondering if the input different between mutation and subscription will cause error?
mutation --> createNotes(input: CreateNotesInput!): Notes subscription --> onCreateNotes(id: ID, title: String, body: String): Notes
Short explanation: I think the subscription in the screenshot is evaluating to
onCreateNotes(id: null, title: null, body: null). Therefore, the subscription is looking for created Notes which have id = null, title = null, and body = null.Longer Answer: The subscription has 3 query variables defined for the operation (
$id,$title, and$body). Sinceid,titleandbodyare defined and they are being used as input parameters to the subscription, the graphQL engine will try to coerce those values by looking into the Query Variables passed in (bottom left corner of the page). In the screenshot, there is a variable value forcreatenotesinput, but there are no variables passed in forid,title, orbody.Therefore, a default value is probably inserted forid,title, andbody. The default value, in this case, is probablynull.