Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
166
rated 0 times [  169] [ 3]  / answers: 1 / hits: 12793  / 5 Years ago, fri, september 27, 2019, 12:00:00

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



https://github.com/nestjs/nest/tree/master/sample/23-type-graphql



and the same situation...



Error looks like



{
errors: [
{
message: Cannot return null for non-nullable field Recipe.id.,
locations: [
{
line: 3,
column: 5
}
],
path: [
recipe,
id
],
extensions: {
code: INTERNAL_SERVER_ERROR,
exception: {
stacktrace: [
Error: Cannot return null for non-nullable field Recipe.id.,
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?


More From » node.js

 Answers
4

This is the fastest fix, just to launch.



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

@ObjectType()
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[];
}


[#6098] Wednesday, September 25, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alexandreah

Total Points: 720
Total Questions: 85
Total Answers: 90

Location: Central African Republic
Member since Fri, Jun 5, 2020
4 Years ago
alexandreah questions
Mon, Aug 9, 21, 00:00, 3 Years ago
Wed, Jan 8, 20, 00:00, 5 Years ago
Mon, Dec 16, 19, 00:00, 5 Years ago
Thu, Aug 29, 19, 00:00, 5 Years ago
;