Husqvik / GraphQlClientGenerator

GraphQL C# client generator
MIT License
213 stars 49 forks source link

Build fails miserably against WPGraphQL Schema #153

Closed richardaubin closed 7 months ago

richardaubin commented 8 months ago

wpgraphql_schema.txt I've attached the restult of the introspection query that you provided in https://github.com/Husqvik/GraphQlClientGenerator/issues/108

image

Husqvik commented 8 months ago

Thanks for reporting. I'll hope to find some time during this week to fix these.

richardaubin commented 8 months ago

No problem. The first group of errors are related to the Enum generation. The enums with errors are of the 0000x0000 type. When the enums are generated, the is removed and produces an invalid enum name starting with integers. The _ should be kept when the name is created.

And not sure how to explain the other ones :)

Husqvik commented 8 months ago

It's at least three issues:

  1. enum names - can be temporarily solved by using EnumValueNaming = EnumValueNamingOption.Original option
  2. interfaces not generated because containing only deprecated fields (which doesn't really mean they are not needed) - can be temporarily solved by using IncludeDeprecatedFields = true
  3. interface inherited from another interface contains a field of the same name but different type - there is no temporary solution for this issue
Husqvik commented 8 months ago

The metadata contains some invalid information. For example GraphQL doesn't support interface inheritance but in your schema there are 57 interfaces defined as inheriting from other interface. This is part of the third issue, the easier.

Another thing is that a type implements multiple interfaces with same member name but different type (interface). Without containing that definition on the object type. I know that GraphQL allows this (by dynamic object building from the interface if not defined). Will have to extend the generator to support that because C# is more strict - the signature of the interface member must be exactly the same, implementing type cannot be used for interface member.

richardaubin commented 8 months ago

Here's the SDL schema if that will help... It's not my own and created by a third party.

wpgraphql.zip

Husqvik commented 8 months ago

Thanks. I think I have enough information to fix the problem.

Husqvik commented 8 months ago

WordpressSchema.zip

This is result after the last update.

It's not perfectly optimal due to overhead of converting the collection types. I was considering to make all interface collection definitions as IEnumerable which is covariant but that also comes with drawbacks of consuming.

Husqvik commented 7 months ago

fixed in https://www.nuget.org/packages/GraphQlClientGenerator/0.9.19