Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datastore Model with custom ownerField fails #3026

Closed
guustmc opened this issue Jun 16, 2023 · 5 comments
Closed

Datastore Model with custom ownerField fails #3026

guustmc opened this issue Jun 16, 2023 · 5 comments
Labels
bug Something isn't working datastore Issues related to the DataStore category

Comments

@guustmc
Copy link

guustmc commented Jun 16, 2023

Describe the bug

CLI Version: 12.1.0
SDK version: 2.11.5

When using the following Datastore model on Amplify studio & running amplify pull:

type UserChild @model @auth(rules: [{allow: owner, ownerField: "authors"}]) {
  id: ID!
  name: String
  gender: UserChildGender
  userID: ID! @index(name: "byUser")
  dueDate: AWSDate
  authors: [String]
}

And then calling:

let child = Child(name: "test", gender: .boy, userID: "xyz", dueDate: Date())
try await Amplify.DataStore.save(child)

I get the following error:

GraphQLResponseError<MutationSync<AnyModel>>: 
GraphQL service returned a successful response containing errors: [
      Amplify.GraphQLError(
          message: "Validation error of type UnknownArgument: Unknown field argument authors @ 'onUpdateUserChild\", 
          locations: nil, path: nil, extensions: nil
      )]

This error only happens when im using the custom ownerField 'authors' (I need to share user data between multiple users). If I use the default owner code everything works nicely with authentication.

I've tried removing all local amplify data & pulling the project again.

Steps To Reproduce

Steps to reproduce the behavior:
1. Create an amplify project
2. Use the data model supplied in the report
3. Pull the project using the amplify CLI (without any changes to the config)
4. Authenticate yourself using the Amplify auth plugin & cognito 
4. Save a record of the model to datastore

Expected behavior

The model is saved with the saving user added as one of the authors.
The data should be:
authors: ['xyz::xyz']

Amplify Framework Version

iOS SDK version 2.11.5

Amplify Categories

Auth, DataStore

Dependency manager

Swift PM

Swift version

5

CLI version

12.1.0

Xcode version

14.3.1

Relevant log output

<details>
<summary>Log Messages</summary>

[RetryableGraphQLSubscriptionOperation<MutationSync<AnyModel>>] APIError: Subscription item event failed with error
Caused by:
GraphQLResponseError<MutationSync<AnyModel>>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type UnknownArgument: Unknown field argument authors @ \'onDeleteUserChild\'", locations: nil, path: nil, extensions: nil)]
Recovery suggestion: The list of `GraphQLError` contains service-specific messages
2023-06-16 15:15:55.878464+0200 [37392:4128790] [RetryableGraphQLSubscriptionOperation<MutationSync<AnyModel>>] [37E8B0FD-6D46-4869-87BC-544CBCD2DE61] - Failed
2023-06-16 15:15:55.878490+0200 [37392:4128790] [IncomingAsyncSubscriptionEventPublisher] [InitializeSubscription.1] API.subscribe failed for `UserChild` error: Subscription item event failed with error
2023-06-16 15:15:55.878490+0200 [37392:4128801] [RetryableGraphQLSubscrip2023-06-16 15:15:55.878490+0200 [37392:4128805] [RetryableGraphQLSubscriptionOperation<MutationSync<AnyModel>>] APIError: Subscription item event failed with error
Caused by:
GraphQLResponseError<MutationSync<AnyModel>>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type UnknownArgument: Unknown field argument authors @ \'onUpdateUserChild\'", locations: nil, path: nil, extensions: nil)]
Recovery suggestion: The list of `GraphQLError` contains service-specific messages
</details>

Is this a regression?

No

Regression additional context

No response

Device

iPhone 14

iOS Version

16

Specific to simulators

No

Additional context

No response

@phantumcode phantumcode added bug Something isn't working datastore Issues related to the DataStore category labels Jun 19, 2023
@pixelier
Copy link

There is a draft PR dating from January 2022.
Will it be fixed anytime soon? 🙏

@guustmc
Copy link
Author

guustmc commented Jun 20, 2023

This issue a little different where it happens also with just 1 auth rule in stead of multiple @pixelier

@atierian
Copy link
Member

Thanks for reporting this. We'll investigate and respond here with any updates.

@lawmicha
Copy link
Contributor

@lawmicha
Copy link
Contributor

lawmicha commented Oct 2, 2023

Closing since this has been released, please try out 2.19.0. Feel free to let us know to re-open or open a new issue with your schema if something isn't working as expected

@lawmicha lawmicha closed this as completed Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working datastore Issues related to the DataStore category
Projects
None yet
Development

No branches or pull requests

5 participants