Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI doesn't register object union with null #3128

Open
2 of 4 tasks
adamghowiba opened this issue Feb 7, 2024 · 1 comment
Open
2 of 4 tasks

CLI doesn't register object union with null #3128

adamghowiba opened this issue Feb 7, 2024 · 1 comment

Comments

@adamghowiba
Copy link

adamghowiba commented Feb 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Using a union type with null. IE string | null

Minimum reproduction code

NA

Steps to reproduce

No response

Expected behavior

Using the GraphQL CLI, set an object property to a union containing null

import { User} from '@prisma/client';


@ObjectType()
export class UserEntity implements User {
  @Field(() => ID)
  id!: number;

  first_name!: string;

  middle_name!: string | null; // <-- Will not set the output object to be nullable. 
  
  // Setting middle_name to undefined will throw a type error
  // because prisma will always return null for undefined fields
}

Package version

12.0.11

Graphql version

graphql: 16.8.1

NestJS version

12.0.11

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@adamghowiba
Copy link
Author

adamghowiba commented Feb 7, 2024

After looking again I saw #1072 spoke about this back in 2020, any chance we'd be willing to revisit this? ☹️ @kamilmysliwiec

If all else fails, is there any easy way to fork the NestJS GraphQL CLI to accommodate null unions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant