Field true not found on type Site

82 views Asked by At

I'm using EntityGraphQL with an ASP.NET Core app that uses Entity Framework Core.

This query works:

{
  sites(filter: "id==1") {
    id
    name
    isActive
  }
}

But this one fails with an error:

Field true not found on type Site

{
  sites(filter: "isActive==true") {
    id
    name
    isActive
  }
}

The documentation says I should be able to do that, why is it not working?

update

This is the Site Model

public class Site 
    {

        [Key]
        public int Id { get; set; }

        [Required]
        [MaxLength(150)]
        public string Name { get; set; }

        public bool IsActive { get; set; } = true;
    ...

I'm using:

  • .NET 6
  • EntityGraphQL.AspNet 5.0.0

I'm decorating the DbSet with [UseFilter]

  [UseFilter]
  public DbSet<Site>? Sites { get; set; }
1

There are 1 answers

1
The One On

If I do this, it works

{
  sites(filter: "isActive==(1==1)") {
    id
    name
    isActive
  }
}

So it must be something with the way the string "isActive==false" is parsed, so I cloned the project and I don't know anything about ANTLR or parsers, but if I delete true and false from this part of EntityQL.g4 then it works

// identity includes keywords too
identity: ID
    | 'true' DELETE THIS
    | 'false' DELETE THIS
    | 'and'
    | 'if'
    | 'then'
    | 'else';

Something else must break of course, but it might give someone a clue

Issue Raised