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.24k stars 744 forks source link

Unknown interface types in result list throws exception #6415

Open A360JMaxxgamer opened 1 year ago

A360JMaxxgamer commented 1 year ago

Is there an existing issue for this?

Product

Strawberry Shake

Describe the bug

Use case: Let's say I have some kind of following schema.

type Query { 
  getItems: [Item]
}

type A {}

type B {}

type C {}

union Item = A | B | C

C was later reduced to my schema and my blazor app with my strawberry shake client was not yet updated. The client still operates on the schema.

type Query { 
  getItems: [Item]
}

type A {}

type B {}

union Item = A | B

Error:

After my gateway or service is updated with type C my client in the app is broken. It fails on deserializing the received data. Even though it only has fragments for the known types A and B.

Expectation: The app ignores the unknown type and operates normally.

In my scenario various services broke even though they don't care about the new types.

Steps to reproduce

  1. Create strawberry shake client which queries for a list of a union type
  2. Return a json with an item which is not part of the union type of the generated client schema
  3. The client cannot deserialize the items

Relevant log output

No response

Additional Context?

My main issue is, that I cannot dynamically enhance my platform without updating my strawberry shake clients if each fails of unknown types.

Version

13.3.0

A360JMaxxgamer commented 1 year ago

I would suggest instead of throwing a NotSupport exception, the deserialization returns null and only items which are not null are added to the list. If the solution is fine for you guys, I can fix it and submit a pr in the next days.