My schema has
type Query {
me: User
}
And my me resolver is returning null if the user is not logging it. But I get this error
debugMessage: Cannot return null for non-nullable field User.id.
Shouldn't I be allowed to return null in this case?
I was able to circumvent this by creating a a custom type and returning it instead
type Query {
me: mePayload
}
type mePayload {
user: User
}
This allows me to return null
Can you show us your User model type?
type User @model {
id: ID! <--- is the reason probably
}
Are you returning null or are you returning a user without data?
I think the issue you are having is a combination of what @eriktisme and @joskfg said.
Make sure to return null from the me field, not an empty User.
Closing as this looks like expected behaviour.
Most helpful comment
Can you show us your User model type?