/demo-hyper-express-graphql-server

Demo GraphQL server running on hyper-express

Primary LanguageTypeScriptThe UnlicenseUnlicense

demo-hyper-express-graphql-server

Demo GraphQL server running on hyper-express

requirements

  • Node v20.x

installation

This demo service uses:

npm i

configuration

Refer to .sample.env, copy as .env and edit.

build

npm run build

start

# execute transpiled code in ./build
npm run start

# or execute TypeScript code in ./src
npm run start:ts

usage

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"}}}'

schema

Refer to schema.graphql

models

Refer to ./src/types.ts