diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator.cs index c10f15b0359..ce704e34628 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator.cs @@ -210,11 +210,13 @@ private void AddDeserializeMethod( .SetType(TypeNames.JsonElement.MakeNullable()); } + var isNonNull = typeReference.IsNonNull(); + var jsonElementNullCheck = IfBuilder .New() .SetCondition($"!{Obj}.HasValue") .AddCode( - typeReference.IsNonNull() + isNonNull ? ExceptionBuilder.New(TypeNames.ArgumentNullException) : CodeLineBuilder.From("return null;")); @@ -228,7 +230,7 @@ private void AddDeserializeMethod( .New() .SetCondition($"{Obj}.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null") .AddCode( - typeReference.IsNonNull() + isNonNull ? ExceptionBuilder.New(TypeNames.ArgumentNullException) : CodeLineBuilder.From("return null;")); @@ -236,7 +238,7 @@ private void AddDeserializeMethod( .AddCode(jsonElementNullValueKindCheck) .AddEmptyLine(); - AddDeserializeMethodBody(classBuilder, methodBuilder, typeReference, processed); + AddDeserializeMethodBody(classBuilder, methodBuilder, typeReference, processed, isNonNull); } } @@ -244,7 +246,8 @@ private void AddDeserializeMethodBody( ClassBuilder classBuilder, MethodBuilder methodBuilder, ITypeDescriptor typeDescriptor, - HashSet processed) + HashSet processed, + bool isNonNull) { switch (typeDescriptor) { @@ -261,23 +264,24 @@ private void AddDeserializeMethodBody( classBuilder, methodBuilder, d, - processed); + processed, + isNonNull); break; case ComplexTypeDescriptor { Kind: TypeKind.AbstractData } d: - AddDataTypeDeserializerMethod(classBuilder, methodBuilder, d, processed); + AddDataTypeDeserializerMethod(classBuilder, methodBuilder, d, processed, isNonNull); break; case ComplexTypeDescriptor { Kind: TypeKind.Data } d: - AddDataTypeDeserializerMethod(classBuilder, methodBuilder, d, processed); + AddDataTypeDeserializerMethod(classBuilder, methodBuilder, d, processed, isNonNull); break; case INamedTypeDescriptor { Kind: TypeKind.Entity } d: - AddUpdateEntityMethod(classBuilder, methodBuilder, d, processed); + AddUpdateEntityMethod(classBuilder, methodBuilder, d, processed, isNonNull); break; case NonNullTypeDescriptor d: - AddDeserializeMethodBody(classBuilder, methodBuilder, d.InnerType, processed); + AddDeserializeMethodBody(classBuilder, methodBuilder, d.InnerType, processed, isNonNull); break; default: @@ -285,6 +289,18 @@ private void AddDeserializeMethodBody( } } + /// + /// Builds the fallback that is reached when the transport returns a concrete + /// __typename that is unknown to the generated abstract type mapping (for example + /// a union or interface member that was added to the server after the client was + /// generated). For a nullable position the unknown value degrades to null, + /// for a non-null position it remains an error. + /// + private static ICode CreateUnknownTypeFallback(bool isNonNull) + => isNonNull + ? ExceptionBuilder.New(TypeNames.NotSupportedException) + : CodeLineBuilder.From("return null;"); + private static MethodCallBuilder BuildUpdateMethodCall(PropertyDescriptor property) { var propertyAccessor = MethodCallBuilder diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_DeserializeDataType.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_DeserializeDataType.cs index b1bf8a189aa..bb1120e11cf 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_DeserializeDataType.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_DeserializeDataType.cs @@ -15,11 +15,15 @@ private void AddDataTypeDeserializerMethod( ClassBuilder classBuilder, MethodBuilder methodBuilder, ComplexTypeDescriptor complexTypeDescriptor, - HashSet processed) + HashSet processed, + bool isNonNull) { if (complexTypeDescriptor is InterfaceTypeDescriptor interfaceTypeDescriptor) { - AddInterfaceDataTypeDeserializerToMethod(methodBuilder, interfaceTypeDescriptor); + AddInterfaceDataTypeDeserializerToMethod( + methodBuilder, + interfaceTypeDescriptor, + isNonNull); } else { @@ -42,7 +46,8 @@ private void AddDataTypeDeserializerMethod( private void AddInterfaceDataTypeDeserializerToMethod( MethodBuilder methodBuilder, - InterfaceTypeDescriptor interfaceTypeDescriptor) + InterfaceTypeDescriptor interfaceTypeDescriptor, + bool isNonNull) { methodBuilder.AddCode( AssignmentBuilder @@ -77,7 +82,7 @@ private void AddInterfaceDataTypeDeserializerToMethod( methodBuilder .AddEmptyLine() - .AddCode(ExceptionBuilder.New(TypeNames.NotSupportedException)); + .AddCode(CreateUnknownTypeFallback(isNonNull)); } private MethodCallBuilder CreateBuildDataStatement(ObjectTypeDescriptor concreteType) diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_EntityOrDataType.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_EntityOrDataType.cs index 02aa1997562..c68c990da98 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_EntityOrDataType.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_EntityOrDataType.cs @@ -12,11 +12,15 @@ private void AddEntityOrDataTypeDeserializerMethod( ClassBuilder classBuilder, MethodBuilder methodBuilder, ComplexTypeDescriptor complexTypeDescriptor, - HashSet processed) + HashSet processed, + bool isNonNull) { if (complexTypeDescriptor is InterfaceTypeDescriptor interfaceTypeDescriptor) { - AddEntityDataTypeDeserializerToMethod(methodBuilder, interfaceTypeDescriptor); + AddEntityDataTypeDeserializerToMethod( + methodBuilder, + interfaceTypeDescriptor, + isNonNull); } else { @@ -28,7 +32,8 @@ private void AddEntityOrDataTypeDeserializerMethod( private void AddEntityDataTypeDeserializerToMethod( MethodBuilder methodBuilder, - InterfaceTypeDescriptor interfaceTypeDescriptor) + InterfaceTypeDescriptor interfaceTypeDescriptor, + bool isNonNull) { methodBuilder.AddCode( AssignmentBuilder @@ -92,6 +97,6 @@ private void AddEntityDataTypeDeserializerToMethod( methodBuilder .AddEmptyLine() - .AddCode(ExceptionBuilder.New(TypeNames.NotSupportedException)); + .AddCode(CreateUnknownTypeFallback(isNonNull)); } } diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs index 278698482ad..1a13697d2c7 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using StrawberryShake.CodeGeneration.CSharp.Builders; using StrawberryShake.CodeGeneration.Descriptors.TypeDescriptors; using StrawberryShake.CodeGeneration.Extensions; @@ -15,42 +16,41 @@ private void AddUpdateEntityMethod( ClassBuilder classBuilder, MethodBuilder methodBuilder, INamedTypeDescriptor namedTypeDescriptor, - HashSet processed) + HashSet processed, + bool isNonNull) { - methodBuilder.AddCode( - AssignmentBuilder - .New() - .SetLeftHandSide($"{TypeNames.EntityId} {EntityId}") - .SetRightHandSide( - MethodCallBuilder - .Inline() - .SetMethodName(GetFieldName(IdSerializer), "Parse") - .AddArgument($"{Obj}.Value"))); - - methodBuilder.AddCode( - MethodCallBuilder - .New() - .SetMethodName(EntityIds, nameof(List.Add)) - .AddArgument(EntityId)); - - methodBuilder.AddEmptyLine(); - if (namedTypeDescriptor is InterfaceTypeDescriptor interfaceTypeDescriptor) { - // If the type is an interface + // If the type is an interface we first read the concrete __typename and + // only parse the entity id for a member that is known to this client. A + // member that is unknown (for example one added to the server after the + // client was generated) degrades to the fallback instead of failing the + // whole result. + methodBuilder.AddCode( + AssignmentBuilder + .New() + .SetLeftHandSide($"var {Typename}") + .SetRightHandSide(MethodCallBuilder + .Inline() + .SetMethodName(Obj, "Value", nameof(JsonElement.GetProperty)) + .AddArgument(WellKnownNames.TypeName.AsStringToken()) + .Chain(x => x.SetMethodName(nameof(JsonElement.GetString))))); + foreach (var concreteType in interfaceTypeDescriptor.ImplementedBy) { methodBuilder .AddEmptyLine() - .AddCode(CreateUpdateEntityStatement(concreteType) - .AddCode($"return {EntityId};")); + .AddCode(CreateUpdateEntityByTypenameStatement(concreteType)); } methodBuilder.AddEmptyLine(); - methodBuilder.AddCode(ExceptionBuilder.New(TypeNames.NotSupportedException)); + methodBuilder.AddCode(CreateUnknownTypeFallback(isNonNull)); } else if (namedTypeDescriptor is ObjectTypeDescriptor objectTypeDescriptor) { + methodBuilder.AddCode(CreateParseEntityIdStatement()); + methodBuilder.AddEmptyLine(); + BuildTryGetEntityIf( CreateEntityType( objectTypeDescriptor.Name, @@ -65,6 +65,22 @@ private void AddUpdateEntityMethod( AddRequiredDeserializeMethods(namedTypeDescriptor, classBuilder, processed); } + private static ICode CreateParseEntityIdStatement() + => CodeBlockBuilder + .New() + .AddCode(AssignmentBuilder + .New() + .SetLeftHandSide($"{TypeNames.EntityId} {EntityId}") + .SetRightHandSide( + MethodCallBuilder + .Inline() + .SetMethodName(GetFieldName(IdSerializer), "Parse") + .AddArgument($"{Obj}.Value"))) + .AddCode(MethodCallBuilder + .New() + .SetMethodName(EntityIds, nameof(List.Add)) + .AddArgument(EntityId)); + private IfBuilder CreateUpdateEntityStatement( ObjectTypeDescriptor concreteType) { @@ -90,6 +106,31 @@ private IfBuilder CreateUpdateEntityStatement( .AddEmptyLine(); } + private IfBuilder CreateUpdateEntityByTypenameStatement( + ObjectTypeDescriptor concreteType) + { + var ifStatement = IfBuilder + .New() + .SetCondition( + $"{Typename}?.Equals(\"{concreteType.Name}\", " + + $"{TypeNames.OrdinalStringComparison}) ?? false"); + + var entityTypeName = CreateEntityType( + concreteType.Name, + concreteType.RuntimeType.NamespaceWithoutGlobal); + + var ifBuilder = BuildTryGetEntityIf(entityTypeName) + .AddCode(CreateEntityConstructorCall(concreteType, false)) + .AddElse(CreateEntityConstructorCall(concreteType, true)); + + return ifStatement + .AddCode(CreateParseEntityIdStatement()) + .AddEmptyLine() + .AddCode(ifBuilder) + .AddEmptyLine() + .AddCode($"return {EntityId};"); + } + private static ICode CreateEntityConstructorCall( ObjectTypeDescriptor objectType, bool assignDefault) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.Client.cs index 11c1125af34..6aea2c6e8bc 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.Client.cs @@ -983,7 +983,7 @@ public GetFooBuilder(global::StrawberryShake.IEntityStore entityStore, global::S return new global::StrawberryShake.EntityIdOrData(new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.Quox2Data(typename, foo: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs index a2488ca3500..8d53eb70952 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs @@ -1997,10 +1997,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -2013,8 +2014,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -2027,7 +2030,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -2063,7 +2066,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.FriendsConnectionData(typename, nodes: Update_IGetHero_Hero_Friends_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetHero_Hero_Friends_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -2099,10 +2102,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); @@ -2115,8 +2119,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); @@ -2129,7 +2135,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.Client.cs index 96f61381aa0..81a5b198c11 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.Client.cs @@ -974,10 +974,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), entity.Name)); @@ -990,8 +991,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), entity.Name)); @@ -1004,7 +1007,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.FriendsConnectionData? Deserialize_IGetHero_Hero_Friends(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1025,7 +1028,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.FriendsConnectionData(typename, nodes: Update_IGetHero_Hero_Friends_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetHero_Hero_Friends_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1061,10 +1064,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(entity.Friends, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1077,8 +1081,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(entity.Friends, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1091,7 +1097,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.Client.cs index 7d3abc4f7c5..55de3c788cb 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.Client.cs @@ -984,10 +984,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -1000,8 +1001,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -1014,7 +1017,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1050,7 +1053,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.FriendsConnectionData(typename, nodes: Update_IGetHero_Hero_Friends_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetHero_Hero_Friends_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1086,10 +1089,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); @@ -1102,8 +1106,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); @@ -1116,7 +1122,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsNoStoreTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsNoStoreTest.Client.cs index d1934d40b1b..4e3c36a6e8b 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsNoStoreTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsNoStoreTest.Client.cs @@ -940,7 +940,7 @@ public GetHeroBuilder(global::StrawberryShake.IOperationResultDataFactory? Deserialize_ICharacterDataArray(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.Client.cs index e5d6e404cc1..3f738684017 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.Client.cs @@ -963,10 +963,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -979,8 +980,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -993,7 +996,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1029,7 +1032,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.FriendsConnectionData(typename, nodes: Update_IGetHero_Hero_Friends_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetHero_Hero_Friends_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1065,10 +1068,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); @@ -1081,8 +1085,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); @@ -1095,7 +1101,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs index 04963147937..ad2c4a0de23 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs @@ -660,10 +660,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -676,8 +677,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -690,7 +693,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.Client.cs index 72e53f7fd4f..cba14523a8a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.Client.cs @@ -685,10 +685,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")))); @@ -701,8 +702,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")))); @@ -715,7 +718,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.Client.cs index 04fbd020dbb..7ffc4e2d25d 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.Client.cs @@ -1097,10 +1097,11 @@ public GetHeroWithFragmentIncludeAndSkipDirectiveBuilder(global::StrawberryShake return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")))); @@ -1113,8 +1114,10 @@ public GetHeroWithFragmentIncludeAndSkipDirectiveBuilder(global::StrawberryShake return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")))); @@ -1127,7 +1130,7 @@ public GetHeroWithFragmentIncludeAndSkipDirectiveBuilder(global::StrawberryShake return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1163,7 +1166,7 @@ public GetHeroWithFragmentIncludeAndSkipDirectiveBuilder(global::StrawberryShake return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.FriendsConnectionData(typename, includedPageInfo: Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends_IncludedPageInfo(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "includedPageInfo")), skippedPageInfo: Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends_SkippedPageInfo(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "skippedPageInfo"))); } - throw new global::System.NotSupportedException(); + return null; } private global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.PageInfoData? Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends_IncludedPageInfo(global::System.Text.Json.JsonElement? obj) @@ -1184,7 +1187,7 @@ public GetHeroWithFragmentIncludeAndSkipDirectiveBuilder(global::StrawberryShake return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.PageInfoData(typename, hasNextPage: Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "hasNextPage"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Boolean Deserialize_NonNullableBoolean(global::System.Text.Json.JsonElement? obj) @@ -1220,7 +1223,7 @@ public GetHeroWithFragmentIncludeAndSkipDirectiveBuilder(global::StrawberryShake return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.PageInfoData(typename, hasNextPage: Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "hasNextPage"))); } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.Client.cs index 337b18a5122..8063e0ae039 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.Client.cs @@ -3851,7 +3851,7 @@ public IntrospectionQueryBuilder(global::StrawberryShake.IEntityStore entityStor return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData(typename, name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))); } - throw new global::System.NotSupportedException(); + return null; } private global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData? Deserialize_IIntrospectionQuery___schema_SubscriptionType(global::System.Text.Json.JsonElement? obj) @@ -3872,7 +3872,7 @@ public IntrospectionQueryBuilder(global::StrawberryShake.IEntityStore entityStor return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData(typename, name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList Deserialize_NonNullableIIntrospectionQuery___schema_TypesNonNullableArray(global::System.Text.Json.JsonElement? obj) @@ -4070,7 +4070,7 @@ public IntrospectionQueryBuilder(global::StrawberryShake.IEntityStore entityStor return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData(typename, kind: Deserialize_NonNullable__TypeKind(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "kind")), name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), ofType: Deserialize_IIntrospectionQuery___schema_Types_Interfaces_OfType_OfType(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "ofType"))); } - throw new global::System.NotSupportedException(); + return null; } private global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData? Deserialize_IIntrospectionQuery___schema_Types_Interfaces_OfType_OfType(global::System.Text.Json.JsonElement? obj) @@ -4091,7 +4091,7 @@ public IntrospectionQueryBuilder(global::StrawberryShake.IEntityStore entityStor return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData(typename, kind: Deserialize_NonNullable__TypeKind(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "kind")), name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), ofType: Deserialize_IIntrospectionQuery___schema_Types_Interfaces_OfType_OfType_OfType(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "ofType"))); } - throw new global::System.NotSupportedException(); + return null; } private global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData? Deserialize_IIntrospectionQuery___schema_Types_Interfaces_OfType_OfType_OfType(global::System.Text.Json.JsonElement? obj) @@ -4112,7 +4112,7 @@ public IntrospectionQueryBuilder(global::StrawberryShake.IEntityStore entityStor return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData(typename, kind: Deserialize_NonNullable__TypeKind(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "kind")), name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))); } - throw new global::System.NotSupportedException(); + return null; } private global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection.State.__TypeData Deserialize_NonNullableIIntrospectionQuery___schema_Types_Fields_Type(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.Client.cs index 8d3dbdf5cbd..dfd9911c7bd 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.Client.cs @@ -665,10 +665,11 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); @@ -681,8 +682,10 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); @@ -695,7 +698,7 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.Client.cs index 8ad4327cfd3..f55d369a430 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.Client.cs @@ -809,10 +809,11 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Starship", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Starship", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.StarshipEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.StarshipEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); @@ -825,8 +826,10 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); @@ -839,8 +842,10 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return entityId; } - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); @@ -853,7 +858,7 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.Client.cs index 0286ba234e3..a637f20318f 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.Client.cs @@ -1100,10 +1100,11 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Starship", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Starship", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.StarshipEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.StarshipEntity()); @@ -1116,8 +1117,10 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_ISearchHero_Search_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -1130,8 +1133,10 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return entityId; } - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1144,7 +1149,7 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1180,7 +1185,7 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.FriendsConnectionData(typename, nodes: Update_ISearchHero_Search_Friends_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_ISearchHero_Search_Friends_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1216,10 +1221,11 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1232,8 +1238,10 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); @@ -1246,7 +1254,7 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa return entityId; } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnknownUnionMemberTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnknownUnionMemberTest.cs new file mode 100644 index 00000000000..0b63ae9e2aa --- /dev/null +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnknownUnionMemberTest.cs @@ -0,0 +1,68 @@ +using System.Text.Json; +using StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList; +using StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State; +using StrawberryShake.Serialization; + +namespace StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnknownUnionMember; + +public class StarWarsUnknownUnionMemberTest +{ + [Fact] + public void Build_Should_Skip_Element_When_Union_Member_Is_Unknown() + { + // arrange + // The generated client only knows the union members Human, Droid and Starship. + // The server returns an additional, unknown member ("Reptile") that was added + // after the client was generated (see issue #6415). + var builder = CreateSearchHeroBuilder(); + var response = CreateResponse( + """ + { + "data": { + "search": [ + { "__typename": "Droid", "id": "ZHJvaWQ6MQ==", "name": "R2-D2" }, + { "__typename": "Reptile", "id": "cmVwdGlsZTox", "name": "Slither" } + ] + } + } + """); + + // act + var result = builder.Build(response); + + // assert + result.EnsureNoErrors(); + Assert.Collection( + result.Data!.Search!, + known => Assert.Equal("R2-D2", Assert.IsType(known).Name), + unknown => Assert.Null(unknown)); + } + + private static SearchHeroBuilder CreateSearchHeroBuilder() + { + var entityStore = new EntityStore(); + var idSerializer = new StarWarsUnionListClientEntityIdFactory(); + + var droidNodeMapper = new SearchHero_Search_Friends_Nodes_DroidFromDroidEntityMapper(entityStore); + var humanNodeMapper = new SearchHero_Search_Friends_Nodes_HumanFromHumanEntityMapper(entityStore); + var starshipMapper = new SearchHero_Search_StarshipFromStarshipEntityMapper(entityStore); + var humanMapper = new SearchHero_Search_HumanFromHumanEntityMapper( + entityStore, + droidNodeMapper, + humanNodeMapper); + var droidMapper = new SearchHero_Search_DroidFromDroidEntityMapper(entityStore); + + var resultDataFactory = new SearchHeroResultFactory( + entityStore, + starshipMapper, + humanMapper, + droidMapper); + + var serializerResolver = new SerializerResolver(new ISerializer[] { new StringSerializer() }); + + return new SearchHeroBuilder(entityStore, idSerializer, resultDataFactory, serializerResolver); + } + + private static Response CreateResponse(string json) + => new(JsonDocument.Parse(json), null); +} diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Combined.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Combined.snap index 6baeceff14d..c17e724c70d 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Combined.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Combined.snap @@ -1168,10 +1168,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1184,7 +1185,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1245,10 +1246,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1261,7 +1263,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1322,10 +1324,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1338,7 +1341,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_DifferentTransportMethods.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_DifferentTransportMethods.snap index de079a5e8db..3536b416d54 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_DifferentTransportMethods.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_DifferentTransportMethods.snap @@ -1168,10 +1168,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1184,7 +1185,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1245,10 +1246,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1261,7 +1263,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1322,10 +1324,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1338,7 +1341,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_InMemory.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_InMemory.snap index a9ddef7a02f..f56d8226b1b 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_InMemory.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_InMemory.snap @@ -1168,10 +1168,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1184,7 +1185,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1245,10 +1246,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1261,7 +1263,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1322,10 +1324,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1338,7 +1341,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_MultiProfile.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_MultiProfile.snap index 3cc1ef6a957..703bf7437d5 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_MultiProfile.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_MultiProfile.snap @@ -1176,10 +1176,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1192,7 +1193,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1253,10 +1254,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1269,7 +1271,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1330,10 +1332,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1346,7 +1349,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Mutation.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Mutation.snap index 325cb15fa9b..362c23a161b 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Mutation.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Mutation.snap @@ -467,10 +467,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -483,7 +484,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Query.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Query.snap index 9369837b4f9..bfdf93ec766 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Query.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Query.snap @@ -467,10 +467,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -483,7 +484,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Subscription.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Subscription.snap index 21bf4add349..c2edad6086c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Subscription.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Subscription.snap @@ -430,10 +430,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -446,7 +447,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes.snap index 9819ac52eeb..568f311a35e 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes.snap @@ -742,10 +742,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("SearchableStore", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("SearchableStore", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.SearchableStoreEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")), Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")))); @@ -815,7 +816,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BookData(typename, isbn: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isbn")), title: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title"))); } - throw new global::System.NotSupportedException(); + return null; } private global::Foo.Bar.State.ISearchResultData? Deserialize_ISearchResultData(global::System.Text.Json.JsonElement? obj) @@ -841,7 +842,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BookData(typename, title: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")), isbn: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isbn"))); } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes_With_Records.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes_With_Records.snap index c3ab353d047..6e7f6f34626 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes_With_Records.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes_With_Records.snap @@ -742,10 +742,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("SearchableStore", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("SearchableStore", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.SearchableStoreEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")), Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")))); @@ -815,7 +816,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BookData(typename, isbn: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isbn")), title: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title"))); } - throw new global::System.NotSupportedException(); + return null; } private global::Foo.Bar.State.ISearchResultData? Deserialize_ISearchResultData(global::System.Text.Json.JsonElement? obj) @@ -841,7 +842,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BookData(typename, title: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")), isbn: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isbn"))); } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_InterfaceDataTypes.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_InterfaceDataTypes.snap index 6190acb7ea5..303afe5d20e 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_InterfaceDataTypes.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_InterfaceDataTypes.snap @@ -603,7 +603,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.MagazineData(typename, isbn: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isbn")), coverImageUrl: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "coverImageUrl"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_InterfaceDataTypes_With_Records.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_InterfaceDataTypes_With_Records.snap index 645f2fce317..eee076fd1fb 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_InterfaceDataTypes_With_Records.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_InterfaceDataTypes_With_Records.snap @@ -603,7 +603,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.MagazineData(typename, isbn: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isbn")), coverImageUrl: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "coverImageUrl"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_UnionDataTypes.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_UnionDataTypes.snap index 5bd3e0246b3..14c455a7910 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_UnionDataTypes.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_UnionDataTypes.snap @@ -546,7 +546,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BookData(typename, title: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_UnionDataTypes_With_Records.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_UnionDataTypes_With_Records.snap index b34a014e1c0..c9fbf690e15 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_UnionDataTypes_With_Records.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataOnly_UnionDataTypes_With_Records.snap @@ -546,7 +546,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BookData(typename, title: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity.snap index 27988b6ea3b..f00cea684f6 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity.snap @@ -684,7 +684,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonConnectionData(typename, nodes: Update_IGetPeople_People_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetPeople_People_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -720,10 +720,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); @@ -736,7 +737,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity_With_Records.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity_With_Records.snap index f789e89b715..d3d5f60869d 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity_With_Records.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity_With_Records.snap @@ -684,7 +684,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonConnectionData(typename, nodes: Update_IGetPeople_People_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetPeople_People_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -720,10 +720,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); @@ -736,7 +737,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly.snap index 05bead7ebfa..78f1fc46f06 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly.snap @@ -1803,7 +1803,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonConnectionData(typename, nodes: Update_IGetPeople_People_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetPeople_People_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1839,10 +1839,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); @@ -1855,7 +1856,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1891,7 +1892,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.MessageConnectionData(typename, nodes: Update_IGetPeople_People_Nodes_Messages_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetPeople_People_Nodes_Messages_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1927,10 +1928,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Message", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Message", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); @@ -1943,7 +1945,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::StrawberryShake.EntityId Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1958,10 +1960,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Messages)); @@ -2041,10 +2044,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Message", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Message", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); @@ -2072,10 +2076,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Messages)); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly_With_Records.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly_With_Records.snap index 1372c8c91fd..5d30e26a30c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly_With_Records.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly_With_Records.snap @@ -1803,7 +1803,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonConnectionData(typename, nodes: Update_IGetPeople_People_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetPeople_People_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1839,10 +1839,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); @@ -1855,7 +1856,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1891,7 +1892,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.MessageConnectionData(typename, nodes: Update_IGetPeople_People_Nodes_Messages_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetPeople_People_Nodes_Messages_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1927,10 +1928,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Message", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Message", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); @@ -1943,7 +1945,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::StrawberryShake.EntityId Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1958,10 +1960,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Messages)); @@ -2041,10 +2044,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Message", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Message", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); @@ -2072,10 +2076,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Messages)); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap index 1dd8dd4b862..d0ffa104ad5 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap @@ -483,10 +483,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); @@ -499,7 +500,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_DateTimeOffset_Entity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_DateTimeOffset_Entity.snap index e6ba0f9acea..c44e7bf8e2a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_DateTimeOffset_Entity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_DateTimeOffset_Entity.snap @@ -482,10 +482,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); @@ -498,7 +499,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.DateTimeOffset Deserialize_NonNullableDateTimeOffset(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_IdEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_IdEntity.snap index 465dc69f74e..0dd140443c5 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_IdEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_IdEntity.snap @@ -480,10 +480,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); @@ -496,7 +497,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_NoEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_NoEntity.snap index f451b748b30..8ba1ac4450f 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_NoEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_NoEntity.snap @@ -464,7 +464,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), email: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_UUID_Entity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_UUID_Entity.snap index 7832a5f1f7b..bdf3909e717 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_UUID_Entity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_UUID_Entity.snap @@ -482,10 +482,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); @@ -498,7 +499,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Guid Deserialize_NonNullableGuid(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceField.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceField.snap index 6738a6af715..a2ae4be5055 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceField.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceField.snap @@ -879,7 +879,7 @@ namespace Foo.Bar.State return new global::StrawberryShake.EntityIdOrData(new global::Foo.Bar.State.Quox2Data(typename, foo: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), bar: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "bar")))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceList.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceList.snap index 95b898a8414..009c94d641a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceList.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceList.snap @@ -922,7 +922,7 @@ namespace Foo.Bar.State return new global::StrawberryShake.EntityIdOrData(new global::Foo.Bar.State.Quox2Data(typename, foo: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), bar: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "bar")))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) 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 index 72ca087590e..0bd8f6d5c7a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap @@ -880,7 +880,7 @@ namespace Foo.Bar.State return new global::StrawberryShake.EntityIdOrData(new global::Foo.Bar.State.Quox2Data(typename, foo: Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Int32 Deserialize_NonNullableInt32(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionField.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionField.snap index d74a7f4f0d9..f4e760066b1 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionField.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionField.snap @@ -843,7 +843,7 @@ namespace Foo.Bar.State return new global::StrawberryShake.EntityIdOrData(new global::Foo.Bar.State.Quox2Data(typename, foo: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionList.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionList.snap index 536cc8bcbb8..bbeefbd323e 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionList.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionList.snap @@ -886,7 +886,7 @@ namespace Foo.Bar.State return new global::StrawberryShake.EntityIdOrData(new global::Foo.Bar.State.Quox2Data(typename, foo: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionListInEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionListInEntity.snap index 0ccd16f9067..26f1d3bc8a5 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionListInEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionListInEntity.snap @@ -859,10 +859,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Test", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Test", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.TestEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.TestEntity(Deserialize_IBarDataArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo"), entityIds))); @@ -875,7 +876,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Deserialize_IBarDataArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -958,7 +959,7 @@ namespace Foo.Bar.State return new global::StrawberryShake.EntityIdOrData(new global::Foo.Bar.State.Quox2Data(typename, foo: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_ChatClient_InvalidNullCheck.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_ChatClient_InvalidNullCheck.snap index 4c661812b71..e0c796ebd8c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_ChatClient_InvalidNullCheck.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_ChatClient_InvalidNullCheck.snap @@ -748,10 +748,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_IGetPeople_Me_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), entity.Name, entity.Email, entity.IsOnline)); @@ -785,7 +786,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonConnectionData(typename, nodes: Update_IGetPeople_Me_Friends_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetPeople_Me_Friends_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -821,10 +822,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(entity.Friends, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); @@ -837,7 +839,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap index 7a7f81f32aa..395660d29e7 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap @@ -635,10 +635,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); @@ -651,8 +652,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); @@ -665,7 +668,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.Input_Type_Fields_Are_Inspected_For_LeafTypes.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.Input_Type_Fields_Are_Inspected_For_LeafTypes.snap index 9fb2a4f0291..4c047084a6a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.Input_Type_Fields_Are_Inspected_For_LeafTypes.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.Input_Type_Fields_Are_Inspected_For_LeafTypes.snap @@ -767,10 +767,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")))); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.KeywordCollisions.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.KeywordCollisions.snap index e66e9273f84..b33833c3364 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.KeywordCollisions.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.KeywordCollisions.snap @@ -756,7 +756,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.readonlyData(typename, @abstract: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "abstract"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) @@ -786,10 +786,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("readonlyEntity", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("readonlyEntity", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.readonlyEntityEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.readonlyEntityEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "abstract")))); @@ -802,7 +803,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Default_Names.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Default_Names.snap index 2e03846f9a1..80670ddc90a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Default_Names.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Default_Names.snap @@ -577,7 +577,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.HumanData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), appearsIn: Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap index e66d64c3b74..e3919350825 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap @@ -940,7 +940,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.HumanData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), homePlanet: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")), friends: Deserialize_IGetHero_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -991,7 +991,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.FriendsConnectionData(typename, nodes: Deserialize_ICharacterDataArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Deserialize_ICharacterDataArray(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Leaf_Argument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Leaf_Argument.snap index 2b0a35e4af7..fe5764cd143 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Leaf_Argument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Leaf_Argument.snap @@ -594,7 +594,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.HumanData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), appearsIn: Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap index 2c71324dc6a..211e385f78b 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap @@ -635,7 +635,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.DroidData(typename); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.StarWarsUnionList.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.StarWarsUnionList.snap index 8222c82386a..97f2a98bab7 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.StarWarsUnionList.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.StarWarsUnionList.snap @@ -641,7 +641,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.DroidData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap index 391a47f4b27..ce5d9bd85b0 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap @@ -4355,7 +4355,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonConnectionData(typename, nodes: Update_IGetPeople_People_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetPeople_People_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -4391,10 +4391,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "imageUri")), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastSeen")), entity.Messages)); @@ -4407,7 +4408,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -4521,10 +4522,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(entity.Name, entity.Email, entity.IsOnline, entity.ImageUri, entity.LastSeen, Deserialize_IGetMessages_PersonByEmail_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); @@ -4558,7 +4560,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.MessageConnectionData(typename, nodes: Update_IGetMessages_PersonByEmail_Messages_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetMessages_PersonByEmail_Messages_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -4594,10 +4596,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Message", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Message", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); @@ -4610,7 +4613,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -4655,10 +4658,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); @@ -4701,10 +4705,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); @@ -4807,10 +4812,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Message", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Message", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); @@ -4868,10 +4874,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); @@ -4914,10 +4921,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); @@ -5020,10 +5028,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Message", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Message", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); @@ -5081,10 +5090,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); @@ -5127,10 +5137,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); @@ -5212,10 +5223,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Message", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Message", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); @@ -5273,10 +5285,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); @@ -5319,10 +5332,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/PersistedOperationGeneratorTests.Simple_Custom_Scalar.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/PersistedOperationGeneratorTests.Simple_Custom_Scalar.snap index eeb89dabe45..333a47b19a6 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/PersistedOperationGeneratorTests.Simple_Custom_Scalar.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/PersistedOperationGeneratorTests.Simple_Custom_Scalar.snap @@ -466,7 +466,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), email: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Nested_Entity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Nested_Entity.snap index 09b0690f390..9dfc16f4a30 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Nested_Entity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Nested_Entity.snap @@ -892,10 +892,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("VehicleMake", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("VehicleMake", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.VehicleMakeEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.VehicleMakeEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "make")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "makeCode")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")))); @@ -908,7 +909,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Guid Deserialize_NonNullableGuid(global::System.Text.Json.JsonElement? obj) @@ -953,10 +954,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("VehicleModel", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("VehicleModel", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.VehicleModelEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.VehicleModelEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "model")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelCode")), Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "vehicleMakeId")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelType")))); @@ -969,7 +971,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Operation_With_Comments.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Operation_With_Comments.snap index d11a66df06c..dec68563d40 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Operation_With_Comments.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Operation_With_Comments.snap @@ -960,7 +960,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BazData(typename, str: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "str")), strNonNullable: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "strNonNullable")), nested: Deserialize_IGetFoo_Foo_Nested(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nested")), nestedList: Deserialize_NonNullableIGetFoo_Foo_NestedListNonNullableArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nestedList")), nestedMatrix: Deserialize_IGetFoo_Foo_NestedMatrixArrayArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nestedMatrix"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) @@ -1011,7 +1011,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BazData(typename, str: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "str"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList Deserialize_NonNullableIGetFoo_Foo_NestedListNonNullableArray(global::System.Text.Json.JsonElement? obj) @@ -1116,7 +1116,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BazData(typename, str: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "str"))); } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Operation_With_Complex_Types.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Operation_With_Complex_Types.snap index 58240de519c..31b6bdf05ac 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Operation_With_Complex_Types.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Operation_With_Complex_Types.snap @@ -876,7 +876,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BazData(typename, str: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "str")), strNonNullable: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "strNonNullable")), nested: Deserialize_IGetFoo_Foo_Nested(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nested")), nestedList: Deserialize_NonNullableIGetFoo_Foo_NestedListNonNullableArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nestedList")), nestedMatrix: Deserialize_IGetFoo_Foo_NestedMatrixArrayArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nestedMatrix"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) @@ -927,7 +927,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BazData(typename, str: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "str"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList Deserialize_NonNullableIGetFoo_Foo_NestedListNonNullableArray(global::System.Text.Json.JsonElement? obj) @@ -1032,7 +1032,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.BazData(typename, str: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "str"))); } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Any_Scalar.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Any_Scalar.snap index 210747ad01a..ccc2c7b398a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Any_Scalar.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Any_Scalar.snap @@ -466,7 +466,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), data: Deserialize_Object(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "data"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Any_Type.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Any_Type.snap index 831e19f2208..0e8832de87c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Any_Type.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Any_Type.snap @@ -466,7 +466,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), email: Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_UUID_And_DateTime.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_UUID_And_DateTime.snap index 874e28f71dd..c03b2e9ee9a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_UUID_And_DateTime.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_UUID_And_DateTime.snap @@ -793,10 +793,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Expense", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Expense", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.ExpenseEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.ExpenseEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableDecimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "amount")), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "date")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "description")), Deserialize_NonNullableExpenseCategory(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")), Deserialize_NonNullablePaymentMethod(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "paymentMethod")), Deserialize_IAllExpenses_Expense_TagsArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "tags")))); @@ -809,7 +810,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Guid Deserialize_NonNullableGuid(global::System.Text.Json.JsonElement? obj) @@ -941,7 +942,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.TagData(typename, name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))); } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_RuntimeType.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_RuntimeType.snap index 8019f77fe98..4ed3b529911 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_RuntimeType.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_RuntimeType.snap @@ -466,7 +466,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), email: Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_RuntimeType_ValueType_AsInput.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_RuntimeType_ValueType_AsInput.snap index 3ce271ad7c8..e63e48d6198 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_RuntimeType_ValueType_AsInput.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_RuntimeType_ValueType_AsInput.snap @@ -463,7 +463,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, setEmail: Deserialize_NonNullableIndex(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "setEmail"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Index Deserialize_NonNullableIndex(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_SerializationType.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_SerializationType.snap index c6449bc230a..d6370ba5dd4 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_SerializationType.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_SerializationType.snap @@ -466,7 +466,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), email: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_SerializationType_And_RuntimeType.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_SerializationType_And_RuntimeType.snap index 498f34aaa00..9375cc7776e 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_SerializationType_And_RuntimeType.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_SerializationType_And_RuntimeType.snap @@ -466,7 +466,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), email: Deserialize_Int64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_Unknown_RuntimeType.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_Unknown_RuntimeType.snap index ff3f4c309fb..27514fd0783 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_Unknown_RuntimeType.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Custom_Scalar_With_Unknown_RuntimeType.snap @@ -466,7 +466,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), email: Deserialize_Custom(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Duration_Not_Detected.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Duration_Not_Detected.snap index 6592ecdd316..9d36e1b6225 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Duration_Not_Detected.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Duration_Not_Detected.snap @@ -610,7 +610,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.SessionConnectionData(typename, nodes: Update_IGetSessions_Sessions_NodesEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetSessions_Sessions_NodesEntityNonNullableArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -646,10 +646,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Session", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Session", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.SessionEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.SessionEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")))); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Only_Custom_Scalars.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Only_Custom_Scalars.snap index 65b72c23d7b..b4bb7775635 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Only_Custom_Scalars.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Only_Custom_Scalars.snap @@ -457,7 +457,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, email: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Simple_Custom_Scalar.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Simple_Custom_Scalar.snap index 83404d3b1dd..2a85cbdb7aa 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Simple_Custom_Scalar.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Simple_Custom_Scalar.snap @@ -466,7 +466,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, name: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), email: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.TimeSpan_Type.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.TimeSpan_Type.snap index dc47a609dd2..9e91456bbdb 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.TimeSpan_Type.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.TimeSpan_Type.snap @@ -457,7 +457,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, timeSpan: Deserialize_TimeSpan(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "timeSpan"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.TimeSpan? Deserialize_TimeSpan(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Uri_Type.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Uri_Type.snap index 6d130483c94..150dfca29cb 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Uri_Type.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Uri_Type.snap @@ -470,7 +470,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, uri: Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "uri")), uRI: Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "URI"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Uri? Deserialize_Uri(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Uuid_Type.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Uuid_Type.snap index 672f0ad5175..9839d7516bd 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Uuid_Type.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Uuid_Type.snap @@ -470,7 +470,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonData(typename, uuid: Deserialize_Guid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "Uuid")), uUID: Deserialize_Guid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "UUID"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Guid? Deserialize_Guid(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatById.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatById.snap index a24b08f5810..96a7aa86b6f 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatById.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatById.snap @@ -781,7 +781,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.FeatCollectionSegmentData(typename, items: Update_IGetFeatById_Feats_ItemsEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "items"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetFeatById_Feats_ItemsEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -817,10 +817,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Feat", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Feat", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds))); @@ -833,7 +834,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Guid Deserialize_NonNullableGuid(global::System.Text.Json.JsonElement? obj) @@ -914,10 +915,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("FeatDetailsBlock", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("FeatDetailsBlock", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatDetailsBlockEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatsPage.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatsPage.snap index a3592ebaf41..a88e2bbb7f5 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatsPage.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatsPage.snap @@ -781,7 +781,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.FeatCollectionSegmentData(typename, items: Update_IGetFeatsPage_Feats_ItemsEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "items"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetFeatsPage_Feats_ItemsEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -817,10 +817,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Feat", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Feat", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")), Update_NonNullableIGetFeatsPage_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds))); @@ -833,7 +834,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -893,10 +894,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("ActionType", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("ActionType", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.ActionTypeEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap index c84dbdf79ca..5443e0d1ef1 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap @@ -1260,7 +1260,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.PersonCollectionSegmentData(typename, totalCount: Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "totalCount")), pageInfo: Deserialize_NonNullableIPeopleSearch_People_PageInfo(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "pageInfo")), items: Update_IPeopleSearch_People_ItemsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "items"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Int32 Deserialize_NonNullableInt32(global::System.Text.Json.JsonElement? obj) @@ -1347,10 +1347,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isActive")), Update_IPeopleSearch_People_Items_DepartmentEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "department"), entityIds), Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "image")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")), Update_IPeopleSearch_People_Items_ManagerEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "manager"), entityIds))); @@ -1423,10 +1424,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Department", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Department", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DepartmentEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DepartmentEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -1439,7 +1441,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Uri? Deserialize_Uri(global::System.Text.Json.JsonElement? obj) @@ -1469,10 +1471,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Person", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")), entity.IsActive, entity.Department, entity.Image, entity.Title, entity.Manager)); @@ -1485,7 +1488,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap index 5cf38da3c89..557e2a3da0e 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap @@ -669,7 +669,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.NewsItemCollectionSegmentData(typename, items: Update_ISearchNewsItems_NewsItems_ItemsEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "items"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_ISearchNewsItems_NewsItems_ItemsEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -705,10 +705,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("NewsItem", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("NewsItem", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.NewsItemEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.NewsItemEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "summary")))); @@ -721,7 +722,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_UpdateMembers_Mutation.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_UpdateMembers_Mutation.snap index ce7f38d3371..f3e57ac3f8a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_UpdateMembers_Mutation.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_UpdateMembers_Mutation.snap @@ -986,7 +986,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.MutationResultData(typename, correlationId: Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "correlationId"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Guid Deserialize_NonNullableGuid(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap index 2daded24966..dd3bdc904f9 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap @@ -3755,7 +3755,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.Bwr_TimeSeriesConnectionData(typename, nodes: Update_IGetBwr_TimeSeries_Bwr_TimeSeries_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetBwr_TimeSeries_Bwr_TimeSeries_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -3791,10 +3791,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("bwr_TimeSeries", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("bwr_TimeSeries", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.bwr_TimeSeriesEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.bwr_TimeSeriesEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "inventoryId")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "area")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "source")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "type")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "specification")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "commodity")), Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_Resolution(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "resolution")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "unit")), Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ValidationCriteriaEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "validationCriteria"), entityIds), Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ImportSpecificationEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "importSpecification"), entityIds), Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes__dataPointsNonNullableArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_dataPoints")))); @@ -3807,7 +3808,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String? Deserialize_String(global::System.Text.Json.JsonElement? obj) @@ -3843,7 +3844,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.ResolutionData(typename, timeUnit: Deserialize_NonNullableTimeUnit(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "timeUnit")), factor: Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "factor"))); } - throw new global::System.NotSupportedException(); + return null; } private global::Foo.Bar.TimeUnit Deserialize_NonNullableTimeUnit(global::System.Text.Json.JsonElement? obj) @@ -3888,10 +3889,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("bwr_ValidationCriteria", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("bwr_ValidationCriteria", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.bwr_ValidationCriteriaEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ValidationCriteriaEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_inventoryItemId")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "completeness")), Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lowerBound")), Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "upperBound")))); @@ -3904,7 +3906,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Decimal? Deserialize_Decimal(global::System.Text.Json.JsonElement? obj) @@ -3934,10 +3936,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("bwr_ImportSpecification", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("bwr_ImportSpecification", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.bwr_ImportSpecificationEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ImportSpecificationEntity(Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "fromPeriod")), Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "toPeriod")))); @@ -3950,7 +3953,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Int32? Deserialize_Int32(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.HasuraMutation.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.HasuraMutation.snap index c2015e1580b..af3be478852 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.HasuraMutation.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.HasuraMutation.snap @@ -4040,7 +4040,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.people_mutation_responseData(typename, affected_Rows: Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "affected_rows"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Int32 Deserialize_NonNullableInt32(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.IntrospectionQuery.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.IntrospectionQuery.snap index 0b1708a7c4a..9e42bef2e6a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.IntrospectionQuery.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.IntrospectionQuery.snap @@ -3755,7 +3755,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.__TypeData(typename, name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))); } - throw new global::System.NotSupportedException(); + return null; } private global::Foo.Bar.State.__TypeData? Deserialize_IIntrospectionQuery___schema_SubscriptionType(global::System.Text.Json.JsonElement? obj) @@ -3776,7 +3776,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.__TypeData(typename, name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList Deserialize_NonNullableIIntrospectionQuery___schema_TypesNonNullableArray(global::System.Text.Json.JsonElement? obj) @@ -3974,7 +3974,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.__TypeData(typename, kind: Deserialize_NonNullable__TypeKind(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "kind")), name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), ofType: Deserialize_IIntrospectionQuery___schema_Types_Interfaces_OfType_OfType(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "ofType"))); } - throw new global::System.NotSupportedException(); + return null; } private global::Foo.Bar.State.__TypeData? Deserialize_IIntrospectionQuery___schema_Types_Interfaces_OfType_OfType(global::System.Text.Json.JsonElement? obj) @@ -3995,7 +3995,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.__TypeData(typename, kind: Deserialize_NonNullable__TypeKind(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "kind")), name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), ofType: Deserialize_IIntrospectionQuery___schema_Types_Interfaces_OfType_OfType_OfType(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "ofType"))); } - throw new global::System.NotSupportedException(); + return null; } private global::Foo.Bar.State.__TypeData? Deserialize_IIntrospectionQuery___schema_Types_Interfaces_OfType_OfType_OfType(global::System.Text.Json.JsonElement? obj) @@ -4016,7 +4016,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.__TypeData(typename, kind: Deserialize_NonNullable__TypeKind(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "kind")), name: Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))); } - throw new global::System.NotSupportedException(); + return null; } private global::Foo.Bar.State.__TypeData Deserialize_NonNullableIIntrospectionQuery___schema_Types_Fields_Type(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap index 2dfd99b1402..319184f70ca 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap @@ -521,10 +521,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("people", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("people", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.peopleEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.peopleEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")))); @@ -537,7 +538,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NodeTypenameCollision.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NodeTypenameCollision.snap index 25ce713173d..95de5c80fb8 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NodeTypenameCollision.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NodeTypenameCollision.snap @@ -494,10 +494,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Workspace", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Workspace", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.WorkspaceEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.WorkspaceEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); @@ -510,7 +511,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap index 2e2185b1518..11936d7ec00 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap @@ -3253,7 +3253,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.FeatCollectionSegmentData(typename, totalCount: Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "totalCount")), items: Update_IGetFeatsPage_Feats_ItemsEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "items"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Int32 Deserialize_NonNullableInt32(global::System.Text.Json.JsonElement? obj) @@ -3304,10 +3304,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Feat", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Feat", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")), Update_NonNullableIGetFeatsPage_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds), entity.Special, entity.Trigger, entity.ActionType)); @@ -3320,7 +3321,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Guid Deserialize_NonNullableGuid(global::System.Text.Json.JsonElement? obj) @@ -3401,10 +3402,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("FeatDetailsBlock", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("FeatDetailsBlock", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatDetailsBlockEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); @@ -3473,7 +3475,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.FeatCollectionSegmentData(typename, items: Update_IGetFeatById_Feats_ItemsEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "items"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetFeatById_Feats_ItemsEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -3509,10 +3511,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Feat", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Feat", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), entity.CanBeLearnedMoreThanOnce, Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "special")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "trigger")), Update_NonNullableIGetFeatById_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds))); @@ -3525,7 +3528,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.Guid Deserialize_NonNullableGuid(global::System.Text.Json.JsonElement? obj) @@ -3621,10 +3624,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("FeatDetailsBlock", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("FeatDetailsBlock", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatDetailsBlockEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); @@ -3652,10 +3656,11 @@ namespace Foo.Bar.State throw new global::System.ArgumentNullException(); } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("ActionType", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("ActionType", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.ActionTypeEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Generate_Client_With_Internal_Access_Modifier.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Generate_Client_With_Internal_Access_Modifier.snap index 2302f16f059..473e97fea60 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Generate_Client_With_Internal_Access_Modifier.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Generate_Client_With_Internal_Access_Modifier.snap @@ -635,10 +635,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); @@ -651,8 +652,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); @@ -665,7 +668,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap index 7a7f81f32aa..395660d29e7 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap @@ -635,10 +635,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); @@ -651,8 +652,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); @@ -665,7 +668,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap index 4c93ea9c8df..1e1f020ce4f 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap @@ -960,10 +960,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "primaryFunction")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -976,8 +977,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); @@ -990,7 +993,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) @@ -1041,7 +1044,7 @@ namespace Foo.Bar.State return new global::Foo.Bar.State.FriendsConnectionData(typename, nodes: Update_IGetHero_Hero_Friends_NodesEntityArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nodes"), entityIds)); } - throw new global::System.NotSupportedException(); + return null; } private global::System.Collections.Generic.IReadOnlyList? Update_IGetHero_Hero_Friends_NodesEntityArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) @@ -1077,10 +1080,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.PrimaryFunction, entity.Friends)); @@ -1093,8 +1097,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.HomePlanet, entity.Friends)); @@ -1107,7 +1113,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap index c374c18da15..e0596b2571c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap @@ -652,10 +652,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); @@ -668,8 +669,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); @@ -682,7 +685,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap index 3a369fc11d1..b6214cb3fd4 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap @@ -711,10 +711,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Starship", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Starship", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.StarshipEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); @@ -727,8 +728,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); @@ -741,8 +744,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); @@ -755,7 +760,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsUnionList.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsUnionList.snap index 76c41dc3cef..e59d5402994 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsUnionList.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsUnionList.snap @@ -708,10 +708,11 @@ namespace Foo.Bar.State return null; } - global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); - entityIds.Add(entityId); - if (entityId.Name.Equals("Starship", global::System.StringComparison.Ordinal)) + var typename = obj.Value.GetProperty("__typename").GetString(); + if (typename?.Equals("Starship", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.StarshipEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity()); @@ -724,8 +725,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Human", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Human", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -738,8 +741,10 @@ namespace Foo.Bar.State return entityId; } - if (entityId.Name.Equals("Droid", global::System.StringComparison.Ordinal)) + if (typename?.Equals("Droid", global::System.StringComparison.Ordinal) ?? false) { + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); @@ -752,7 +757,7 @@ namespace Foo.Bar.State return entityId; } - throw new global::System.NotSupportedException(); + return null; } private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj)