Demo GraphQL server running on hyper-express
- Node v20.x
This demo service uses:
- @graphql-tools/schema to prepare schema
- dotenv
- graphql to execute commands
- hyper-express
- knex
- pg (for PostgreSQL database)
npm i
Refer to .sample.env
, copy as .env
and edit.
npm run build
# execute transpiled code in ./build
npm run start
# or execute TypeScript code in ./src
npm run start:ts
curl --location 'http://localhost:8080/'
curl --location 'http://localhost:8080/health'
# simple test feature to echo inputs
curl --location 'http://localhost:8080/test' \
--header 'Content-Type: application/json' \
--data '{
"a": 123
}'
# simple 'health' feature to check db connection
curl --location 'http://localhost:8080/graphql' \
--header 'Content-Type: application/json' \
--data '{"query":"query {\n health {\n data\n error\n }\n}","variables":{}}'
# simple 'me' feature to get user details
curl --location 'http://localhost:8080/graphql' \
--header 'Content-Type: application/json' \
--data '{"query":"query {\n me {\n id\n username\n }\n}","variables":{}}'
curl --location 'http://localhost:8080/graphql' \
--header 'Content-Type: application/json' \
--data '{"query":"query me($inputs: LocationHistoryInput) {\n me {\n id\n username\n locationHistory(inputs: $inputs) {\n data {\n ts\n latitude\n longitude\n }\n }\n }\n}","variables":{"inputs":{"after":"1701617081"}}}'
Refer to schema.graphql
Refer to ./src/types.ts