Nest JS GraphQL “Cannot return null for non-nullable” [duplicate]

I tried to resolve one error in my study code, but failed. Then I just try to launch this code...

and the same situation...

Error looks like

  "errors": [
      "message": "Cannot return null for non-nullable field",
      "locations": [
          "line": 3,
          "column": 5
      "path": [
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: Cannot return null for non-nullable field",
            "    at completeValue (/home/innistry/Downloads/nest-master/sample/23-type-graphql/node_modules/graphql/execution/execute.js:560:13)",
            "    at /home/innistry/Downloads/nest-master/sample/23-type-graphql/node_modules/graphql/execution/execute.js:492:16",
            "    at process._tickCallback (internal/process/next_tick.js:68:7)"
  "data": null

Has someone ideas?



This is the fastest fix, just to launch.

import { Field, ID, ObjectType } from 'type-graphql';

export class Recipe {
  @Field(type => ID, { nullable: true })
  id?: string;

  @Field({ nullable: true })
  title?: string;

  @Field({ nullable: true })
  description?: string;

  @Field({ nullable: true })
  creationDate?: Date;

  @Field(type => [String], { nullable: true })
  ingredients?: string[];


Make the property nullable or make sure you don't return null as the value.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.