Validation error of type SubSelectionRequired: Sub selection required for type null of field

0

I'm trying to getUser with Id through Amplify.API

My schema :

type User @model @searchable @auth(rules: [{ allow: owner,ownerField: "id", operations: [create, read, delete, update]}, { allow: public, operations: [read, update] }]){
    id: ID!
    name:String!
    username: String!

    posts: [Post]!@hasMany

    notification: [Notification]!@hasMany

    searchHistory: [Search]!@hasMany

}

type Notification @model @auth(rules: [{ allow: owner,ownerField: "forUser", operations: [create, read, delete, update]},{ allow: public , operations: [create, read, delete, update]}]) {
    content: String!

    byUser: User

    forUser: User! @belongsTo
}


type Search @model @searchable @auth(rules: [{ allow: owner,ownerField: "user", operations: [create, read, delete, update]},{ allow: public , operations: [create, read, delete, update]}]) {
    id: ID!
    searchValue: String!
    user: User! @belongsTo
}

type Post @model @searchable @auth(rules: [{ allow: owner,ownerField: "byUser", operations: [create, read, delete, update]}, { allow: public, operations: [create, read, delete, update] }]){
    id: ID!

    title: String!

    byUser: User! @belongsTo


}

Error:

[{"locations":[{"column":9,"line":10}],"message":"Validation error of type SubSelectionRequired: Sub selection required for type null of field forUser @ \u0027getUser/notification/items/forUser\u0027"},{"locations":[{"column":9,"line":38}],"message":"Validation error of type SubSelectionRequired: Sub selection required for type null of field user @ \u0027getUser/searchHistory/items/user\u0027"}]

Look I'm getting this when I'm adding auth rules, but why I'm not getting for Post model, post has also byUser: User! @belongsTo as a owner? why I'm getting for only notification and search?

Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen