Ignoring method in my object with HotChocolate GraphQL

Ignoring method in my object with HotChocolate GraphQL


0

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 ?


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *