How to resolve Schema validation failed in AWS Graphql Schema Transformer v1 to v2

  Kiến thức lập trình

I had an old project which had the following schema:

type User @model {
  id: ID!
  username: String!
  email: String!
  imageUri: String
  posts: [Post] @connection(keyName: "byUser", fields: ["id"])
}

type Post @model @key(name: "byUser", fields: ["userID"]) {
  id: ID!
  videoUri: String!
  description: String!

  userID: ID!
  user: User @connection(fields: ["userID"])

  songID: ID!
  song: Song @connection(fields: ["songID"])
}

type Song @model {
  id: ID!
  name: String!
  imageUri: String
}

But when I tried changing the code or transform the code v2, I started having the error below, when I try using amplify update api:

Schema validation failed.

Unknown argument “fields” on directive “@index”.

GraphQL request:13:41
12 | description: String!
13 | byUser: [Post] @index(name: “byUser”, fields: [“userID”])
| ^
14 | userID: ID!

Please, what’s the right code to resolve the issue?

LEAVE A COMMENT