Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB & Filter on Boolean property: the "_not" filter throws an exception #1033

Closed
gmiserez opened this issue Aug 26, 2019 · 1 comment
Closed
Milestone

Comments

@gmiserez
Copy link
Contributor

gmiserez commented Aug 26, 2019

While using the new HotChocolate PRISMA-inspired Filter package on top of a Mongo database I encountered the following error when using the booleanProperty_not Filter:

({document}{IsCapitalCity} == False) is not supported.

In short, this works:

{
  cities(where: { isCapitalCity: true }){
    name
  }
}

while this does not:

{
  cities(where: { isCapitalCity_not: false }){
    name
  }
}

Note: This works:

{
  cities(where: { isCapitalCity: false }){
    name
  }
}

To Reproduce
Declare the following query type:

    public class QueryType: ObjectType
    {
        protected override void Configure(IObjectTypeDescriptor descriptor)
        {
            descriptor.Name("Query");
            descriptor.Field("cities")
                .Resolver(ctx => ctx.Service<IMongoCollection<City>>().AsQueryable())
                .UseFiltering<CityFilterType>();
        }
    }

And initialize the City collection in the services:

            services.AddSingleton(sp =>
            {
                var client = new MongoClient();
                IMongoDatabase database = client.GetDatabase(
                    "db_" + Guid.NewGuid().ToString("N"));
                IMongoCollection<City> collection
                    = database.GetCollection<City>("col");
                collection.InsertMany(new[]
                {
                    new City(1, "Amsterdam", "nl", true),
                    new City(2, "Berlin", "de", true),
                    new City(3, "Paris", "fr", true),
                    new City(4, "Zürich", "ch", false)
                });
                return collection;
            });

I commited a sample repo here: https://github.com/gmiserez/HotChocolate_BooleanNotFilterAgainstMongo
(needs a local Mongo instance listening to port 27017)

Expected behavior
cities(where: { isCapitalCity_not: false }) should return the same result set than cities(where: { isCapitalCity: true })

Packages:

  • HotChocolate.* 11.0.0-preview.4
  • MongoDB.Driver 2.8.1
@michaelstaib
Copy link
Member

This one is now fixed #1170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants