Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ba72efb

Browse files
committedOct 12, 2022
➕ add graphql and apollo
1 parent f75c4f9 commit ba72efb

6 files changed

+533
-24
lines changed
 

‎.eslintrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,11 @@ module.exports = {
2121
'@typescript-eslint/explicit-function-return-type': 'off',
2222
'@typescript-eslint/explicit-module-boundary-types': 'off',
2323
'@typescript-eslint/no-explicit-any': 'off',
24+
'prettier/prettier': [
25+
'error',
26+
{
27+
endOfLine: 'auto',
28+
},
29+
],
2430
},
2531
};

‎.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"singleQuote": true,
33
"trailingComma": "all"
4-
}
4+
}

‎package.json

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"start:dev": "nest start --watch",
1414
"start:debug": "nest start --debug --watch",
1515
"start:prod": "node dist/main",
16+
"generate-typings": "ts-node ./src/generate-typings.ts",
1617
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
1718
"test": "jest",
1819
"test:watch": "jest --watch",
@@ -23,8 +24,12 @@
2324
"dependencies": {
2425
"@nestjs/common": "^9.0.0",
2526
"@nestjs/core": "^9.0.0",
27+
"@nestjs/graphql": "^10.1.3",
28+
"@nestjs/mapped-types": "*",
2629
"@nestjs/platform-express": "^9.0.0",
2730
"@prisma/client": "^4.4.0",
31+
"apollo-server-express": "^3.10.3",
32+
"graphql": "^16.6.0",
2833
"prisma": "^4.4.0",
2934
"reflect-metadata": "^0.1.13",
3035
"rimraf": "^3.0.2",

‎src/app.module.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import { Module } from '@nestjs/common';
22
import { AppController } from './app.controller';
33
import { AppService } from './app.service';
4+
import { GraphQLModule } from '@nestjs/graphql';
5+
import { ApolloServerPluginLandingPageLocalDefault } from 'apollo-server-core';
6+
import { AuthenticationModule } from './authentication/authentication.module';
47

58
@Module({
6-
imports: [],
9+
imports: [
10+
GraphQLModule.forRoot({
11+
playground: false,
12+
plugins: [ApolloServerPluginLandingPageLocalDefault()],
13+
typePaths: ['./**/*.graphql'],
14+
}),
15+
AuthenticationModule,
16+
],
717
controllers: [AppController],
818
providers: [AppService],
919
})

‎src/generate-typings.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { GraphQLDefinitionsFactory } from '@nestjs/graphql';
2+
import { join } from 'path';
3+
4+
const definitionsFactory = new GraphQLDefinitionsFactory();
5+
6+
/* Generating the types for the GraphQL schema. */
7+
definitionsFactory.generate({
8+
typePaths: ['./src/**/*.graphql'],
9+
path: join(process.cwd(), 'src/graphql.ts'),
10+
outputAs: 'class',
11+
watch: true,
12+
});

‎yarn.lock

+498-22
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.