diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..057cdbbd --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: npm start --prefix example diff --git a/app.json b/app.json new file mode 100644 index 00000000..f79ffaa2 --- /dev/null +++ b/app.json @@ -0,0 +1,10 @@ +{ + "name": "graphql-voyager-example", + "description": "GraphQL introspection viewer example", + "website": "https://github.com/APIs-guru/graphql-voyager.git", + "buildpacks": [ + { + "url": "heroku/nodejs" + } + ] +} diff --git a/example/README.md b/example/README.md index 04db2412..b72a137e 100644 --- a/example/README.md +++ b/example/README.md @@ -2,7 +2,7 @@ Example GraphQL-Voyager Install ======================== ------ -**Attribution:** the contents of this folder was copied from [GraphiQL](https://github.com/graphql/graphiql/tree/master/example) example and modified for GraphQL-Voyager example. See copyright below: +**Attribution:** The contents of this folder were copied from [GraphiQL](https://github.com/graphql/graphiql/tree/master/example) example and modified for GraphQL-Voyager example. See copyright below: > Copyright (c) Facebook, Inc. All rights reserved. [LICENSE](https://github.com/graphql/graphiql/blob/master/LICENSE) @@ -13,8 +13,14 @@ than depending on npm, so that it is easier to test new changes. In order to use the compiled version of GraphQL-Voyager, first run in the parent directory before installing and starting the example. +## Running Locally + 1. Run `npm install && npm run build:release` in the parent directory 2. Navigate to this directory (example) in Terminal 3. `npm install` 4. `npm start` 5. Open your browser to the address listed in your console. e.g. `Started on http://localhost:49811/` + +## Running on Cloud + +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/bdcorps/graphql-voyager/tree/9-deploy-to-heroku) diff --git a/example/server.js b/example/server.js index 9fe2732d..53343b43 100644 --- a/example/server.js +++ b/example/server.js @@ -3,11 +3,13 @@ const graphqlHTTP = require('express-graphql'); const schema = require('./schema'); +var port = process.env.PORT || process.env.VCAP_APP_PORT || 3005; + const app = express(); app.use(express.static(__dirname)); app.use('/graphql', graphqlHTTP(() => ({ schema }))); -app.listen(0, function() { - const port = this.address().port; + +app.listen(port, function() { console.log(`Started on http://localhost:${port}/`); }); diff --git a/package.json b/package.json index 5d4cffc2..f8fc5434 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "deploy": "deploy-to-gh-pages --local --update demo-dist", "stats": "NODE_ENV=production webpack --json --mode=production --config build/webpack.js > stats.json", "prettier": "prettier --write \"{,!(node_modules)/**/}*.{ts,tsx}\"", - "declarations": "tsc --emitDeclarationOnly -p tsconfig.lib.json" + "declarations": "tsc --emitDeclarationOnly -p tsconfig.lib.json", + "postinstall": "cd example && npm install" }, "license": "MIT", "devDependencies": {