ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.2k stars 742 forks source link

Strawberry Shake: Runtime ArgumentNullException caused by possible code generation bug when mapping response into "Data" object #5349

Open HonzaBejvl opened 2 years ago

HonzaBejvl commented 2 years ago

Is there an existing issue for this?

Describe the bug

I'm in the situation where shake is not able parse the response and throws.

Steps to reproduce

I have created a repro repo where you can find my query that causes the problem.

I have a Listing. Listing is implemented by ListingSimple and Projekt. ListingSimple is implemented by Offer and Auction. Project has a field listings that is selection wrapper around [ListingSimple!]!.

I also have a querylisting(..): [Listing]! where I would like to query all project listings. But it seems that Shake threats all Listings the same - I mean that if I query for non nullable field in "child project listings" it also nullchecks for that field in the "parent project listing" even though I did not query for that particular field (it is not present in the response) so an ArgumentNullException is thrown.

Relevant log output

System.ArgumentNullException: Value cannot be null.
   at Logic.Graphql.Generated.State.GetProjectDetailItemsResultFactory.MapNonNullableIGetProjectDetailItems_Listing_Listings_SatisfiesFilter_Items(IListingData data, IEntityStoreSnapshot snapshot) in /Users/janbejvl/Development/Infinityloop/nemovizor-client/NemovizorBridgeShake/Generated/BridgeClient.StrawberryShake.cs:line 126814
   at Logic.Graphql.Generated.State.GetProjectDetailItemsResultFactory.MapNonNullableIGetProjectDetailItems_Listing_Listings_SatisfiesFilter_ItemsNonNullableArray(IReadOnlyList`1 list, IEntityStoreSnapshot snapshot) in /Users/janbejvl/Development/Infinityloop/nemovizor-client/NemovizorBridgeShake/Generated/BridgeClient.StrawberryShake.cs:line 126787
   at Logic.Graphql.Generated.State.GetProjectDetailItemsResultFactory.MapNonNullableIGetProjectDetailItems_Listing_Listings_SatisfiesFilter(ListingSelectionData data, IEntityStoreSnapshot snapshot) in /Users/janbejvl/Development/Infinityloop/nemovizor-client/NemovizorBridgeShake/Generated/BridgeClient.StrawberryShake.cs:line 126767
   at Logic.Graphql.Generated.State.GetProjectDetailItemsResultFactory.MapNonNullableIGetProjectDetailItems_Listing_Listings(ProjectListingsData data, IEntityStoreSnapshot snapshot) in /Users/janbejvl/Development/Infinityloop/nemovizor-client/NemovizorBridgeShake/Generated/BridgeClient.StrawberryShake.cs:line 126752
   at Logic.Graphql.Generated.State.GetProjectDetailItemsResultFactory.MapNonNullableIGetProjectDetailItems_Listing(IListingData data, IEntityStoreSnapshot snapshot) in /Users/janbejvl/Development/Infinityloop/nemovizor-client/NemovizorBridgeShake/Generated/BridgeClient.StrawberryShake.cs:line 126737
   at Logic.Graphql.Generated.State.GetProjectDetailItemsResultFactory.Create(IOperationResultDataInfo dataInfo, IEntityStoreSnapshot snapshot) in /Users/janbejvl/Development/Infinityloop/nemovizor-client/NemovizorBridgeShake/Generated/BridgeClient.StrawberryShake.cs:line 126718
   at Logic.Graphql.Generated.State.GetProjectDetailItemsBuilder.BuildData(JsonElement obj) in /Users/janbejvl/Development/Infinityloop/nemovizor-client/NemovizorBridgeShake/Generated/BridgeClient.StrawberryShake.cs:line 144275
   at Logic.Graphql.Generated.State.GetProjectDetailItemsBuilder.Build(Response`1 response) in /Users/janbejvl/Development/Infinityloop/nemovizor-client/NemovizorBridgeShake/Generated/BridgeClient.StrawberryShake.cs:line 144237

Additional Context?

image

Note: I'm 100% sure that there is no null value in non-nullable field.

Product

Strawberry Shake

Version

12.12.1

bromix commented 2 years ago

We've the same problem with thrown exceptions handled with IErrorFilter. We can transform the exception for GraphQL, but the Query has non nullable return defined and strawberry shake will cause the same exception afterwards in our clients.