I have a model configured like this:
type MyModel @model
@auth(rules: [
{ allow: owner },
{ allow: private, provider: iam, operations: [read, update] }
])
{
id: ID!
someValue: Int
otherValue: Int
}
and a subscription to the model:
const listener = API.graphql(graphqlOperation(onUpdateMyModel, {owner: user.username})).subscribe({
next: (updatedModel) => {
//do something
}
});
I also have a lambda that when triggered, updates otherValue
on the model via a graphQL mutation. This however, does not trigger the subscription listener.
I've tested that the listener picks up when the user updates the model and this works perfectly fine so I know the subscription is working in general.
The API is configured with the cognito user pool as the default auth.
I must be missing something here but I can't work out what. How do I ensure my listener picks up changes made by the Lambda?
The reason this was not working had nothing to do with the fact that it was a lambda updating the record but everything to do with the custom mutation in which it was using to update the record.
All I needed to do was ensure all the fields were being returned by the mutation...this includes the auto generated createdAt
and updatedAt
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.