Skip to content

Commit f89f1bb

Browse files
Merge pull request #4844 from MacondoExpress/unique-types-random-chunk
use UniqueType on root integration test files and subscription path
2 parents 2259c6d + 8509a3d commit f89f1bb

14 files changed

+732
-631
lines changed

packages/graphql/tests/integration/enums.int.test.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@
1717
* limitations under the License.
1818
*/
1919

20-
import type { Driver } from "neo4j-driver";
2120
import { graphql } from "graphql";
21+
import type { Driver } from "neo4j-driver";
2222
import { generate } from "randomstring";
23-
import Neo4jHelper from "./neo4j";
2423
import { Neo4jGraphQL } from "../../src/classes";
24+
import { UniqueType } from "../utils/graphql-types";
25+
import Neo4jHelper from "./neo4j";
2526

2627
describe("enums", () => {
2728
let driver: Driver;
2829
let neo4j: Neo4jHelper;
30+
let Movie: UniqueType;
2931

3032
beforeAll(async () => {
3133
neo4j = new Neo4jHelper();
3234
driver = await neo4j.getDriver();
35+
Movie = new UniqueType("Movie");
3336
});
3437

3538
afterAll(async () => {
@@ -44,7 +47,7 @@ describe("enums", () => {
4447
ACTIVE
4548
}
4649
47-
type Movie {
50+
type ${Movie} {
4851
id: ID
4952
status: Status
5053
}
@@ -58,8 +61,8 @@ describe("enums", () => {
5861

5962
const create = `
6063
mutation {
61-
createMovies(input:[{id: "${id}", status: ACTIVE}]) {
62-
movies {
64+
${Movie.operations.create}(input:[{id: "${id}", status: ACTIVE}]) {
65+
${Movie.plural} {
6366
id
6467
}
6568
}
@@ -76,7 +79,7 @@ describe("enums", () => {
7679
expect(gqlResult.errors).toBeFalsy();
7780

7881
const result = await session.run(`
79-
MATCH (m:Movie {id: "${id}"})
82+
MATCH (m:${Movie} {id: "${id}"})
8083
RETURN m {.id, .status} as m
8184
`);
8285

@@ -96,7 +99,7 @@ describe("enums", () => {
9699
EATING
97100
}
98101
99-
type Movie {
102+
type ${Movie} {
100103
id: ID
101104
status: Status @default(value: ACTIVE)
102105
}
@@ -110,8 +113,8 @@ describe("enums", () => {
110113

111114
const create = `
112115
mutation {
113-
createMovies(input:[{id: "${id}"}]) {
114-
movies {
116+
${Movie.operations.create}(input:[{id: "${id}"}]) {
117+
${Movie.plural} {
115118
id
116119
}
117120
}
@@ -128,7 +131,7 @@ describe("enums", () => {
128131
expect(gqlResult.errors).toBeFalsy();
129132

130133
const result = await session.run(`
131-
MATCH (m:Movie {id: "${id}"})
134+
MATCH (m:${Movie} {id: "${id}"})
132135
RETURN m {.id, .status} as m
133136
`);
134137

@@ -150,7 +153,7 @@ describe("enums", () => {
150153
ACTIVE
151154
}
152155
153-
type Movie {
156+
type ${Movie} {
154157
id: ID
155158
status: Status
156159
}
@@ -164,8 +167,8 @@ describe("enums", () => {
164167

165168
const create = `
166169
mutation {
167-
createMovies(input:[{id: "${id}", status: ACTIVE}]) {
168-
movies {
170+
${Movie.operations.create}(input:[{id: "${id}", status: ACTIVE}]) {
171+
${Movie.plural} {
169172
id
170173
}
171174
}
@@ -182,7 +185,7 @@ describe("enums", () => {
182185
expect(gqlResult.errors).toBeFalsy();
183186

184187
const result = await session.run(`
185-
MATCH (m:Movie {id: "${id}"})
188+
MATCH (m:${Movie} {id: "${id}"})
186189
RETURN m {.id, .status} as m
187190
`);
188191

@@ -206,7 +209,7 @@ describe("enums", () => {
206209
EATING
207210
}
208211
209-
type Movie {
212+
type ${Movie} {
210213
id: ID
211214
status: Status @default(value: ACTIVE)
212215
}
@@ -220,8 +223,8 @@ describe("enums", () => {
220223

221224
const create = `
222225
mutation {
223-
createMovies(input:[{id: "${id}"}]) {
224-
movies {
226+
${Movie.operations.create}(input:[{id: "${id}"}]) {
227+
${Movie.plural} {
225228
id
226229
}
227230
}
@@ -238,7 +241,7 @@ describe("enums", () => {
238241
expect(gqlResult.errors).toBeFalsy();
239242

240243
const result = await session.run(`
241-
MATCH (m:Movie {id: "${id}"})
244+
MATCH (m:${Movie} {id: "${id}"})
242245
RETURN m {.id, .status} as m
243246
`);
244247

packages/graphql/tests/integration/errors.int.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
import type { GraphQLError } from "graphql";
2121
import { graphql } from "graphql";
2222
import { Neo4jGraphQL } from "../../src/classes";
23+
import { UniqueType } from "../utils/graphql-types";
2324

2425
describe("Errors", () => {
2526
test("An error should be thrown if no driver is supplied", async () => {
27+
const Movie = new UniqueType("Movie");
28+
2629
const typeDefs = `
27-
type Movie {
30+
type ${Movie} {
2831
id: ID
2932
}
3033
`;
@@ -33,7 +36,7 @@ describe("Errors", () => {
3336

3437
const query = `
3538
query {
36-
movies {
39+
${Movie.plural} {
3740
id
3841
}
3942
}

packages/graphql/tests/integration/field-filtering.int.test.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
* limitations under the License.
1818
*/
1919

20-
import type { Driver } from "neo4j-driver";
2120
import { graphql } from "graphql";
22-
import { generate } from "randomstring";
2321
import { gql } from "graphql-tag";
24-
import Neo4jHelper from "./neo4j";
22+
import type { Driver } from "neo4j-driver";
23+
import { generate } from "randomstring";
2524
import { Neo4jGraphQL } from "../../src/classes";
25+
import { UniqueType } from "../utils/graphql-types";
26+
import Neo4jHelper from "./neo4j";
2627

2728
describe("field-filtering", () => {
2829
let driver: Driver;
@@ -39,19 +40,22 @@ describe("field-filtering", () => {
3940

4041
test("should use connection filter on field", async () => {
4142
const session = await neo4j.getSession();
43+
const Movie = new UniqueType("Movie");
44+
const Series = new UniqueType("Series");
45+
const Genre = new UniqueType("Genre");
4246

4347
const typeDefs = gql`
44-
type Movie {
48+
type ${Movie} {
4549
title: String!
46-
genres: [Genre!]! @relationship(type: "IN_GENRE", direction: OUT)
50+
genres: [${Genre}!]! @relationship(type: "IN_GENRE", direction: OUT)
4751
}
4852
49-
type Genre {
53+
type ${Genre} {
5054
name: String!
51-
series: [Series!]! @relationship(type: "IN_SERIES", direction: OUT)
55+
series: [${Series}!]! @relationship(type: "IN_SERIES", direction: OUT)
5256
}
5357
54-
type Series {
58+
type ${Series} {
5559
name: String!
5660
}
5761
`;
@@ -75,7 +79,7 @@ describe("field-filtering", () => {
7579

7680
const query = `
7781
{
78-
movies(where: { title: "${movieTitle}" }) {
82+
${Movie.plural}(where: { title: "${movieTitle}" }) {
7983
title
8084
genres(where: { seriesConnection: { node: { name: "${seriesName}" } } }) {
8185
name
@@ -88,8 +92,8 @@ describe("field-filtering", () => {
8892
`;
8993

9094
const cypher = `
91-
CREATE (m:Movie {title:$movieTitle})-[:IN_GENRE]->(:Genre {name:$genreName1})-[:IN_SERIES]->(:Series {name:$seriesName})
92-
CREATE (m)-[:IN_GENRE]->(:Genre {name:$genreName2})
95+
CREATE (m:${Movie} {title:$movieTitle})-[:IN_GENRE]->(:${Genre} {name:$genreName1})-[:IN_SERIES]->(:${Series} {name:$seriesName})
96+
CREATE (m)-[:IN_GENRE]->(:${Genre} {name:$genreName2})
9397
`;
9498

9599
try {
@@ -107,7 +111,7 @@ describe("field-filtering", () => {
107111

108112
expect(gqlResult.errors).toBeUndefined();
109113

110-
expect((gqlResult.data as any).movies).toEqual([
114+
expect((gqlResult.data as any)[Movie.plural]).toEqual([
111115
{ title: movieTitle, genres: [{ name: genreName1, series: [{ name: seriesName }] }] },
112116
]);
113117
} finally {

0 commit comments

Comments
 (0)