Amplify-js: Wrong schema? Type mismatch for Index Key

Created on 24 Dec 2019  路  6Comments  路  Source: aws-amplify/amplify-js

When i use:

await DataStore.save(
          new User({
            firstname: "John",
            lastname: "Doe"
          })
        )

The request to the graphql api in appsync contains: userStatusId: null. I don麓t want that field at the time of creating a user. So how do i get rid of it? A user can have one status. A status can be in many users. When i query with DataStore.query(User) I麓d like to have all the relational fields like status in it. This parts works when using the schema below.

type User @model {
  id: ID!
  firstname: String
  lastname: String!
  status: Status @connection(name: "StatusUsers")
}

type Status @model {
  id: ID!
  users: [User] @connection(name: "StatusUsers")
  name: String
}

thanks

DataStore bug

All 6 comments

Hi! I have reported the same new API/Datastore plugins behaviour miss-alignment here: https://github.com/aws-amplify/amplify-cli/issues/3109

@benjamin79 Where are you getting the Type mismatch index key error? Do you have sample code or repo?

I get the error in the browser console when i run Datastore.save... You just can add the models above from a project you already have and run the Datastore.save and you see the error. But i can make a repo next week if you still need it.

Don麓t you think it might be the reason what Soek22 described?

@ashika01 I am getting exactly same error on Amplify-iOS plugin, as stated here: https://github.com/aws-amplify/amplify-ios/issues/284 (with references to the source code where the problem is located)

I think it is a behaviour miss-alignment that breaks previously deployed backends, making them unable to work with the new API/Datastore plugins. Because of that, I have opened a more "generic" issue on the amplify-cli repo: https://github.com/aws-amplify/amplify-cli/issues/3109

Thanks, we'll look into this together with the CLI to better support previously deployed backends

Closing this issue since it has to be tracked from Amplify CLI. https://github.com/aws-amplify/amplify-cli/issues/3109.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simon998yang picture simon998yang  路  3Comments

oste picture oste  路  3Comments

TheRealRed7 picture TheRealRed7  路  3Comments

guanzo picture guanzo  路  3Comments

DougWoodCDS picture DougWoodCDS  路  3Comments