'Amplify @hasMany relationship return null

This are my first question here.

I have this schema on amplify

type Products @model {
  id: ID!
  title: String!
  description: String!
  variations: [Variation] @hasMany(indexName: "byProduct", fields: ["id"])
}

type Variation @model {
  id: ID!
  productId: ID! @index(name: "byProduct")
  name: String!
  image: String!
  quantity: Int!
}

When I test the query on AppSync this return the variations, but when I use

const result = (await API.graphql(graphqlOperation(gql.listProducts))).data.listProducts.items;

or with DataStore like this

await DataStore.query(Products)

return a null or empty

    variations: { nextToken: null, startedAt: null },

Someone with the same issue ? or maybe I was missing something?

thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source