File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " graphql-cli-voyager" ,
3
- "version" : " 0.0.1 " ,
3
+ "version" : " 0.1.0 " ,
4
4
"description" : " GraphQL CLI Voyager plugin" ,
5
5
"files" : [
6
6
" LICENSE" ,
Original file line number Diff line number Diff line change 1
- exports . command = 'voyager'
1
+ exports . command = 'voyager [--port] '
2
2
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
+ }
3
9
4
10
import * as express from 'express'
5
11
import { express as middleware } from 'graphql-voyager/middleware'
6
12
import * as graphqlHTTP from 'express-graphql'
7
- import * as opn from 'opn' ;
13
+ import * as opn from 'opn'
14
+ import { buildSchema } from 'graphql'
8
15
9
- exports . handler = function ( context ) {
10
- const schema = context . getProjectConfig ( ) . getSchema ( )
16
+ exports . handler = function ( context , argv ) {
17
+ const schema = buildSchema ( context . getProjectConfig ( ) . getSchemaSDL ( ) ) ;
11
18
12
19
const app = express ( )
13
20
@@ -17,13 +24,13 @@ exports.handler = function (context) {
17
24
18
25
app . use ( '/voyager' , middleware ( { endpointUrl : '/graphql' } ) )
19
26
20
- app . listen ( 7000 ) ;
27
+ const port = parseInt ( argv . port ) || 7000 ;
28
+ app . listen ( port ) ;
21
29
const listener = app . listen ( ( ) => {
22
30
let host = listener . address ( ) . address
23
31
if ( host === '::' ) {
24
32
host = 'localhost'
25
33
}
26
- const port = listener . address ( ) . port
27
34
const link = `http://${ host } :${ port } /voyager`
28
35
console . log ( 'Serving voyager at %s' , link )
29
36
opn ( link )
You can’t perform that action at this time.
0 commit comments