neo4j-graphql / neo4j-graphql-java

Neo4j Labs Project: Pure JVM translation for GraphQL queries and mutations to Neo4j's Cypher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested filters are not working

magaton opened this issue · comments

Reference:
https://grandstack.io/docs/graphql-filtering/#nested-filter

I am trying to achieve the same:

My schema:

interface Period {
   id: String!
   value: Int!
   name: String!
   type: String!
   startDate: _Neo4jDate!
   endDate: _Neo4jDate!
   in: [Period] @relation(name: "IN_PERIOD", direction: OUT)
   next: [Period] @relation(name: "NEXT", direction: OUT)
}

type Week implements Period {
   id: String!
   value: Int!
   name: String!
   type: String!
   startDate: _Neo4jDate!
   endDate: _Neo4jDate!
   payDate: _Neo4jDate!
   in: [Period] @relation(name: "IN_PERIOD", direction: OUT)
   next: [Period] @relation(name: "NEXT", direction: OUT)
}

The augmented schema looks good:

type Week implements Period {
  id: String!
  value: Int!
  name: String!
  type: String!
  startDate: _Neo4jDate!
  endDate: _Neo4jDate!
  payDate: _Neo4jDate!
  in(
    first: Int
    offset: Int
    orderBy: [_PeriodOrdering!]
    filter: _PeriodFilter
  ): [Period]
  next(
    first: Int
    offset: Int
    orderBy: [_PeriodOrdering!]
    filter: _PeriodFilter
  ): [Period]
}

but this query:

{
   Week(
    filter: {
      in: { value:2020 }
    }
  ) 
  {
    id
    value
    startDate {  
      formatted
    }  
    endDate {
      formatted  
    }  
    payDate {
      formatted 
    }
  }
}

results with an error:

{
  "errors": [
    {
      "message": "Exception while fetching data (/Week) : null",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "Week"
      ]
    }
  ]
}

In the logs I can see:

DEBUG org.neo4j.graphql.RelationOperator - in on type Week was used for filtering, consider using in_every instead

but it throws the same error if I replace in with in_every

Nested filters used to work fine in older versions (older than 1.3), however is not working anymore. Any views on having this fixed soon ?

@ameyec / @magaton can you take a look at the PR #230 to see if it works for you