Skip to content

Commit

Permalink
feat(api): Update to NestJS v10 and Apollo v4
Browse files Browse the repository at this point in the history
  • Loading branch information
robere2 committed Nov 21, 2024
1 parent 320590d commit 8455a66
Show file tree
Hide file tree
Showing 5 changed files with 10,779 additions and 13,782 deletions.
22 changes: 11 additions & 11 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@apollo/server": "^4.11.2",
"@apollo/utils.keyvadapter": "^3.1.0",
"@casl/ability": "^6.3.3",
"@casl/prisma": "^1.3.3",
"@graphql-tools/utils": "^9.1.4",
"@keyv/redis": "^2.8.3",
"@nestjs/apollo": "^10.1.7",
"@nestjs/common": "^9.3.9",
"@nestjs/config": "^2.3.1",
"@nestjs/core": "^9.0.0",
"@nestjs/graphql": "^10.1.7",
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/apollo": "^12.2.1",
"@nestjs/common": "^10.4.8",
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.4.8",
"@nestjs/graphql": "^12.2.1",
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^10.4.8",
"@prisma/client": "^5.7.0",
"@rpitv/glimpse-prisma": "*",
"amqplib": "^0.10.3",
"apollo-server-express": "^3.11.1",
"argon2": "^0.30.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
Expand All @@ -62,9 +62,9 @@
"rxjs": "^7.2.0"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@nestjs/cli": "^10.4.8",
"@nestjs/schematics": "^10.2.3",
"@nestjs/testing": "^10.4.8",
"@types/connect-redis": "^0.0.19",
"@types/cookie-parser": "^1.4.3",
"@types/express": "^4.17.13",
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/casl/casl.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloServerPlugin } from "apollo-server-plugin-base";
import { ApolloServerPlugin } from "@apollo/server";
import { Logger } from "@nestjs/common";
import { Plugin } from "@nestjs/apollo";
import { CaslAbilityFactory } from "./casl-ability.factory";
Expand All @@ -21,7 +21,7 @@ export class CaslPlugin implements ApolloServerPlugin {
constructor(private caslAbilityFactory: CaslAbilityFactory) {}

async requestDidStart(ctx) {
const req = ctx.context.req;
const req = ctx.contextValue.req;

// Generate the current user's permissions as of this request if they haven't been generated already.
if (!req.permissions) {
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/gql/gql-complexity.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComplexityEstimatorArgs, GraphQLSchemaHost } from "@nestjs/graphql";
import { Plugin } from "@nestjs/apollo";
import { ApolloServerPlugin, GraphQLRequestListener } from "apollo-server-plugin-base";
import { ApolloServerPlugin, GraphQLRequestListener } from "@apollo/server";
import { GraphQLError } from "graphql";
import { fieldExtensionsEstimator, getComplexity, simpleEstimator } from "graphql-query-complexity";
import { Logger } from "@nestjs/common";
Expand Down Expand Up @@ -42,7 +42,7 @@ export class ComplexityPlugin implements ApolloServerPlugin {

constructor(private gqlSchemaHost: GraphQLSchemaHost) {}

async requestDidStart(): Promise<GraphQLRequestListener> {
async requestDidStart(): Promise<GraphQLRequestListener<unknown>> {
// Complexity is quite subjective and cannot be outlined in a comment. Read the wiki page for more information
// on how complexity is calculated: https://github.com/rpitv/glimpse/wiki/Rate-Limiting
const maxComplexity = 1000;
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/prisma/prisma.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloServerPlugin, GraphQLRequestListener } from "apollo-server-plugin-base";
import { ApolloServerPlugin, GraphQLRequestListener } from "@apollo/server";
import { Plugin } from "@nestjs/apollo";
import { PrismaService } from "./prisma.service";
import { Logger } from "@nestjs/common";
Expand Down Expand Up @@ -27,7 +27,7 @@ export class PrismaPlugin implements ApolloServerPlugin {
private logger: Logger = new Logger("PrismaPlugin");
constructor(private readonly prisma: PrismaService) {}

async requestDidStart(ctx): Promise<GraphQLRequestListener> {
async requestDidStart(ctx): Promise<GraphQLRequestListener<unknown>> {
this.logger.verbose("Creating Prisma transaction...");
let endTransaction: () => void;
let failTransaction: (err: any) => void;
Expand All @@ -36,7 +36,7 @@ export class PrismaPlugin implements ApolloServerPlugin {
this.prisma
.$transaction(
async (tx) => {
ctx.context.req.prismaTx = tx;
ctx.contextValue.req.prismaTx = tx;
this.logger.verbose("Prisma transaction created.");
continueRequest();

Expand Down
Loading

0 comments on commit 8455a66

Please sign in to comment.