Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup of GraphQL Codegenerator #87

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Create an `.env` file at the root of the `api` directory:

```
```dotenv
# MongoDB connection string and database name
MONGO_URI=***
MONGO_DB_NAME=***
Expand All @@ -35,7 +35,7 @@ Note: contact me (Sacha) on [Discord](https://discord.gg/zRDb35jfrt) if you need

## Running the App

```
```sh
npm run dev
npm run dev:clean # run without cache
```
Expand Down
11 changes: 11 additions & 0 deletions api/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
overwrite: true
schema:
- src/type_defs/*.graphql:
skipGraphQLImport: true # skip #import comments
generates:
src/generated/graphql.ts:
plugins:
- typescript
- typescript-resolvers
config:
contextType: ../types#RequestContext
6 changes: 5 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
"write-file-webpack-plugin": "^4.5.1"
},
"devDependencies": {
"@types/node-fetch": "^2.5.12",
"@graphql-codegen/cli": "^2.6.2",
"@graphql-codegen/typescript": "^2.4.8",
"@graphql-codegen/typescript-resolvers": "^2.6.1",
"@types/js-yaml": "^4.0.3",
"@types/lodash": "^4.14.175",
"@types/marked": "^2.0.4",
"@types/mongodb": "^4.0.7",
"@types/node": "^16.7.0",
"@types/node-fetch": "^2.5.12",
"@types/webpack-env": "^1.16.3",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "^9.0.1",
Expand All @@ -44,6 +47,7 @@
},
"scripts": {
"build": "NODE_ENV=production webpack --config webpack.production.js",
"prebuild": "graphql-codegen --config codegen.yml",
"dev": "NODE_ENV=development webpack --config webpack.development.js",
"dev:clean": "NODE_ENV=development DISABLE_CACHE=true webpack --config webpack.development.js",
"fmt": "prettier --write \"src/**/*.{ts,js,mjs,yml,graphql}\"",
Expand Down
Loading