Skip to content

Commit 9a1e36a

Browse files
committed
v0.1.0
1 parent c864e78 commit 9a1e36a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-cli-voyager",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "GraphQL CLI Voyager plugin",
55
"files": [
66
"LICENSE",

src/voyager.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
exports.command = 'voyager'
1+
exports.command = 'voyager [--port]'
22
exports.desc = 'Open GraphQL voyager in your browser'
3+
exports.builder = {
4+
port: {
5+
alias: 'p',
6+
description: 'port to start local server with voyager on',
7+
}
8+
}
39

410
import * as express from 'express'
511
import { express as middleware } from 'graphql-voyager/middleware'
612
import * as graphqlHTTP from 'express-graphql'
7-
import * as opn from 'opn';
13+
import * as opn from 'opn'
14+
import { buildSchema } from 'graphql'
815

9-
exports.handler = function (context) {
10-
const schema = context.getProjectConfig().getSchema()
16+
exports.handler = function (context, argv) {
17+
const schema = buildSchema(context.getProjectConfig().getSchemaSDL());
1118

1219
const app = express()
1320

@@ -17,13 +24,13 @@ exports.handler = function (context) {
1724

1825
app.use('/voyager', middleware({ endpointUrl: '/graphql' }))
1926

20-
app.listen(7000);
27+
const port = parseInt(argv.port) || 7000;
28+
app.listen(port);
2129
const listener = app.listen(() => {
2230
let host = listener.address().address
2331
if (host === '::') {
2432
host = 'localhost'
2533
}
26-
const port = listener.address().port
2734
const link = `http://${host}:${port}/voyager`
2835
console.log('Serving voyager at %s', link)
2936
opn(link)

0 commit comments

Comments
 (0)