79349513

Date: 2025-01-12 07:43:20
Score: 0.5
Natty:
Report link

If anyone is having this problem, then it is likely an issue with your typedef. The error says it all: somewhere there is a non-nullable field.

If you look at this user's typedef, it shows that

id: Int!

this means that id is a required field, and it must be an integer! The user then proceeds to fail to pass an Integer for the field of id. Hence, "cannot return null for non-nullable field." I don't know about every case, but I know that for me, with MongoDB, all I need to say is:

id: ID!

and something in the magical backend of mongoose takes care of populating that field with a unique ID.

That was an issue in the type definition.

And here is what the id field looks like in my Mongoose schema:

  id: {
     type: mongoose.Schema.Types.ObjectId,
     ref: "ID",
  },

That takes care of forming ID's for me.

So remember! If it "cannot return null for non-nullable field" somewhere, you are asking it to return null for a non-nullable field.

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jay Harrison Crawford