GraphQL: Cannot return null for non-nullable field Query.user
A resolver returned null (or threw) for a field the schema marks as non-null (!), so GraphQL nulls out the parent and reports this error.
Seen on:
REST API
Meaning
The real cause is usually in the resolver: not found records, an exception, a missing return, or a field name mismatch between the resolver result and the schema.
Common causes
- Resolver returns null/undefined (record not found, missing return)
- Resolver threw an error
- Returned object uses different property names
- Schema says non-null where null is legitimately possible
⚡ Quick fix
- Check server logs for the resolver error
- Return a value or make the field nullable
- Map database fields to schema names
Detailed fix by platform
JavaScript
- javascript
const resolvers = { Query: { user: async (_, { id }, { db }) => { const u = await db.user.findUnique({ where: { id } }); if (!u) throw new GraphQLError("User not found", { extensions: { code: "NOT_FOUND" } }); return u; } } };
How to diagnose
- Path — errors[].path
- Logs — Resolver exceptions
- Schema — Non-null correct?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in API
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026