diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/TypeMapperGenerator_ComplexDataHandler.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/TypeMapperGenerator_ComplexDataHandler.cs
index d66e9775dde..17ab51237d5 100644
--- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/TypeMapperGenerator_ComplexDataHandler.cs
+++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/TypeMapperGenerator_ComplexDataHandler.cs
@@ -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();
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/EntityOrIdGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/EntityOrIdGeneratorTests.cs
index 421a4339da9..276028f63af 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/EntityOrIdGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/EntityOrIdGeneratorTests.cs
@@ -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\")");
+ }
}
}
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap
new file mode 100644
index 00000000000..87ba15281cb
--- /dev/null
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap
@@ -0,0 +1,1190 @@
+// ReSharper disable BuiltInTypeReferenceStyle
+// ReSharper disable RedundantNameQualifier
+// ReSharper disable ArrangeObjectCreationWhenTypeEvident
+// ReSharper disable UnusedType.Global
+// ReSharper disable PartialTypeWithSinglePart
+// ReSharper disable UnusedMethodReturnValue.Local
+// ReSharper disable ConvertToAutoProperty
+// ReSharper disable UnusedMember.Global
+// ReSharper disable SuggestVarOrType_SimpleTypes
+// ReSharper disable InconsistentNaming
+
+// FooClient
+
+//
+#nullable enable
+
+namespace Foo.Bar
+{
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFooResult : global::System.IEquatable, IGetFooResult
+ {
+ public GetFooResult(global::System.Collections.Generic.IReadOnlyList? foo)
+ {
+ Foo = foo;
+ }
+
+ public global::System.Collections.Generic.IReadOnlyList? Foo
+ {
+ get;
+ }
+
+ public virtual global::System.Boolean Equals(GetFooResult? other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ if (other.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return (global::StrawberryShake.Helper.ComparisonHelper.SequenceEqual(Foo, other.Foo));
+ }
+
+ public override global::System.Boolean Equals(global::System.Object? obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ if (obj.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return Equals((GetFooResult)obj);
+ }
+
+ public override global::System.Int32 GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 5;
+ if (Foo != null)
+ {
+ foreach (var Foo_elm in Foo)
+ {
+ if (Foo_elm != null)
+ {
+ hash ^= 397 * Foo_elm.GetHashCode();
+ }
+ }
+ }
+
+ return hash;
+ }
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFoo_Foo_Baz : global::System.IEquatable, IGetFoo_Foo_Baz
+ {
+ public GetFoo_Foo_Baz(global::System.Int32 id)
+ {
+ Id = id;
+ }
+
+ public global::System.Int32 Id
+ {
+ get;
+ }
+
+ public virtual global::System.Boolean Equals(GetFoo_Foo_Baz? other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ if (other.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return (Id == other.Id);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object? obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ if (obj.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return Equals((GetFoo_Foo_Baz)obj);
+ }
+
+ public override global::System.Int32 GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 5;
+ hash ^= 397 * Id.GetHashCode();
+ return hash;
+ }
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFoo_Foo_Quox : global::System.IEquatable, IGetFoo_Foo_Quox
+ {
+ public GetFoo_Foo_Quox(global::System.Int32 foo)
+ {
+ Foo = foo;
+ }
+
+ public global::System.Int32 Foo
+ {
+ get;
+ }
+
+ public virtual global::System.Boolean Equals(GetFoo_Foo_Quox? other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ if (other.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return (Foo == other.Foo);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object? obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ if (obj.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return Equals((GetFoo_Foo_Quox)obj);
+ }
+
+ public override global::System.Int32 GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 5;
+ hash ^= 397 * Foo.GetHashCode();
+ return hash;
+ }
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFoo_Foo_Baz2 : global::System.IEquatable, IGetFoo_Foo_Baz2
+ {
+ public GetFoo_Foo_Baz2(global::System.Int32 id)
+ {
+ Id = id;
+ }
+
+ public global::System.Int32 Id
+ {
+ get;
+ }
+
+ public virtual global::System.Boolean Equals(GetFoo_Foo_Baz2? other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ if (other.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return (Id == other.Id);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object? obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ if (obj.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return Equals((GetFoo_Foo_Baz2)obj);
+ }
+
+ public override global::System.Int32 GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 5;
+ hash ^= 397 * Id.GetHashCode();
+ return hash;
+ }
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFoo_Foo_Quox2 : global::System.IEquatable, IGetFoo_Foo_Quox2
+ {
+ public GetFoo_Foo_Quox2(global::System.Int32 foo)
+ {
+ Foo = foo;
+ }
+
+ public global::System.Int32 Foo
+ {
+ get;
+ }
+
+ public virtual global::System.Boolean Equals(GetFoo_Foo_Quox2? other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ if (other.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return (Foo == other.Foo);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object? obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ if (obj.GetType() != GetType())
+ {
+ return false;
+ }
+
+ return Equals((GetFoo_Foo_Quox2)obj);
+ }
+
+ public override global::System.Int32 GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 5;
+ hash ^= 397 * Foo.GetHashCode();
+ return hash;
+ }
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public interface IGetFooResult
+ {
+ public global::System.Collections.Generic.IReadOnlyList? Foo
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public interface IGetFoo_Foo
+ {
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public interface IGetFoo_Foo_Baz : IGetFoo_Foo
+ {
+ public global::System.Int32 Id
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public interface IGetFoo_Foo_Quox : IGetFoo_Foo
+ {
+ public global::System.Int32 Foo
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public interface IGetFoo_Foo_Baz2 : IGetFoo_Foo
+ {
+ public global::System.Int32 Id
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public interface IGetFoo_Foo_Quox2 : IGetFoo_Foo
+ {
+ public global::System.Int32 Foo
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.OperationDocumentGenerator
+ ///
+ /// Represents the operation service of the GetFoo GraphQL operation
+ ///
+ /// query GetFoo {
+ /// foo {
+ /// __typename
+ /// ... on Baz {
+ /// id
+ /// }
+ /// ... on Quox {
+ /// foo
+ /// }
+ /// ... on Baz2 {
+ /// id
+ /// }
+ /// ... on Quox2 {
+ /// foo
+ /// }
+ /// ... on Baz {
+ /// id
+ /// }
+ /// ... on Baz2 {
+ /// id
+ /// }
+ /// }
+ /// }
+ ///
+ ///
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFooQueryDocument : global::StrawberryShake.IDocument
+ {
+ private GetFooQueryDocument()
+ {
+ }
+
+ public static GetFooQueryDocument Instance
+ {
+ get;
+ }
+
+ = new GetFooQueryDocument();
+ public global::StrawberryShake.OperationKind Kind => global::StrawberryShake.OperationKind.Query;
+ public global::System.ReadOnlySpan Body => new global::System.Byte[]{0x71, 0x75, 0x65, 0x72, 0x79, 0x20, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6f, 0x20, 0x7b, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x7b, 0x20, 0x5f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x2e, 0x2e, 0x2e, 0x20, 0x6f, 0x6e, 0x20, 0x42, 0x61, 0x7a, 0x20, 0x7b, 0x20, 0x69, 0x64, 0x20, 0x7d, 0x20, 0x2e, 0x2e, 0x2e, 0x20, 0x6f, 0x6e, 0x20, 0x51, 0x75, 0x6f, 0x78, 0x20, 0x7b, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x7d, 0x20, 0x2e, 0x2e, 0x2e, 0x20, 0x6f, 0x6e, 0x20, 0x42, 0x61, 0x7a, 0x32, 0x20, 0x7b, 0x20, 0x69, 0x64, 0x20, 0x7d, 0x20, 0x2e, 0x2e, 0x2e, 0x20, 0x6f, 0x6e, 0x20, 0x51, 0x75, 0x6f, 0x78, 0x32, 0x20, 0x7b, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x7d, 0x20, 0x2e, 0x2e, 0x2e, 0x20, 0x6f, 0x6e, 0x20, 0x42, 0x61, 0x7a, 0x20, 0x7b, 0x20, 0x69, 0x64, 0x20, 0x7d, 0x20, 0x2e, 0x2e, 0x2e, 0x20, 0x6f, 0x6e, 0x20, 0x42, 0x61, 0x7a, 0x32, 0x20, 0x7b, 0x20, 0x69, 0x64, 0x20, 0x7d, 0x20, 0x7d, 0x20, 0x7d};
+ public global::StrawberryShake.DocumentHash Hash
+ {
+ get;
+ }
+
+ = new global::StrawberryShake.DocumentHash("sha1Hash", "43715bb5e8ecbe7659e99dcb33abcf1ffeadff8e");
+ public override global::System.String ToString()
+ {
+#if NETSTANDARD2_0
+ return global::System.Text.Encoding.UTF8.GetString(Body.ToArray());
+#else
+ return global::System.Text.Encoding.UTF8.GetString(Body);
+#endif
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.OperationServiceGenerator
+ ///
+ /// Represents the operation service of the GetFoo GraphQL operation
+ ///
+ /// query GetFoo {
+ /// foo {
+ /// __typename
+ /// ... on Baz {
+ /// id
+ /// }
+ /// ... on Quox {
+ /// foo
+ /// }
+ /// ... on Baz2 {
+ /// id
+ /// }
+ /// ... on Quox2 {
+ /// foo
+ /// }
+ /// ... on Baz {
+ /// id
+ /// }
+ /// ... on Baz2 {
+ /// id
+ /// }
+ /// }
+ /// }
+ ///
+ ///
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFooQuery : global::Foo.Bar.IGetFooQuery
+ {
+ private readonly global::StrawberryShake.IOperationExecutor _operationExecutor;
+ public GetFooQuery(global::StrawberryShake.IOperationExecutor operationExecutor)
+ {
+ _operationExecutor = operationExecutor ?? throw new global::System.ArgumentNullException(nameof(operationExecutor));
+ }
+
+ global::System.Type global::StrawberryShake.IOperationRequestFactory.ResultType => typeof(IGetFooResult);
+ public async global::System.Threading.Tasks.Task> ExecuteAsync(global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var request = CreateRequest();
+ return await _operationExecutor.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
+ }
+
+ public global::System.IObservable> Watch(global::StrawberryShake.ExecutionStrategy? strategy = null)
+ {
+ var request = CreateRequest();
+ return _operationExecutor.Watch(request, strategy);
+ }
+
+ private global::StrawberryShake.OperationRequest CreateRequest()
+ {
+ return CreateRequest(null);
+ }
+
+ private global::StrawberryShake.OperationRequest CreateRequest(global::System.Collections.Generic.IReadOnlyDictionary? variables)
+ {
+ return new global::StrawberryShake.OperationRequest(id: GetFooQueryDocument.Instance.Hash.Value, name: "GetFoo", document: GetFooQueryDocument.Instance, strategy: global::StrawberryShake.RequestStrategy.Default);
+ }
+
+ global::StrawberryShake.OperationRequest global::StrawberryShake.IOperationRequestFactory.Create(global::System.Collections.Generic.IReadOnlyDictionary? variables)
+ {
+ return CreateRequest();
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.OperationServiceInterfaceGenerator
+ ///
+ /// Represents the operation service of the GetFoo GraphQL operation
+ ///
+ /// query GetFoo {
+ /// foo {
+ /// __typename
+ /// ... on Baz {
+ /// id
+ /// }
+ /// ... on Quox {
+ /// foo
+ /// }
+ /// ... on Baz2 {
+ /// id
+ /// }
+ /// ... on Quox2 {
+ /// foo
+ /// }
+ /// ... on Baz {
+ /// id
+ /// }
+ /// ... on Baz2 {
+ /// id
+ /// }
+ /// }
+ /// }
+ ///
+ ///
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public interface IGetFooQuery : global::StrawberryShake.IOperationRequestFactory
+ {
+ global::System.Threading.Tasks.Task> ExecuteAsync(global::System.Threading.CancellationToken cancellationToken = default);
+ global::System.IObservable> Watch(global::StrawberryShake.ExecutionStrategy? strategy = null);
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ClientGenerator
+ ///
+ /// Represents the FooClient GraphQL client
+ ///
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class FooClient : global::Foo.Bar.IFooClient
+ {
+ private readonly global::Foo.Bar.IGetFooQuery _getFoo;
+ public FooClient(global::Foo.Bar.IGetFooQuery getFoo)
+ {
+ _getFoo = getFoo ?? throw new global::System.ArgumentNullException(nameof(getFoo));
+ }
+
+ public static global::System.String ClientName => "FooClient";
+ public global::Foo.Bar.IGetFooQuery GetFoo => _getFoo;
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ClientInterfaceGenerator
+ ///
+ /// Represents the FooClient GraphQL client
+ ///
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public interface IFooClient
+ {
+ global::Foo.Bar.IGetFooQuery GetFoo
+ {
+ get;
+ }
+ }
+}
+
+namespace Foo.Bar.State
+{
+ // StrawberryShake.CodeGeneration.CSharp.Generators.EntityTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")]
+ public partial class BazEntity
+ {
+ public BazEntity(global::System.Int32 id = default !)
+ {
+ Id = id;
+ }
+
+ public global::System.Int32 Id
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.EntityTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")]
+ public partial class Baz2Entity
+ {
+ public Baz2Entity(global::System.Int32 id = default !)
+ {
+ Id = id;
+ }
+
+ public global::System.Int32 Id
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultDataFactoryGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFooResultFactory : global::StrawberryShake.IOperationResultDataFactory
+ {
+ private readonly global::StrawberryShake.IEntityStore _entityStore;
+ private readonly global::StrawberryShake.IEntityMapper _getFoo_Foo_BazFromBazEntityMapper;
+ private readonly global::StrawberryShake.IEntityMapper _getFoo_Foo_Baz2FromBaz2EntityMapper;
+ public GetFooResultFactory(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityMapper getFoo_Foo_BazFromBazEntityMapper, global::StrawberryShake.IEntityMapper getFoo_Foo_Baz2FromBaz2EntityMapper)
+ {
+ _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore));
+ _getFoo_Foo_BazFromBazEntityMapper = getFoo_Foo_BazFromBazEntityMapper ?? throw new global::System.ArgumentNullException(nameof(getFoo_Foo_BazFromBazEntityMapper));
+ _getFoo_Foo_Baz2FromBaz2EntityMapper = getFoo_Foo_Baz2FromBaz2EntityMapper ?? throw new global::System.ArgumentNullException(nameof(getFoo_Foo_Baz2FromBaz2EntityMapper));
+ }
+
+ global::System.Type global::StrawberryShake.IOperationResultDataFactory.ResultType => typeof(global::Foo.Bar.IGetFooResult);
+ public GetFooResult Create(global::StrawberryShake.IOperationResultDataInfo dataInfo, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null)
+ {
+ if (snapshot is null)
+ {
+ snapshot = _entityStore.CurrentSnapshot;
+ }
+
+ if (dataInfo is GetFooResultInfo info)
+ {
+ return new GetFooResult(MapIGetFoo_FooArray(info.Foo, snapshot));
+ }
+
+ throw new global::System.ArgumentException("GetFooResultInfo expected.");
+ }
+
+ private global::System.Collections.Generic.IReadOnlyList? MapIGetFoo_FooArray(global::System.Collections.Generic.IReadOnlyList? list, global::StrawberryShake.IEntityStoreSnapshot snapshot)
+ {
+ if (list is null)
+ {
+ return null;
+ }
+
+ var bars = new global::System.Collections.Generic.List();
+ foreach (global::StrawberryShake.EntityIdOrData? child in list)
+ {
+ bars.Add(MapIGetFoo_Foo(child, snapshot));
+ }
+
+ return bars;
+ }
+
+ private global::Foo.Bar.IGetFoo_Foo? MapIGetFoo_Foo(global::StrawberryShake.EntityIdOrData? data, global::StrawberryShake.IEntityStoreSnapshot snapshot)
+ {
+ if (data is null)
+ {
+ return null;
+ }
+
+ if (data.Value.EntityId is
+ {
+ }
+
+ )
+ {
+ return MapIGetFoo_FooData(data.Value.EntityId, snapshot);
+ }
+ else if (data.Value.Data is global::Foo.Bar.State.IBarData d)
+ {
+ return MapIGetFoo_FooEntity(d, snapshot);
+ }
+ else
+ {
+ throw new global::System.ArgumentOutOfRangeException();
+ }
+ }
+
+ private global::Foo.Bar.IGetFoo_Foo? MapIGetFoo_FooEntity(global::Foo.Bar.State.IBarData? data, global::StrawberryShake.IEntityStoreSnapshot snapshot)
+ {
+ if (data is null)
+ {
+ return null;
+ }
+
+ IGetFoo_Foo? returnValue;
+ if (data is global::Foo.Bar.State.QuoxData quox)
+ {
+ if (!quox.Foo.HasValue)
+ {
+ throw new global::System.ArgumentNullException();
+ }
+
+ returnValue = new global::Foo.Bar.GetFoo_Foo_Quox(quox.Foo!.Value);
+ }
+ else if (data is global::Foo.Bar.State.Quox2Data quox2)
+ {
+ if (!quox2.Foo.HasValue)
+ {
+ throw new global::System.ArgumentNullException();
+ }
+
+ returnValue = new global::Foo.Bar.GetFoo_Foo_Quox2(quox2.Foo!.Value);
+ }
+ else
+ {
+ throw new global::System.NotSupportedException();
+ }
+
+ return returnValue;
+ }
+
+ private global::Foo.Bar.IGetFoo_Foo? MapIGetFoo_FooData(global::StrawberryShake.EntityId? entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot)
+ {
+ if (entityId is null)
+ {
+ return null;
+ }
+
+ if (entityId.Value.Name.Equals("Baz", global::System.StringComparison.Ordinal))
+ {
+ return _getFoo_Foo_BazFromBazEntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException());
+ }
+
+ if (entityId.Value.Name.Equals("Baz2", global::System.StringComparison.Ordinal))
+ {
+ return _getFoo_Foo_Baz2FromBaz2EntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException());
+ }
+
+ throw new global::System.NotSupportedException();
+ }
+
+ global::System.Object global::StrawberryShake.IOperationResultDataFactory.Create(global::StrawberryShake.IOperationResultDataInfo dataInfo, global::StrawberryShake.IEntityStoreSnapshot? snapshot)
+ {
+ return Create(dataInfo, snapshot);
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInfoGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFooResultInfo : global::StrawberryShake.IOperationResultDataInfo
+ {
+ private readonly global::System.Collections.Generic.IReadOnlyCollection _entityIds;
+ private readonly global::System.UInt64 _version;
+ public GetFooResultInfo(global::System.Collections.Generic.IReadOnlyList? foo, global::System.Collections.Generic.IReadOnlyCollection entityIds, global::System.UInt64 version)
+ {
+ Foo = foo;
+ _entityIds = entityIds ?? throw new global::System.ArgumentNullException(nameof(entityIds));
+ _version = version;
+ }
+
+ public global::System.Collections.Generic.IReadOnlyList? Foo
+ {
+ get;
+ }
+
+ public global::System.Collections.Generic.IReadOnlyCollection EntityIds => _entityIds;
+ public global::System.UInt64 Version => _version;
+ public global::StrawberryShake.IOperationResultDataInfo WithVersion(global::System.UInt64 version)
+ {
+ return new GetFooResultInfo(Foo, _entityIds, version);
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFoo_Foo_BazFromBazEntityMapper : global::StrawberryShake.IEntityMapper
+ {
+ private readonly global::StrawberryShake.IEntityStore _entityStore;
+ public GetFoo_Foo_BazFromBazEntityMapper(global::StrawberryShake.IEntityStore entityStore)
+ {
+ _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore));
+ }
+
+ public GetFoo_Foo_Baz Map(global::Foo.Bar.State.BazEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null)
+ {
+ if (snapshot is null)
+ {
+ snapshot = _entityStore.CurrentSnapshot;
+ }
+
+ return new GetFoo_Foo_Baz(entity.Id);
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFoo_Foo_Baz2FromBaz2EntityMapper : global::StrawberryShake.IEntityMapper
+ {
+ private readonly global::StrawberryShake.IEntityStore _entityStore;
+ public GetFoo_Foo_Baz2FromBaz2EntityMapper(global::StrawberryShake.IEntityStore entityStore)
+ {
+ _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore));
+ }
+
+ public GetFoo_Foo_Baz2 Map(global::Foo.Bar.State.Baz2Entity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null)
+ {
+ if (snapshot is null)
+ {
+ snapshot = _entityStore.CurrentSnapshot;
+ }
+
+ return new GetFoo_Foo_Baz2(entity.Id);
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.JsonResultBuilderGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class GetFooBuilder : global::StrawberryShake.IOperationResultBuilder
+ {
+ private readonly global::StrawberryShake.IEntityStore _entityStore;
+ private readonly global::StrawberryShake.IEntityIdSerializer _idSerializer;
+ private readonly global::StrawberryShake.IOperationResultDataFactory _resultDataFactory;
+ private readonly global::StrawberryShake.Serialization.ILeafValueParser _intParser;
+ public GetFooBuilder(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer idSerializer, global::StrawberryShake.IOperationResultDataFactory resultDataFactory, global::StrawberryShake.Serialization.ISerializerResolver serializerResolver)
+ {
+ _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore));
+ _idSerializer = idSerializer ?? throw new global::System.ArgumentNullException(nameof(idSerializer));
+ _resultDataFactory = resultDataFactory ?? throw new global::System.ArgumentNullException(nameof(resultDataFactory));
+ _intParser = serializerResolver.GetLeafValueParser("Int") ?? throw new global::System.ArgumentException("No serializer for type `Int` found.");
+ }
+
+ public global::StrawberryShake.IOperationResult Build(global::StrawberryShake.Response response)
+ {
+ (IGetFooResult Result, GetFooResultInfo Info)? data = null;
+ global::System.Collections.Generic.IReadOnlyList? errors = null;
+ if (response.Exception is null)
+ {
+ try
+ {
+ if (response.Body != null)
+ {
+ if (response.Body.RootElement.TryGetProperty("data", out global::System.Text.Json.JsonElement dataElement) && dataElement.ValueKind == global::System.Text.Json.JsonValueKind.Object)
+ {
+ data = BuildData(dataElement);
+ }
+
+ if (response.Body.RootElement.TryGetProperty("errors", out global::System.Text.Json.JsonElement errorsElement))
+ {
+ errors = global::StrawberryShake.Json.JsonErrorParser.ParseErrors(errorsElement);
+ }
+ }
+ }
+ catch (global::System.Exception ex)
+ {
+ errors = new global::StrawberryShake.IClientError[]{new global::StrawberryShake.ClientError(ex.Message, exception: ex, extensions: new global::System.Collections.Generic.Dictionary{{"body", response.Body?.RootElement.ToString()}})};
+ }
+ }
+ else
+ {
+ errors = new global::StrawberryShake.IClientError[]{new global::StrawberryShake.ClientError(response.Exception.Message, exception: response.Exception, extensions: new global::System.Collections.Generic.Dictionary{{"body", response.Body?.RootElement.ToString()}})};
+ }
+
+ return new global::StrawberryShake.OperationResult(data?.Result, data?.Info, _resultDataFactory, errors);
+ }
+
+ private (IGetFooResult, GetFooResultInfo) BuildData(global::System.Text.Json.JsonElement obj)
+ {
+ var entityIds = new global::System.Collections.Generic.HashSet();
+ global::StrawberryShake.IEntityStoreSnapshot snapshot = default !;
+ global::System.Collections.Generic.IReadOnlyList? fooId = default !;
+ _entityStore.Update(session =>
+ {
+ fooId = DeserializeIBarDataArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo"), entityIds);
+ snapshot = session.CurrentSnapshot;
+ });
+ var resultInfo = new GetFooResultInfo(fooId, entityIds, snapshot.Version);
+ return (_resultDataFactory.Create(resultInfo), resultInfo);
+ }
+
+ private global::System.Collections.Generic.IReadOnlyList? DeserializeIBarDataArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds)
+ {
+ if (!obj.HasValue)
+ {
+ return null;
+ }
+
+ var bars = new global::System.Collections.Generic.List();
+ foreach (global::System.Text.Json.JsonElement child in obj.Value.EnumerateArray())
+ {
+ bars.Add(DeserializeIBarData(session, child, entityIds));
+ }
+
+ return bars;
+ }
+
+ private global::StrawberryShake.EntityIdOrData? DeserializeIBarData(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds)
+ {
+ if (!obj.HasValue)
+ {
+ return null;
+ }
+
+ var typename = obj.Value.GetProperty("__typename").GetString();
+ if (typename?.Equals("Baz", global::System.StringComparison.Ordinal) ?? false)
+ {
+ global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value);
+ if (entityId.Name.Equals("Baz", global::System.StringComparison.Ordinal))
+ {
+ if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BazEntity? entity))
+ {
+ session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(DeserializeNonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id"))));
+ }
+ else
+ {
+ session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(DeserializeNonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id"))));
+ }
+
+ return new global::StrawberryShake.EntityIdOrData(entityId);
+ }
+ }
+
+ if (typename?.Equals("Quox", global::System.StringComparison.Ordinal) ?? false)
+ {
+ return new global::StrawberryShake.EntityIdOrData(new global::Foo.Bar.State.QuoxData(typename, foo: DeserializeNonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo"))));
+ }
+
+ if (typename?.Equals("Baz2", global::System.StringComparison.Ordinal) ?? false)
+ {
+ global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value);
+ if (entityId.Name.Equals("Baz2", global::System.StringComparison.Ordinal))
+ {
+ if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.Baz2Entity? entity))
+ {
+ session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(DeserializeNonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id"))));
+ }
+ else
+ {
+ session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(DeserializeNonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id"))));
+ }
+
+ return new global::StrawberryShake.EntityIdOrData(entityId);
+ }
+ }
+
+ if (typename?.Equals("Quox2", global::System.StringComparison.Ordinal) ?? false)
+ {
+ return new global::StrawberryShake.EntityIdOrData(new global::Foo.Bar.State.Quox2Data(typename, foo: DeserializeNonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo"))));
+ }
+
+ throw new global::System.NotSupportedException();
+ }
+
+ private global::System.Int32 DeserializeNonNullableInt32(global::System.Text.Json.JsonElement? obj)
+ {
+ if (!obj.HasValue)
+ {
+ throw new global::System.ArgumentNullException();
+ }
+
+ return _intParser.Parse(obj.Value.GetInt32()!);
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.DataTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")]
+ public partial interface IBarData
+ {
+ global::System.String __typename
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.DataTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")]
+ public partial class QuoxData : IBarData
+ {
+ public QuoxData(global::System.String __typename, global::System.Int32? foo = default !)
+ {
+ this.__typename = __typename ?? throw new global::System.ArgumentNullException(nameof(__typename));
+ Foo = foo;
+ }
+
+ public global::System.String __typename
+ {
+ get;
+ }
+
+ public global::System.Int32? Foo
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.DataTypeGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")]
+ public partial class Quox2Data : IBarData
+ {
+ public Quox2Data(global::System.String __typename, global::System.Int32? foo = default !)
+ {
+ this.__typename = __typename ?? throw new global::System.ArgumentNullException(nameof(__typename));
+ Foo = foo;
+ }
+
+ public global::System.String __typename
+ {
+ get;
+ }
+
+ public global::System.Int32? Foo
+ {
+ get;
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.EntityIdFactoryGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class FooClientEntityIdFactory : global::StrawberryShake.IEntityIdSerializer
+ {
+ private static readonly global::System.Text.Json.JsonWriterOptions _options = new global::System.Text.Json.JsonWriterOptions()
+ {Indented = false};
+ public global::StrawberryShake.EntityId Parse(global::System.Text.Json.JsonElement obj)
+ {
+ global::System.String __typename = obj.GetProperty("__typename").GetString()!;
+ return __typename switch
+ {
+ "Baz" => ParseBazEntityId(obj, __typename), "Baz2" => ParseBaz2EntityId(obj, __typename), _ => throw new global::System.NotSupportedException()}
+
+ ;
+ }
+
+ public global::System.String Format(global::StrawberryShake.EntityId entityId)
+ {
+ return entityId.Name switch
+ {
+ "Baz" => FormatBazEntityId(entityId), "Baz2" => FormatBaz2EntityId(entityId), _ => throw new global::System.NotSupportedException()}
+
+ ;
+ }
+
+ private global::StrawberryShake.EntityId ParseBazEntityId(global::System.Text.Json.JsonElement obj, global::System.String type)
+ {
+ return new global::StrawberryShake.EntityId(type, obj.GetProperty("id").GetInt32()!);
+ }
+
+ private global::System.String FormatBazEntityId(global::StrawberryShake.EntityId entityId)
+ {
+ using var writer = new global::StrawberryShake.Internal.ArrayWriter();
+ using var jsonWriter = new global::System.Text.Json.Utf8JsonWriter(writer, _options);
+ jsonWriter.WriteStartObject();
+ jsonWriter.WriteString("__typename", entityId.Name);
+ jsonWriter.WriteNumber("id", (global::System.Int32)entityId.Value);
+ jsonWriter.WriteEndObject();
+ jsonWriter.Flush();
+ return global::System.Text.Encoding.UTF8.GetString(writer.GetInternalBuffer(), 0, writer.Length);
+ }
+
+ private global::StrawberryShake.EntityId ParseBaz2EntityId(global::System.Text.Json.JsonElement obj, global::System.String type)
+ {
+ return new global::StrawberryShake.EntityId(type, obj.GetProperty("id").GetInt32()!);
+ }
+
+ private global::System.String FormatBaz2EntityId(global::StrawberryShake.EntityId entityId)
+ {
+ using var writer = new global::StrawberryShake.Internal.ArrayWriter();
+ using var jsonWriter = new global::System.Text.Json.Utf8JsonWriter(writer, _options);
+ jsonWriter.WriteStartObject();
+ jsonWriter.WriteString("__typename", entityId.Name);
+ jsonWriter.WriteNumber("id", (global::System.Int32)entityId.Value);
+ jsonWriter.WriteEndObject();
+ jsonWriter.Flush();
+ return global::System.Text.Encoding.UTF8.GetString(writer.GetInternalBuffer(), 0, writer.Length);
+ }
+ }
+
+ // StrawberryShake.CodeGeneration.CSharp.Generators.StoreAccessorGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public partial class FooClientStoreAccessor : global::StrawberryShake.StoreAccessor
+ {
+ public FooClientStoreAccessor(global::StrawberryShake.IOperationStore operationStore, global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer entityIdSerializer, global::System.Collections.Generic.IEnumerable requestFactories, global::System.Collections.Generic.IEnumerable resultDataFactories): base(operationStore, entityStore, entityIdSerializer, requestFactories, resultDataFactories)
+ {
+ }
+ }
+}
+
+namespace Microsoft.Extensions.DependencyInjection
+{
+ // StrawberryShake.CodeGeneration.CSharp.Generators.DependencyInjectionGenerator
+ [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")]
+ public static partial class FooClientServiceCollectionExtensions
+ {
+ public static global::StrawberryShake.IClientBuilder AddFooClient(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::StrawberryShake.ExecutionStrategy strategy = global::StrawberryShake.ExecutionStrategy.NetworkOnly)
+ {
+ var serviceCollection = new global::Microsoft.Extensions.DependencyInjection.ServiceCollection();
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp =>
+ {
+ ConfigureClientDefault(sp, serviceCollection, strategy);
+ return new ClientServiceProvider(global::Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(serviceCollection));
+ });
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => new global::Foo.Bar.State.FooClientStoreAccessor(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)));
+ return new global::StrawberryShake.ClientBuilder("FooClient", services, serviceCollection);
+ }
+
+ private static global::Microsoft.Extensions.DependencyInjection.IServiceCollection ConfigureClientDefault(global::System.IServiceProvider parentServices, global::Microsoft.Extensions.DependencyInjection.ServiceCollection services, global::StrawberryShake.ExecutionStrategy strategy = global::StrawberryShake.ExecutionStrategy.NetworkOnly)
+ {
+ global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAddSingleton(services, sp => new global::StrawberryShake.OperationStore(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp =>
+ {
+ var clientFactory = global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(parentServices);
+ return new global::StrawberryShake.Transport.Http.HttpConnection(() => clientFactory.CreateClient("FooClient"));
+ });
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::Foo.Bar.State.GetFoo_Foo_BazFromBazEntityMapper>(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::Foo.Bar.State.GetFoo_Foo_Baz2FromBaz2EntityMapper>(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => new global::StrawberryShake.Serialization.SerializerResolver(global::System.Linq.Enumerable.Concat(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(parentServices), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp))));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::Foo.Bar.State.GetFooResultFactory>(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::Foo.Bar.State.GetFooBuilder>(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton>(services, sp => new global::StrawberryShake.OperationExecutor(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp), () => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp), strategy));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp));
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services);
+ global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp));
+ return services;
+ }
+
+ private class ClientServiceProvider : System.IServiceProvider, System.IDisposable
+ {
+ private readonly System.IServiceProvider _provider;
+ public ClientServiceProvider(System.IServiceProvider provider)
+ {
+ _provider = provider;
+ }
+
+ public object? GetService(System.Type serviceType)
+ {
+ return _provider.GetService(serviceType);
+ }
+
+ public void Dispose()
+ {
+ if (_provider is System.IDisposable d)
+ {
+ d.Dispose();
+ }
+ }
+ }
+ }
+}
+
+
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Query_With_Nested_Fragments.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Query_With_Nested_Fragments.snap
index 341826cfedf..4441e4d0355 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Query_With_Nested_Fragments.snap
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Query_With_Nested_Fragments.snap
@@ -644,7 +644,7 @@ namespace Foo.Bar.State
IGetAll_Listings_Items? returnValue;
if (data is global::Foo.Bar.State.AuctionData auction)
{
- if (auction.StartingPrice.HasValue)
+ if (!auction.StartingPrice.HasValue)
{
throw new global::System.ArgumentNullException();
}
@@ -653,7 +653,7 @@ namespace Foo.Bar.State
}
else if (data is global::Foo.Bar.State.OfferData offer)
{
- if (offer.Price.HasValue)
+ if (!offer.Price.HasValue)
{
throw new global::System.ArgumentNullException();
}