Skip to content

Commit a928bb3

Browse files
committed
fix: update dependencies for NestJs 9 compatibility
1 parent bbadef0 commit a928bb3

File tree

6 files changed

+2656
-3086
lines changed

6 files changed

+2656
-3086
lines changed

example/__tests__/app.e2e-spec.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import { Test, TestingModule } from "@nestjs/testing";
22
import { INestApplication } from "@nestjs/common";
33
import { GraphQLModule } from "@nestjs/graphql";
4+
import { ApolloServerBase } from 'apollo-server-core';
45
import gql from "graphql-tag";
56
import { AppModule } from "./../src/app.module";
6-
import { Factory } from "typeorm-factory";
7+
import { Factory } from '@linnify/typeorm-factory';
78
import { Account } from "../src/account/account.entity";
9+
import { ApolloDriver } from "@nestjs/apollo";
10+
11+
class AccountFactory extends Factory<Account> {
12+
entity = Account;
13+
name = 'name'
14+
}
815

916
describe("AppModule", () => {
1017
let app: INestApplication;
11-
let server: GraphQLModule["apolloServer"];
18+
let apolloClient: ApolloServerBase;
1219

1320
beforeAll(async () => {
1421
const moduleFixture: TestingModule = await Test.createTestingModule({
@@ -18,20 +25,18 @@ describe("AppModule", () => {
1825
app = moduleFixture.createNestApplication();
1926
await app.init();
2027

21-
const module: GraphQLModule =
22-
moduleFixture.get<GraphQLModule>(GraphQLModule);
23-
24-
server = module.apolloServer;
28+
const graphqlModule = app.get<GraphQLModule<ApolloDriver>>(GraphQLModule);
29+
apolloClient = graphqlModule.graphQlAdapter?.instance;
2530
});
2631

2732
afterAll(() => app.close());
2833

2934
it("defined", () => expect(app).toBeDefined());
3035

3136
it("/graphql(POST) getAccounts", async () => {
32-
const f = new Factory(Account).attr("name", "name");
37+
const f = new AccountFactory();
3338
const account = await f.create();
34-
const result = await server.executeOperation({
39+
const result = await apolloClient.executeOperation({
3540
query: gql`
3641
query q($ids: [ID!]!) {
3742
getAccounts(ids: $ids) {

example/src/account/account.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export class AccountService {
1212

1313
async findByIds(ids: readonly string[]) {
1414
return this.accounts.find({
15-
id: In(ids as string[]),
15+
where: {
16+
id: In(ids as string[]),
17+
},
1618
});
1719
}
1820
}

example/src/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Module } from "@nestjs/common";
22
import { GraphQLModule } from "@nestjs/graphql";
3+
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
34
import { TypeOrmModule } from "@nestjs/typeorm";
45
import { join } from "path";
56
import { AccountModule } from "./account/account.module";
67

78
@Module({
89
imports: [
9-
GraphQLModule.forRoot({
10+
GraphQLModule.forRoot<ApolloDriverConfig>({
11+
driver: ApolloDriver,
1012
autoSchemaFile: true,
1113
debug: true,
1214
}),

example/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"target": "es6",
99
"sourceMap": true,
1010
"outDir": "./dist",
11-
"skipLibCheck": true
11+
"skipLibCheck": true,
12+
"esModuleInterop": true
1213
},
1314
"include": ["src"],
1415
"exclude": ["node_modules", "*.spec.ts"]

package.json

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,40 @@
2020
"graphql"
2121
],
2222
"peerDependencies": {
23-
"@apollo/gateway": "^0.41.0",
24-
"@nestjs/common": "^8.0.6",
25-
"@nestjs/core": "^8.0.6",
26-
"@nestjs/graphql": "^9.0.4",
27-
"graphql": "^15.5.3",
28-
"reflect-metadata": "^0.1.12"
23+
"@apollo/gateway": "^2.1.0",
24+
"@nestjs/common": "^9.0.11",
25+
"@nestjs/core": "^9.0.11",
26+
"@nestjs/graphql": "^10.0.22",
27+
"graphql": "^16.6.0",
28+
"reflect-metadata": "^0.1.13"
2929
},
3030
"dependencies": {
31-
"dataloader": "^2.0.0"
31+
"dataloader": "^2.1.0"
3232
},
3333
"devDependencies": {
34-
"@apollo/gateway": "^0.41.0",
35-
"@nestjs/cli": "^8.1.1",
36-
"@nestjs/common": "^8.0.6",
37-
"@nestjs/core": "^8.0.6",
38-
"@nestjs/graphql": "^9.0.4",
39-
"@nestjs/platform-express": "^8.0.6",
40-
"@nestjs/testing": "^8.0.6",
41-
"@nestjs/typeorm": "^8.0.2",
42-
"@types/jest": "^27.0.1",
43-
"apollo-server-express": "^3.3.0",
44-
"graphql": "^15.5.3",
45-
"jest": "^27.2.0",
46-
"reflect-metadata": "^0.1.12",
47-
"rxjs": "^7.3.0",
48-
"sqlite3": "^5.0.2",
49-
"ts-jest": "^27.0.5",
50-
"ts-morph": "^12.0.0",
51-
"typeorm": "^0.2.24",
52-
"typeorm-factory": "^0.0.14",
53-
"typescript": "^4.4.3"
34+
"@apollo/gateway": "^2.1.0",
35+
"@linnify/typeorm-factory": "^1.0.12",
36+
"@nestjs/apollo": "^10.0.22",
37+
"@nestjs/cli": "^9.1.1",
38+
"@nestjs/common": "^9.0.11",
39+
"@nestjs/core": "^9.0.11",
40+
"@nestjs/graphql": "^10.0.22",
41+
"@nestjs/platform-express": "^9.0.11",
42+
"@nestjs/testing": "^9.0.11",
43+
"@nestjs/typeorm": "^9.0.1",
44+
"@types/jest": "^28.1.8",
45+
"@types/supertest": "^2.0.12",
46+
"apollo-server-express": "^3.10.2",
47+
"graphql": "^16.6.0",
48+
"jest": "^29.0.1",
49+
"reflect-metadata": "^0.1.13",
50+
"rxjs": "^7.5.6",
51+
"sqlite3": "^5.0.11",
52+
"supertest": "^6.2.4",
53+
"ts-jest": "^28.0.8",
54+
"ts-morph": "^15.1.0",
55+
"typeorm": "^0.3.9",
56+
"typescript": "^4.8.2"
5457
},
5558
"types": "index.d.ts",
5659
"jest": {

0 commit comments

Comments
 (0)