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.26k stars 745 forks source link

Issue on client query code generator #5637

Open davidegolzi opened 1 year ago

davidegolzi commented 1 year ago

Is there an existing issue for this?

Describe the bug

under some circustance the code generated by StrawberryShake generate classes that do not compile due to a Compiler Error CS0542 - 'user-defined type' : member names cannot be the same as their enclosing type

this happens when in a query definition is present a type with a property named as "[TypeName]Data"

the code generator Generate a class for each type named "[TypeName]Data" so any property in that type that has that name produce the compiler erroe CS0542

Steps to reproduce

  1. write a simple query selecting a type that has a property named the same as the typeitself + "Data" Example Schema Type:

type Test { TestData: String }

Relevant log output

Compiler Error CS0542 - 'user-defined type' : member names cannot be the same as their enclosing type

Additional Context?

I'm not familiar on what library is doing the code generator, but i found this bugs including in my .net core 7 project the preview package StrawberryShake.Server/13.0.0-preview.91 with his dependency

Product

Strawberry Shake

Version

13.0.0-preview.91

davidegolzi commented 1 year ago

Suggestioni on fix

Add a constrain during properties generation

Use Graphql alias defined in query as property name