here I have a mutation, as you can see the parameter name is Product with capital P and the field name is CreateProduct with capital C when I execute this mutation from graphical I have to write the name of the field on camel casing and also the name of the parameter, is there a way to configure graphql-dotnet to respect the names as they are written in the code?
const string STR_Product = "Product";
public Mutations(IProductService ProductService)
{
Name = "Mutation";
Field<ProductType>(
"CreateProduct",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<ProductInputType>> { Name = STR_Product }),
resolve: context =>
{
var ProductInput = context.GetArgument<ProductInput>(STR_Product);
return ProductService.CreateAsync(ProductInput.Code, ProductInput.Name, ProductInput.Description);
//return new ProductInputType();
}
);
}
}
You can pass a
IFieldNameConverterto theExecutionOptions. It defaults to usingCamelCaseFieldNameConverter.Some special considerations are needed for the Introspection types, as those are required to be camel case according to the GraphQL Specification.
GraphQL.NET provides
CamelCaseFieldNameConverter,PascalCaseFieldNameConverter, andDefaultFieldNameConverter. You could also write your own. Source found here.