1

I have a pretty simple setyp where I'm putting graphql over an entityframework datacontext (sql server).

I'm trying to get filtering to work. I've tried adding .UseFiltering() to a field descriptor like so...

descriptor.Field(t => t.AccountName).Type<NonNullType<StringType>>().UseFiltering();

But it causes this error on startup...

HotChocolate.SchemaException: 'Unable to infer or resolve a schema type from the type reference Input: System.Char.'

I assume I'm doing something wrong somewhere...

1 Answer 1

3

"UseFiltering" is supposed to be used to filter data which represents a collection of items in some way (IQueryable, IEnumerable, etc). For instance, if you have users collection and each user has AccountName property you could filter that collection by AccountName:

[ExtendObjectType(Name = "Query")]
public class UserQuery
{
    [UseFiltering]
    public async Task<IEnumerable<User>> GetUsers([Service]usersRepo)
    {
       IQueryable<User> users = usersRepo.GetUsersQueryable();
    }
}

In that example the HotChocolate implementation of filtering will generate a number of filters by user fields which you can use in the following way:

users(where: {AND: [{accountName_starts_with: "Tech"}, {accountName_not_ends_with: "Test"}]})

According to your example: the system thinks that AccountName is a collection, so tries to build filtering across the chars the AccountName consists of.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.