neo4j-graphql / neo4j-graphql-js

NOTE: This project is no longer actively maintained. Please consider using the official Neo4j GraphQL Library (linked in README).
Other
608 stars 148 forks source link

Feature request: Filters for list properties #350

Open wheresrhys opened 4 years ago

wheresrhys commented 4 years ago

If I have a property, myProp, which is a list of strings or enums, I would like to be able to use a myProp_contains filter.

It looks like the lack of filters is by design https://github.com/neo4j-graphql/neo4j-graphql-js/blob/master/src/augment/input-values.js#L69, and most filters wouldn't make sense for lists, but contains querying feels like a very valid use case, and would map well to using IN in the underlying cypher.

I'm happy to submit a PR if you're in favour of the feature

benjamin-rood commented 4 years ago

If I have a property (...) which is a list

I'm assuming you mean a property on a node in your Neo4j graph, but w.r.t. graphql strictly, just to clarify:

You mean a field in a type in your schema, yes?

wheresrhys commented 4 years ago

Yes. To be absolutely precise the type would be something like

type MyThing {
     myProp: [String]
}

And I want to be able to query with

{
    MyThing(filter: {
         myProp_contains: "some string"
    }) {
       // some properties
   }
}

Which would run something akin to this in cypher:

MATCH (node:MyThing)
WHERE  "some string" IN node.myProp
...
mobsean commented 3 years ago

Issue should be closed, because PR #513

mobsean commented 3 years ago

Not sure to open a new Issue but: As is said yesterday. The filter for list properties is working.

When you chain filters with AND or OR the filter isn´t working anymore.

For example: typeDef: type MyThing { myProp: [String] myOtherProp: String }

Totally fine: query test { MyThing(filter: { myProp: ["abc"] }) { myProp myOtherProp } }

Not working: --> empty result. (I´m sure, there should be results) query test2 { MyThing(filter: { AND: [ { myProp: ["abc"] }, { myOtherProp: "def" } ] }) { myProp myOtherProp } }

michaeldgraham commented 3 years ago

https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608