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

(6.x) Cypher filtering many to many relationships #5856

Merged
merged 6 commits into from
Nov 29, 2024

Conversation

mjfwebb
Copy link
Contributor

@mjfwebb mjfwebb commented Nov 28, 2024

Description

This PR adds the ability to filter on many to many (m:m) relationship cypher fields. An example:

Type definitions:

type Movie @node {
    title: String
    actors: [Actor!]!
        @cypher(
            statement: """
            MATCH (this)<-[:ACTED_IN]-(actor:Actor)
            RETURN actor
            """
            columnName: "actor"
        )
}

type Actor @node {
    name: String
    movies: [Movie!]!
        @cypher(
            statement: """
            MATCH (this)-[:ACTED_IN]->(movie:Movie)
            RETURN movie
            """
            columnName: "movie"
        )
}

You can now query with a filter based on the actors field:

query {
  movies(where: { actors: { name: "Jada Pinkett Smith" } }) {
      title
  }
}

Complexity

Medium

Issue

Closes #554.

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • TCK tests have been updated
  • Integration tests have been updated
  • Example applications have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed

Copy link

changeset-bot bot commented Nov 28, 2024

🦋 Changeset detected

Latest commit: 2425b21

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@neo4j/graphql Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@neo4j-team-graphql
Copy link
Collaborator

neo4j-team-graphql commented Nov 28, 2024

Performance Report

No Performance Changes

Show Full Table
name dbHits old dbHits time (ms) old time (ms) maxRows
aggregations.TopLevelAggregate 3404 3404 36 44 1134
aggregations.TopLevelAggregateWithMultipleFields 6802 6802 55 61 1134
aggregations.NestedAggregation 15407 15407 58 82 2174
aggregations.AggregationWithWhere 10833 10833 48 76 2174
aggregations.AggregationWhereWithinNestedRelationships 20097917 20097917 1985 2018 2008534
aggregations.AggregationWhereWithinNestedConnections 20097917 20097917 1956 2012 2008534
aggregations.NestedCountFromMovieToActors 8603 8603 31 41 2174
aggregations.NestedCountFromActorsToMovie 8791 8791 34 49 2174
aggregations.DeeplyNestedCount 10052335 10052335 2387 2840 2008534
aggregations.InterfacesAggregations 6242 6242 45 53 2080
aggregations.InterfacesAggregationsWithTwoFields 11444 11444 74 86 2080
batch-create.BatchCreate 4200 4200 146 158 600
batch-create.BatchCreateSmall 77 77 52 68 11
connect.createAndConnect 6433 6433 133 176 3003
connections.Connection 12951 12951 62 79 2174
connections.NestedConnection 37705 37705 123 143 4516
create.SimpleMutation 7 7 56 65 1
cypher-directive.TopLevelMutationDirective 1135 1135 23 29 1134
delete.SimpleDelete 19401 19401 653 681 1040
2925.SingleRelationshipFilter 5245 5245 38 59 1040
2925.SingleRelationshipRequiredFilter 5201 5201 34 42 1040
query.SimpleQuery 3121 3121 21 22 1040
query.SimpleQueryWithRelationship 15031 15031 41 51 2174
query.SimpleQueryWithNestedWhere 8713 8713 46 59 2154
query.Nested 10084891 10084891 6186 6447 2008534
query.NestedWithFilter 10064992 10064992 6016 6099 2004000
query.OrFilterOnRelationships 36958 36767 151 172 2031
query.QueryWithNestedIn 14480 14480 53 56 1960
query.NestedConnectionWhere 8703 8703 50 75 2174
query.DeeplyNestedConnectionWhere 8702 8702 68 89 2174
query.DeeplyNestedWithRelationshipFilters 17357 17357 132 178 1552
query.NestedWithRelationshipSingleFilters 3808 3808 145 223 1134
query.Fulltext 64 64 31 52 16
query.FulltextWithNestedQuery 516 516 41 74 84
sorting-and-cypher.TopLevelSortWithCypher 12961 12961 49 58 2174
sorting-and-cypher.TopLevelConnectionSortWithCypher 12961 12961 70 67 2174
sorting-and-cypher.TopLevelSortWithCypherWithNested 13096 13096 54 65 2174
sorting-and-cypher.TopLevelConnectionSortWithCypherWithNested 13096 13096 88 104 2174
sorting-and-cypher.TopLevelSortWithExpensiveCypher 13725 13725 97 124 2174
sorting-and-cypher.TopLevelConnectionSortWithExpensiveCypher 13266 13266 106 112 2174
sorting.SortMultipleTypes 3436 3436 81 116 1040
sorting.SortMultipleTypesWithCypherWithCypher 13321 13321 101 112 2174
sorting.SortOnNestedFields 12951 12951 40 46 2174
sorting.SortDeeplyNestedFields 39785 39785 95 83 4516
sorting.ConnectionWithSort 3271 3271 71 78 1040
unions.SimpleUnionQuery 321 321 54 66 35
unions.SimpleUnionQueryWithMissingFields 293 293 52 56 35
unions.NestedUnion 309975 309975 257 271 33033
unions.NestedUnionWithMissingFields 283949 283949 253 337 33033
update.NestedUpdate 14137 14137 98 104 2002

Old Schema Generation: 26.208s
Schema Generation: 26.095s
Old Subgraph Schema Generation: 26.055s
Subgraph Schema Generation: 27.669s

@mjfwebb mjfwebb merged commit 7411910 into neo4j:dev Nov 29, 2024
39 checks passed
@mjfwebb mjfwebb deleted the 6x-cypher-filtering-relationships branch November 29, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate filters for primitive/relational cypher fields
3 participants