amazon dynamodb – Amplify graphql @belongsTo returning null

I have these two tables, the owner field in NFT table has a belongsTo relationship with the User, but the query is returning null even tho the User exists in the DB. What am I doing wrong here

type User
  @model
  @auth(
    rules: [
      {allow: public, provider: apiKey, operations: [read]}
      {allow: public, provider: iam, operations: [read]}
      {allow: private, operations: [read]}
      {allow: owner}
    ]
  ) {
  id: ID!
  username: String
    @index(
      name: "usersByUsername",
      queryField: "usersByUsername",
      sortKeyFields: ["createdAt"]
    )
  email: String
    @index(
      name: "usersByEmail",
      queryField: "usersByEmail",
      sortKeyFields: ["createdAt"]
    )
  address: String
  gender: String
  interest: [String]
  profileImage: String
  firstName: String
  lastName: String
  OwnedNfts: [Nft] 
    @hasMany(
      indexName: "nftsByOwnerId",
      fields: "id"
    )
  createdAt: AWSDateTime!
  updatedAt: AWSDateTime!
}

type Nft
  @model
  @auth(
    rules: [
      {allow: public, provider: apiKey, operations: [read]}
      {allow: public, provider: iam, operations: [read, update]}
      {allow: private, operations: [read, update]}
      {allow: owner}
    ]
  ) {
  id: ID!
  private: Boolean
  mediaUrl: String!
  mediaUrlCompressed: String
  thumbnail: String
  category: String!
    @index(
      name: "nftsByCategoryCreatedAt",
      queryField: "nftsByCategoryCreatedAt",
      sortKeyFields: ["createdAt"]
    )
  ownerId: ID
    @index(
      name: "nftsByOwnerId",
      queryField: "nftsByOwnerId"
      sortKeyFields: ["createdAt"]
    )
    @index(
      name: "nftsByOwnerIdRating",
      queryField: "nftsByOwnerIdRating",
      sortKeyFields: ["rating"]
    )
    @index(
      name: "nftsByOwnerIdLikes",
      queryField: "nftsByOwnerIdLikes",
      sortKeyFields: ["likes"]
    )
    @index(
      name: "nftsByOwnerIdReported",
      queryField: "nftsByOwnerIdReported",
      sortKeyFields: ["reportedCount"]
    )
  owner: User
   @belongsTo(
     fields: ["ownerId"]
   )
  createdAt: AWSDateTime!
  updatedAt: AWSDateTime!
}

Read more here: Source link