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.