Skip to content

Commit

Permalink
Fixed nullability issue in mapper (#3549)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn authored Apr 19, 2021
1 parent 994db75 commit 93d04a3
Show file tree
Hide file tree
Showing 4 changed files with 1,241 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private IfBuilder GenerateComplexDataInterfaceIfClause(
block
.AddCode(IfBuilder
.New()
.SetCondition($"{matchedTypeName}.{prop.Name}.HasValue")
.SetCondition($"!{matchedTypeName}.{prop.Name}.HasValue")
.AddCode(ExceptionBuilder.New(TypeNames.ArgumentNullException)))
.AddEmptyLine();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,53 @@ interface Bar {
",
"extend schema @key(fields: \"id\")");
}

[Fact]
public void NonNullableValueTypeId()
{
AssertResult(
@"
query GetFoo {
foo {
... on Baz {
id
}
... on Quox {
foo
}
... on Baz2 {
id
}
... on Quox2 {
foo
}
}
}
",
@"
type Query {
foo: [Bar]
}
type Baz {
id: Int!
}
type Baz2 {
id: Int!
}
type Quox {
foo: Int!
}
type Quox2 {
foo: Int!
}
union Bar = Baz | Quox | Baz2 | Quox2
",
"extend schema @key(fields: \"id\")");
}
}
}
Loading

0 comments on commit 93d04a3

Please sign in to comment.