aws-amplify / aws-amplify/amplify-android

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

Open
#2,390 18 comments 0 reactions 0 assignees View on GitHub
api feature-request GraphQL API
Dominant language
Java
Stars
287
Forks
132
Avg merge
2d 2h
Merged PRs (30d)
45

Description

### 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):

```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:

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

Contributor guide

Open the contributing guide

Research direction

Start with the schema's repeated caregivers owner field and the Android Kotlin ModelSubscription.onUpdate(Baby::class.java) call, then trace the generated onUpdateBaby subscription arguments. Reproduce the validation error from the listed steps and verify that subscribing succeeds without an immediate error and that onNextResponse runs only for an actual model update.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, graphql, kotlin
Domain
api, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.