diff --git a/packages/graphql/tests/integration/directives/cypher/filtering/relationships/cypher-filtering-relationship-connection.int.test.ts b/packages/graphql/tests/integration/directives/cypher/filtering/relationships/cypher-filtering-relationship-connection.int.test.ts index 0c852290fc..348c1bc666 100644 --- a/packages/graphql/tests/integration/directives/cypher/filtering/relationships/cypher-filtering-relationship-connection.int.test.ts +++ b/packages/graphql/tests/integration/directives/cypher/filtering/relationships/cypher-filtering-relationship-connection.int.test.ts @@ -26,96 +26,6 @@ describe("Connection API - cypher directive filtering - Relationship", () => { await testHelper.close(); }); - test("Connection API - relationship with single property filter", async () => { - const Movie = testHelper.createUniqueType("Movie"); - const Actor = testHelper.createUniqueType("Actor"); - - const typeDefs = /* GraphQL */ ` - 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" - ) - } - `; - - await testHelper.initNeo4jGraphQL({ typeDefs }); - await testHelper.executeCypher( - ` - CREATE (m:${Movie} { title: "The Matrix" }) - CREATE (m2:${Movie} { title: "The Matrix Reloaded" }) - CREATE (m3:${Movie} { title: "The Matrix Revolutions" }) - CREATE (a:${Actor} { name: "Keanu Reeves" }) - CREATE (a)-[:ACTED_IN]->(m) - CREATE (a)-[:ACTED_IN]->(m2) - CREATE (a)-[:ACTED_IN]->(m3) - CREATE (a2:${Actor} { name: "Carrie-Anne Moss" }) - CREATE (a2)-[:ACTED_IN]->(m) - CREATE (a2)-[:ACTED_IN]->(m2) - CREATE (a2)-[:ACTED_IN]->(m3) - CREATE (a3:${Actor} { name: "Jada Pinkett Smith" }) - CREATE (a3)-[:ACTED_IN]->(m2) - CREATE (a3)-[:ACTED_IN]->(m3) - `, - {} - ); - - const query = /* GraphQL */ ` - query { - ${Movie.operations.connection}( - where: { - actors: { - name_EQ: "Jada Pinkett Smith" - } - } - ) { - edges { - node { - title - } - } - } - } - `; - - const gqlResult = await testHelper.executeGraphQL(query); - - expect(gqlResult.errors).toBeFalsy(); - expect(gqlResult?.data).toEqual({ - [Movie.operations.connection]: { - edges: expect.toIncludeSameMembers([ - { - node: { - title: "The Matrix Reloaded", - }, - }, - { - node: { - title: "The Matrix Revolutions", - }, - }, - ]), - }, - }); - }); - test("Connection API - relationship with single property filter NOT", async () => { const Movie = testHelper.createUniqueType("Movie"); const Actor = testHelper.createUniqueType("Actor"); @@ -172,7 +82,7 @@ describe("Connection API - cypher directive filtering - Relationship", () => { ${Movie.operations.connection}( where: { NOT: { - actors: { + actors_SOME: { name_EQ: "Jada Pinkett Smith" } } @@ -689,8 +599,8 @@ describe("Connection API - cypher directive filtering - Relationship", () => { ${Movie.operations.connection}( where: { OR: [ - { actors: { name_EQ: "Jada Pinkett Smith" } }, - { genres: { name_EQ: "Romance" } } + { actors_SOME: { name_EQ: "Jada Pinkett Smith" } }, + { genres_SOME: { name_EQ: "Romance" } } ] } ) diff --git a/packages/graphql/tests/integration/directives/cypher/filtering/relationships/cypher-filtering-relationship.int.test.ts b/packages/graphql/tests/integration/directives/cypher/filtering/relationships/cypher-filtering-relationship.int.test.ts index a22138a2dd..471ff4f4eb 100644 --- a/packages/graphql/tests/integration/directives/cypher/filtering/relationships/cypher-filtering-relationship.int.test.ts +++ b/packages/graphql/tests/integration/directives/cypher/filtering/relationships/cypher-filtering-relationship.int.test.ts @@ -26,86 +26,6 @@ describe("cypher directive filtering - Relationship", () => { await testHelper.close(); }); - test("relationship with single property filter", async () => { - const Movie = testHelper.createUniqueType("Movie"); - const Actor = testHelper.createUniqueType("Actor"); - - const typeDefs = /* GraphQL */ ` - 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" - ) - } - `; - - await testHelper.initNeo4jGraphQL({ typeDefs }); - await testHelper.executeCypher( - ` - CREATE (m:${Movie} { title: "The Matrix" }) - CREATE (m2:${Movie} { title: "The Matrix Reloaded" }) - CREATE (m3:${Movie} { title: "The Matrix Revolutions" }) - CREATE (a:${Actor} { name: "Keanu Reeves" }) - CREATE (a)-[:ACTED_IN]->(m) - CREATE (a)-[:ACTED_IN]->(m2) - CREATE (a)-[:ACTED_IN]->(m3) - CREATE (a2:${Actor} { name: "Carrie-Anne Moss" }) - CREATE (a2)-[:ACTED_IN]->(m) - CREATE (a2)-[:ACTED_IN]->(m2) - CREATE (a2)-[:ACTED_IN]->(m3) - CREATE (a3:${Actor} { name: "Jada Pinkett Smith" }) - CREATE (a3)-[:ACTED_IN]->(m2) - CREATE (a3)-[:ACTED_IN]->(m3) - `, - {} - ); - - const query = /* GraphQL */ ` - query { - ${Movie.plural}( - where: { - actors: { - name_EQ: "Jada Pinkett Smith" - } - } - ) { - title - } - } - `; - - const gqlResult = await testHelper.executeGraphQL(query); - - expect(gqlResult.errors).toBeFalsy(); - expect(gqlResult?.data).toEqual({ - [Movie.plural]: expect.toIncludeSameMembers([ - { - title: "The Matrix Reloaded", - }, - { - title: "The Matrix Revolutions", - }, - ]), - }); - }); - test("relationship with single property filter NOT", async () => { const Movie = testHelper.createUniqueType("Movie"); const Actor = testHelper.createUniqueType("Actor"); @@ -162,7 +82,7 @@ describe("cypher directive filtering - Relationship", () => { ${Movie.plural}( where: { NOT: { - actors: { + actors_SOME: { name_EQ: "Jada Pinkett Smith" } } @@ -553,8 +473,8 @@ describe("cypher directive filtering - Relationship", () => { ${Movie.plural}( where: { OR: [ - { actors: { name_EQ: "Jada Pinkett Smith" } }, - { genres: { name_EQ: "Romance" } } + { actors_SOME: { name_EQ: "Jada Pinkett Smith" } }, + { genres_SOME: { name_EQ: "Romance" } } ] } ) diff --git a/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship-auth.test.ts b/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship-auth.test.ts index 04b6046114..af15457e57 100644 --- a/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship-auth.test.ts +++ b/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship-auth.test.ts @@ -26,7 +26,7 @@ describe("cypher directive filtering - relationship auth filter", () => { const typeDefs = /* GraphQL */ ` type Movie @node - @authorization(filter: [{ where: { node: { actors: { name_EQ: "$jwt.custom_value" } } } }]) { + @authorization(filter: [{ where: { node: { actors_SOME: { name_EQ: "$jwt.custom_value" } } } }]) { title: String rating: Float actors: [Actor!]! @@ -118,7 +118,7 @@ describe("cypher directive filtering - relationship auth filter", () => { const typeDefs = /* GraphQL */ ` type Movie @node - @authorization(filter: [{ where: { node: { actors: { name_EQ: "$jwt.custom_value" } } } }]) { + @authorization(filter: [{ where: { node: { actors_SOME: { name_EQ: "$jwt.custom_value" } } } }]) { title: String rating: Float actors: [Actor!]! @@ -210,7 +210,7 @@ describe("cypher directive filtering - relationship auth filter", () => { const typeDefs = /* GraphQL */ ` type Movie @node - @authorization(validate: [{ where: { node: { actors: { name_EQ: "$jwt.custom_value" } } } }]) { + @authorization(validate: [{ where: { node: { actors_SOME: { name_EQ: "$jwt.custom_value" } } } }]) { title: String rating: Float actors: [Actor!]! @@ -302,7 +302,7 @@ describe("cypher directive filtering - relationship auth filter", () => { const typeDefs = /* GraphQL */ ` type Movie @node - @authorization(validate: [{ where: { node: { actors: { name_EQ: "$jwt.custom_value" } } } }]) { + @authorization(validate: [{ where: { node: { actors_SOME: { name_EQ: "$jwt.custom_value" } } } }]) { title: String rating: Float actors: [Actor!]! diff --git a/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship-connection.test.ts b/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship-connection.test.ts index 9d36ecd56f..4792405991 100644 --- a/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship-connection.test.ts +++ b/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship-connection.test.ts @@ -21,83 +21,6 @@ import { Neo4jGraphQL } from "../../../../../../src"; import { formatCypher, formatParams, translateQuery } from "../../../../utils/tck-test-utils"; describe("Connection API - cypher directive filtering - Relationship", () => { - test("Connection API - relationship with single property filter", async () => { - const typeDefs = /* GraphQL */ ` - 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" - ) - } - `; - - const neoSchema: Neo4jGraphQL = new Neo4jGraphQL({ - typeDefs, - }); - - const query = /* GraphQL */ ` - query { - moviesConnection(where: { actors: { name_EQ: "Jada Pinkett Smith" } }) { - edges { - node { - title - } - } - } - } - `; - - const result = await translateQuery(neoSchema, query); - - expect(formatCypher(result.cypher)).toMatchInlineSnapshot(` - "MATCH (this0:Movie) - CALL { - WITH this0 - CALL { - WITH this0 - WITH this0 AS this - MATCH (this)<-[:ACTED_IN]-(actor:Actor) - RETURN actor - } - WITH actor AS this1 - RETURN collect(this1) AS this2 - } - WITH * - WHERE any(this3 IN this2 WHERE this3.name = $param0) - WITH collect({ node: this0 }) AS edges - WITH edges, size(edges) AS totalCount - CALL { - WITH edges - UNWIND edges AS edge - WITH edge.node AS this0 - RETURN collect({ node: { title: this0.title, __resolveType: \\"Movie\\" } }) AS var4 - } - RETURN { edges: var4, totalCount: totalCount } AS this" - `); - expect(formatParams(result.params)).toMatchInlineSnapshot(` - "{ - \\"param0\\": \\"Jada Pinkett Smith\\" - }" - `); - }); - test("Connection API - relationship with single property filter NOT", async () => { const typeDefs = /* GraphQL */ ` type Movie @node { @@ -131,7 +54,7 @@ describe("Connection API - cypher directive filtering - Relationship", () => { const query = /* GraphQL */ ` query { - moviesConnection(where: { NOT: { actors: { name_EQ: "Jada Pinkett Smith" } } }) { + moviesConnection(where: { NOT: { actors_SOME: { name_EQ: "Jada Pinkett Smith" } } }) { edges { node { title @@ -616,7 +539,12 @@ describe("Connection API - cypher directive filtering - Relationship", () => { const query = /* GraphQL */ ` query { moviesConnection( - where: { OR: [{ actors: { name_EQ: "Jada Pinkett Smith" } }, { genres: { name_EQ: "Romance" } }] } + where: { + OR: [ + { actors_SOME: { name_EQ: "Jada Pinkett Smith" } } + { genres_SOME: { name_EQ: "Romance" } } + ] + } ) { edges { node { diff --git a/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship.test.ts b/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship.test.ts index 4039621cd5..5dfc575479 100644 --- a/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship.test.ts +++ b/packages/graphql/tests/tck/directives/cypher/filtering/relationships/cypher-filtering-relationship.test.ts @@ -21,71 +21,6 @@ import { Neo4jGraphQL } from "../../../../../../src"; import { formatCypher, formatParams, translateQuery } from "../../../../utils/tck-test-utils"; describe("cypher directive filtering - Relationship", () => { - test("relationship with single property filter", async () => { - const typeDefs = /* GraphQL */ ` - 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" - ) - } - `; - - const neoSchema: Neo4jGraphQL = new Neo4jGraphQL({ - typeDefs, - }); - - const query = /* GraphQL */ ` - query { - movies(where: { actors: { name_EQ: "Jada Pinkett Smith" } }) { - title - } - } - `; - - const result = await translateQuery(neoSchema, query); - - expect(formatCypher(result.cypher)).toMatchInlineSnapshot(` - "MATCH (this:Movie) - CALL { - WITH this - CALL { - WITH this - WITH this AS this - MATCH (this)<-[:ACTED_IN]-(actor:Actor) - RETURN actor - } - WITH actor AS this0 - RETURN collect(this0) AS this1 - } - WITH * - WHERE any(this2 IN this1 WHERE this2.name = $param0) - RETURN this { .title } AS this" - `); - expect(formatParams(result.params)).toMatchInlineSnapshot(` - "{ - \\"param0\\": \\"Jada Pinkett Smith\\" - }" - `); - }); - test("relationship with single property filter NOT", async () => { const typeDefs = /* GraphQL */ ` type Movie @node { @@ -119,7 +54,7 @@ describe("cypher directive filtering - Relationship", () => { const query = /* GraphQL */ ` query { - movies(where: { NOT: { actors: { name_EQ: "Jada Pinkett Smith" } } }) { + movies(where: { NOT: { actors_SOME: { name_EQ: "Jada Pinkett Smith" } } }) { title } } @@ -464,7 +399,12 @@ describe("cypher directive filtering - Relationship", () => { const query = /* GraphQL */ ` query { movies( - where: { OR: [{ actors: { name_EQ: "Jada Pinkett Smith" } }, { genres: { name_EQ: "Romance" } }] } + where: { + OR: [ + { actors_SOME: { name_EQ: "Jada Pinkett Smith" } } + { genres_SOME: { name_EQ: "Romance" } } + ] + } ) { title }