This template is used to easily start a GraphQL project, which uses NodeJS and Express.
Currently runs with:
- Express: v4.17.1
- GraphQL: v14.7.0
- Express-GraphQL: v0.9.0
Clone this repo locally:
git clone https://github.com/Lucian1000/graphql-express-nodejs.git
Install dependencies with npm:
npm i
To run this project you have to simply type in a command-line:
npm start
This will start a GraphQL API server at http://localhost:4000.
You can now test the API with this:
curl -X POST -H 'Content-Type: application/json' -d '{"query": "{persons {name} }" }'
In src/config/serve-config.ts you can see the development configs, which are used in index.ts to serve the application at http://localhost:4000. As you can see in the code, the config-object changes depending on NODE_ENV variable.
Commands | Description |
---|---|
npm start | runs 'npm run dev:serve' |
npm run dev:serve | runs 'npm run dev:build' then serves the application with development-configs |
npm run dev:build | transpiles and copies .graphql files into 'build' folder |
npm run prod:serve | runs 'npm run prod:build' then serves the application with production-configs |
npm run prod:build | transpiles and copies .graphql files into 'dist' folder |