-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Hi :) Thanks for this awesome library!
We have a small problem.
For fields, we are using the default camel case name format strategy. However, for a couple of fields, we unfortunately need to have a different casing because of backwards compatibility reasons.
I would expect specifying the name with the GraphField attribute to not be changed, and used literally as typed. I understand if you are unwilling to change this behaviour as this would be a breaking change, but is there some other workarounds that I am not aware of that makes it possible to change the name for a single field without a hacky workaround?
[GraphField("FOOBar")] // Will be formatted to `fOOBar` as of now. but I would expect `FOOBar`
public required int FooBar { get; init; }
Currently, I was thinking about doing something like this, but I am not loving this "solution"
using GraphQL.AspNet.Configuration.Formatting;
namespace Foo;
public class CustomGraphNameFormatter(
GraphNameFormatStrategy typeNameStrategy = GraphNameFormatStrategy.ProperCase,
GraphNameFormatStrategy fieldNameStrategy = GraphNameFormatStrategy.CamelCase,
GraphNameFormatStrategy enumValueStrategy = GraphNameFormatStrategy.UpperCase
) : GraphNameFormatter(typeNameStrategy, fieldNameStrategy, enumValueStrategy)
{
private static List<string> ProperCaseFieldNames => ["FooBar"];
public override string FormatFieldName(string name)
{
if (ProperCaseFieldNames.Contains(name))
{
return name;
}
return base.FormatFieldName(name);
}
}
Metadata
Metadata
Assignees
Labels
No labels