Reputation: 1088
I have a graphql schema in Amplify with a simple Model. I get the error "Cannot return null for non-nullable field Organisation.id." when I try to fetch a valid ID, why?
Model
type Organisation
@model
{
id: ID!
name: String!
}
Query:
const org = await API.graphql(graphqlOperation(getOrganisationQuery, { id: 'f18881fb-4cf3-42de-84b1-9396f932938d' }));
Error: Cannot return null for non-nullable field Organisation.id.
Upvotes: 1
Views: 626
Reputation: 312
!
indicates that the returning value cannot be null for the field
remove the exclamation symbol !
to remove the error
make sure the value is present for the field
Upvotes: 2