MarkK
MarkK

Reputation: 1088

Schema graphql error gives 'Cannot return null for non-nullable field Organisation.id' why?

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

Answers (1)

KaranV
KaranV

Reputation: 312

! indicates that the returning value cannot be null for the field

Fix 1

remove the exclamation symbol ! to remove the error

Fix 2

make sure the value is present for the field

Upvotes: 2

Related Questions