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
4.96k stars 722 forks source link

Allow overriding query convention result name per field #7083

Open cmeeren opened 2 weeks ago

cmeeren commented 2 weeks ago

Product

Hot Chocolate

Is your feature request related to a problem?

Currently, HotChocolate names the query convention result types by the field.

I have several fields in different parts of the hierarchy with the same name, and I need to use query conventions for both.

The solution you'd like

The ability to override the query convention result type name per field using an attribute, just like overriding the result type name for mutation conventions or the connection name for pagination.

cmeeren commented 2 weeks ago

To be clear, if I currently have two identically named fields (in different parts of the hierarchy) that both use query conventions, then fetching the schema fails with:

The name SomeFieldNameResult was already registered by another type. (HotChocolate.Types.UnionType)

cmeeren commented 2 weeks ago

Ideally, there'd be a global option to automatically name the field similar to MutationConventionOptions.PayloadTypeNamePattern, which would allow me to set something like "{TypeName}{FieldName}Result". (I would argue that should be the default naming, but as long as I can configure it, I'm happy.)