- Newest
- Most votes
- Most comments
As I do not see your mutation object, I am not sure, but you must make sure that your mutation selects all the fields that may be needed in a subscription. This looks a little weird, that even though the mutation itself does not need any fields to be returned, if you do not do that, the subscriptions will also not return anything.
The issue with your AppSync mutation returning null in the subscription is likely due to a missing resolver for your mutation. When you make a mutation from your Lambda function, AppSync needs a properly configured resolver to process the request and return data.
Here are the steps to fix this issue:
-
Check your mutation resolver: Make sure you have a resolver attached to your mutation in the AppSync console. Navigate to the Schema section and look for your mutation in the Resolvers list.
-
Configure the resolver properly: If you don't have a resolver or it's not properly configured, attach one. For a simple case, you can use a VTL resolver with a NoneDataSource:
{
"version": "2017-02-28",
"payload": {
"notificationId": "$context.arguments.notificationId",
"recipientId": "$context.arguments.recipientId",
"notificationType": "$context.arguments.notificationType",
"isSeen": "$context.arguments.isSeen",
"actorId": "$context.arguments.actorId",
"actorHandle": "$context.arguments.actorHandle",
"actorName": "$context.arguments.actorName",
"resourceId": "$context.arguments.resourceId"
}
}
-
Ensure your mutation returns data: Your Lambda function should be returning the created/updated notification object. The subscription will only receive what the mutation returns.
-
Check subscription setup: Ensure your subscription is properly set up with the
@aws_subscribedirective pointing to the correct mutation. -
Network handling: If you're testing on a mobile device, be aware that network changes (like switching from WiFi to mobile data) can disrupt AppSync subscriptions. The AWS Amplify SDK has built-in reconnection capabilities, but you might need to handle connection state changes.
By ensuring your mutation resolver is properly configured to return the notification data, your subscription should start receiving the expected data instead of null.
Sources
Why do Appsync Mutations return null | AWS re:Post
Example for AppSync subscription resolver to work | AWS re:Post
AWS AppSync Subscriptions Disrupt on Network Changes | AWS re:Post
answered a year ago
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated 4 years ago

Thank you! My graphql mutations were not updated using codegen and were using the old schema. As a result, some fields were missing when making mutations