Skip to content

Commit c864e78

Browse files
committed
initial
0 parents  commit c864e78

File tree

9 files changed

+1628
-0
lines changed

9 files changed

+1628
-0
lines changed

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
33+
# Optional npm cache directory
34+
.npm
35+
36+
# Optional REPL history
37+
.node_repl_history
38+
39+
# graphql files on the root dir
40+
/*.graphql
41+
/*.graphqlconfig
42+
43+
# es5 output dir
44+
/dist/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Graphcool
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# graphql-cli-voyager
2+
3+
GraphQL Voyager plugin for [`graphql-cli`](https://github.com/graphcool/graphql-cli)
4+
5+
## Installation
6+
Just run the following command:
7+
8+
$ npm install -g graphql-cli-voyager
9+
10+
## Usage
11+
As simple as:
12+
13+
$ graphql voyager
14+
15+
## Help & Community [![Slack Status](https://slack.graph.cool/badge.svg)](https://slack.graph.cool)
16+
17+
Join our [Slack community](http://slack.graph.cool/) if you run into issues or have questions. We love talking to you!
18+
19+
![](http://i.imgur.com/5RHR6Ku.png)

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "graphql-cli-voyager",
3+
"version": "0.0.1",
4+
"description": "GraphQL CLI Voyager plugin",
5+
"files": [
6+
"LICENSE",
7+
"README.md",
8+
"dist/"
9+
],
10+
"main": "dist/index.js",
11+
"scripts": {
12+
"prepublish": "npm run build",
13+
"build": "tsc",
14+
"test": "npm run lint && tsc && ava tests/**/test.js --serial",
15+
"lint": "tslint {src,test}/**/*.ts",
16+
"start": "ts-node src/bin.ts"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/graphcool/graphql-cli-voyager.git"
21+
},
22+
"license": "MIT",
23+
"bugs": {
24+
"url": "https://github.com/graphcool/graphql-cli-voyager/issues"
25+
},
26+
"homepage": "https://github.com/graphcool/graphql-cli-voyager#readme",
27+
"devDependencies": {
28+
"@types/graphql": "^0.10.0",
29+
"@types/node": "^8.0.17",
30+
"tslint": "^5.5.0",
31+
"tslint-config-standard": "^6.0.1",
32+
"typescript": "^2.2.0"
33+
},
34+
"dependencies": {
35+
"express": "^4.15.3",
36+
"express-graphql": "^0.6.6",
37+
"graphql-cli": "^1.0.0-beta.1",
38+
"graphql-voyager": "^1.0.0-rc.7",
39+
"opn": "^5.1.0"
40+
}
41+
}

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = [
2+
require('./voyager'),
3+
]

src/voyager.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
exports.command = 'voyager'
2+
exports.desc = 'Open GraphQL voyager in your browser'
3+
4+
import * as express from 'express'
5+
import { express as middleware } from 'graphql-voyager/middleware'
6+
import * as graphqlHTTP from 'express-graphql'
7+
import * as opn from 'opn';
8+
9+
exports.handler = function (context) {
10+
const schema = context.getProjectConfig().getSchema()
11+
12+
const app = express()
13+
14+
app.use('/graphql', graphqlHTTP({
15+
schema: schema
16+
}));
17+
18+
app.use('/voyager', middleware({ endpointUrl: '/graphql' }))
19+
20+
app.listen(7000);
21+
const listener = app.listen(() => {
22+
let host = listener.address().address
23+
if (host === '::') {
24+
host = 'localhost'
25+
}
26+
const port = listener.address().port
27+
const link = `http://${host}:${port}/voyager`
28+
console.log('Serving voyager at %s', link)
29+
opn(link)
30+
});
31+
}

tsconfig.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"preserveConstEnums": true,
4+
"strictNullChecks": true,
5+
"sourceMap": true,
6+
"target": "es5",
7+
"outDir": "dist",
8+
"moduleResolution": "node",
9+
"lib": [
10+
"es2017",
11+
"esnext.asynciterable",
12+
"dom"
13+
],
14+
"types": ["node"]
15+
},
16+
"exclude": [
17+
"node_modules",
18+
"dist"
19+
],
20+
"include": [
21+
"./src/**/*.ts",
22+
"./tests/**/*.ts"
23+
]
24+
}

tslint.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": ["tslint-config-standard"],
3+
"rules": {
4+
"trailing-comma": [
5+
true,
6+
{
7+
"multiline": "always",
8+
"singleline": "never"
9+
}
10+
]
11+
}
12+
}

0 commit comments

Comments
 (0)