Skip to content

Error response when subscribing to "onUpdate" for a model with a repeated owner field. #2390

@astex

Description

@astex

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v18.15.0

Amplify CLI Version

11.0.3

What operating system are you using?

Windows

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes.

Describe the bug

I have a schema like this:

type Baby
  @model
  @auth(rules: [
    {allow: owner, ownerField: "caregivers", operations: [create, read, update, delete]}
  ]) {
    id: ID!
    caregivers: [String]!
    ...
  }

When attempting to subscribe to updates to the model like this (android, kotlin):

Amplify.API.subscribe(
    ModelSubscription.onUpdate(Baby::class.java),
    /* onSubscriptionEstablished = */ { ... },
    /* onNextResponse = */ {
        if (it.errors.isNotEmpty()) {
            Log.e("error response from baby update subscription", it.errors.toString())
        } else {
            ...
        }
    },
    /* onSubscriptionFailure = */ { ... },
    /* onSubscriptionCompleted = */ { ... })

I get this response:

[GraphQLResponse.Error{message='Validation error of type UnknownArgument: Unknown field argument caregivers @ 'onUpdateBaby'', locations='null', path='null', extensions='null'}]

Expected behavior

Log.e should never be called. And, it should wait to call onNextResponse until there is an actual update to the model.

Reproduction steps

  1. Create an API with the schema above.
  2. Try to subscribe as above.

Project Identifier

No response

Log output

No response

Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GraphQL APIRelated to the API (GraphQL) category/pluginsapifeature-requestRequest a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions