I have a class that I expose with Hotchocolate and GraphQL.
In this class I have some properties and a public method with the following signature :
public Expression<Func<Parcelle, bool>> ToLambdaExpression()
By default, Hot Chocolate picks up the public method and exposes them as fields in the graphql schema. I managed to ignore them with an object type extension like this :
protected override void Configure(IObjectTypeDescriptor<ParcelSelectionCriteriaExpression> descriptor)
{
descriptor.Ignore(t => t.TokenizeExpression());
}
And it worked most of the time for methods returning simple types. But when I try to do that for my ToLambdaExpression
method, I get an error during schema validation.
public class ParcelSelectionCriteriaExtension : ObjectTypeExtension<ParcelSelectionCriteria>
{
protected override void Configure(IObjectTypeDescriptor<ParcelSelectionCriteria> descriptor)
{
descriptor.Ignore(t => t.ToLambdaExpression());
}
}
HotChocolate.SchemaException: For more details look at the `Errors` property.
1. Unable to infer or resolve a schema type from the type reference `Expression (Input)`.
If I comment the ToLambdaExpression
method, everything works. It looks like even if I ignore the field, it tries to resolve its type and since it's an Expression<Func<Parcelle, bool>>
it can't figure out how to type it.
Is there a way to make HotChocolate completely ignore this method without having to create a DTO ?
For me it is more natural (semantically) to use "Type definition" but not type extension here. In that case, the following approach should work:
But, anyway, the approach with the type extension is supposed to work as well. Otherwise, I guess, it is a bug.