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

Cannot filter on computed fields #182

Open
rgruener opened this issue May 22, 2019 · 3 comments
Open

Cannot filter on computed fields #182

rgruener opened this issue May 22, 2019 · 3 comments

Comments

@rgruener
Copy link

Using the movie example I have the following schema:

type Movie  {
  title: String!
  released: Int
  actors: [Person] @relation(name:"ACTED_IN",direction:IN)
  directors: [Person] @cypher(statement:"MATCH (this)<-[:DIRECTED]-(d) RETURN d")
}
type Person {
  name: String!
  born: Int
  movies: [Movie] @relation(name:"ACTED_IN")
  totalMoviesCount: Int @cypher(statement: "WITH {this} AS this MATCH (this)-[:ACTED_IN]->() RETURN count(*) AS totalMoviesCount")
}

When trying to query based on the computed field totalMoviesCount it always returns no data.
Examples:

{
  Person(totalMoviesCount:1) {
    name
    totalMoviesCount
  }
}
{
  Person(filter: {totalMoviesCount:1}) {
    name
    totalMoviesCount
  }
}

both return

{
  "data": {
    "Person": []
  },
  "extensions": {
    "type": "READ_ONLY"
  }
}

However I would expect data to be returned as this is the first 10 items in the db:

{
  "data": {
    "Person": [
      {
        "name": "Letitia Wright",
        "totalMoviesCount": 1
      },
      {
        "name": "Keanu Reeves",
        "totalMoviesCount": 7
      },
      {
        "name": "Carrie-Anne Moss",
        "totalMoviesCount": 3
      },
      {
        "name": "Laurence Fishburne",
        "totalMoviesCount": 3
      },
      {
        "name": "Hugo Weaving",
        "totalMoviesCount": 5
      },
      {
        "name": "Lilly Wachowski",
        "totalMoviesCount": 0
      },
      {
        "name": "Lana Wachowski",
        "totalMoviesCount": 0
      },
      {
        "name": "Joel Silver",
        "totalMoviesCount": 0
      },
      {
        "name": "Emil Eifrem",
        "totalMoviesCount": 1
      },
      {
        "name": "Charlize Theron",
        "totalMoviesCount": 2
      }
    ]
  },
  "extensions": {
    "type": "READ_ONLY"
  }
}

Is this expected?

@willhl
Copy link

willhl commented Aug 19, 2019

Just to add +1 to this issue, I also cannot get any @cypher directives to be filterable. I'm assuming this is a limitation of @cypher at the moment? because @relation does work fine with filtering.

@jexp
Copy link
Contributor

jexp commented Aug 22, 2019

Yes because the filter would have to be integrated into your cypher query to be efficient.
So we'd have to have a substitution means in the cypher query that would be substituted with the filter expression, while adapting to all the different variable name changes etc.

That would be a bit tricky to handle.

Otherwise it would be post-filtering, which could made work as a first step.

@jexp
Copy link
Contributor

jexp commented Nov 22, 2019

can you try that on the /experimental endpoint? which is based on neo4j-graphql-java

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

3 participants