Unknown field argument owner @ ‘onCreateXYZ’

if you run across an error like

{"errors":[{"message":"Validation error of type UnknownArgument: Unknown field argument owner @ 'onCreateXYZ'"}]}

While using AWS Amplify with DataStore, it’s probably due to your AppSync Schema being messed up. I’ve run into this when I had a model type two cognito @auth directives, e.g.

@auth(rules: [
{ allow: private, operations: [read] }
{ allow: private, provider: iam, operations: [create, read, update, delete] }
{allow:owner,ownerField: "owner" }
])

The code generator for AppSync gets confused in this case and creates incorrect Subscription definitions. They lack the `owner` parameter, as you can see if you sign into the AppSync dashboard for your environment, and tap on the Schema link.

This is the way it should look:

onCreateUser(owner: String!): User @aws_subscribe(mutations: ["createUser"])

But this is what gets created

onCreateUser: User @aws_subscribe(mutations: ["createUser"]

Just change your schema.graphql back to having only one cognito auth type and push. AppSync schema should be back to normal and the error on launch will go away!

2 thoughts on “Unknown field argument owner @ ‘onCreateXYZ’

Leave a Reply

Your email address will not be published. Required fields are marked *