From cc1726c8518389e7d3962c7074ec0b2e9bc1777a Mon Sep 17 00:00:00 2001 From: Jason Hanggi Date: Wed, 31 May 2023 12:29:42 -0500 Subject: [PATCH] Add npm script for running an example --- examples/README.md | 7 +++++++ package.json | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index e164ca7dc..adc8c81a6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,6 +7,13 @@ All examples has a `examples.gql` file with sample queries/mutations/subscriptio > **Note**: Be aware that the examples on master branch are designed to work with latest codebase that might not be released yet. > So if you are looking for examples that are compatible with the version you use, just browse the files by the git tag, e.g. [`tree/v0.16.0` for `0.16.0` release](https://github.com/MichalLytek/type-graphql/tree/v0.16.0/examples). +## Run an example server + +```bash +# Replace "simple-usage" with the directory name of the example you want to run +npm run example --example=simple-usage +``` + ## Basics - [Simple usage of fields, basic types and resolvers](./simple-usage) diff --git a/package.json b/package.json index b7b766bb9..35bbcbde1 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "package": "echo TODO: bash script", "docs": "npm run --prefix website start", "generate:sponsorkit": "npx sponsorkit --width=320 --dir=./img --name=github-sponsors", - "postgenerate:sponsorkit": "npx shx cp ./img/github-sponsors.svg ./website/static/img/github-sponsors.svg" + "postgenerate:sponsorkit": "npx shx cp ./img/github-sponsors.svg ./website/static/img/github-sponsors.svg", + "example": "ts-node ./examples/${npm_config_example}/index.ts" }, "peerDependencies": { "graphql": "^16.6.0",