graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Error on generating code for non nullable ICollection<Guid>

Open mwilde opened this issue 3 years ago • 7 comments

Describe the bug

If you have a DTO (maybe record) with a non nullable property ICollection<Guid> MyValues than the generated schema.graphql looks great: input MyDtoInput { myValues: [UUID!]! }

But the code generator for StrawberryShake throws an error on generating process: Non-Nullable-Feld "_value_myValues" muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie eine Deklaration von "Feld" als Nullable.

To get the process working the only possibility is to mark ICollection<Guid>? MyValues as nullable.

Steps to reproduce

  1. Create DTO public record MyDto( ICollection<Guid> MyValues);
  2. Create DTO public record MyInput( MyDto MyValue)
  3. Update schema with dotnet graphql update
  4. Create mutation mutation SendMyInput( $dto:MyInput!){ sendMyInput( input: $dto ) }
  5. The code generator throws the error

Relevant log output

Non-Nullable-Feld "_value_myValues" muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie eine Deklaration von "Feld" als Nullable.

Product

Hot Chocolate, Strawberry Shake

Version

12.6.0

mwilde avatar Feb 08 '22 09:02 mwilde

@mwilde can you share query and schema?

PascalSenn avatar Feb 08 '22 11:02 PascalSenn

@PascalSenn here is my schema and the mutation:

schema { mutation: Mutation }

type Mutation { setMyValue(input: SetMyValueInput!): SetMyValuePayload! }

type SetMyValuePayload { errors: [UserError!]! }

scalar UUID

type UserError { message: String! }

input SetMyValueInput { myValue: MyDtoInput! }

input MyDtoInput { myIds: [UUID!]! }

mutation SetMyValue( $dto:SetMyValueInput!){ setMyValue( input: $dto ){ errors { message } } }

mwilde avatar Feb 08 '22 13:02 mwilde

@PascalSenn the same error occurs if you have a collection of type Enum.

mwilde avatar Feb 15 '22 08:02 mwilde

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 04 '22 00:05 stale[bot]

@PascalSenn what is the status here?

mwilde avatar May 04 '22 06:05 mwilde

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 03 '22 07:07 stale[bot]

@PascalSenn what is the status here?

mwilde avatar Jul 04 '22 06:07 mwilde

I'm running into the same issue on version 12.12.1, is there any update @PascalSenn @tobias-tengler ?

QuentonB avatar Oct 05 '22 22:10 QuentonB