Skip to content

Commit 3cc5eea

Browse files
committed
bin, small fixes, new version
1 parent 8775b5c commit 3cc5eea

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

bin/config-yargs.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

bin/swagger2graphql.js

100644100755
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
#!/usr/bin/env node
2-
var argv = require('yargs')
3-
.usage('Usage: $0 -i [path] -o [path]')
4-
.demandOption(['i','o'])
5-
.argv;
2+
var argv = require('yargs').argv;
3+
var build = require('../lib');
4+
var graphql = require('graphql');
5+
6+
if (argv.help) {
7+
console.log('\nUsage: swagger2graphql --swagger=/path/to/schema.json');
8+
}
9+
10+
if (!argv.swagger) {
11+
console.log('\nPlease provide path to swagger schema. \n--help for usage example');
12+
}
13+
14+
build(argv.swagger).then(schema => {
15+
console.log(graphql.printSchema(schema));
16+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-to-graphql",
3-
"version": "1.0.6",
3+
"version": "1.1.0",
44
"author": "Roman Krivtsov",
55
"bin": "./bin/swagger2graphql",
66
"dependencies": {

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const resolver = (endpoint) =>
4545
const req = endpoint.request(args, {
4646
baseUrl: opts.GQLProxyBaseUrl
4747
});
48+
if (opts.BearerToken) {
49+
req.headers.Authorization = opts.BearerToken;
50+
}
4851
const res = await rp(req);
4952
return JSON.parse(res);
5053
};
@@ -69,7 +72,7 @@ const build = async (swaggerPath) => {
6972
const swaggerSchema = await loadSchema(swaggerPath);
7073
const endpoints = getAllEndPoints(swaggerSchema);
7174
const schema = schemaFromEndpoints(endpoints);
72-
console.log(printSchema(schema));
75+
return schema;
7376
};
7477

7578
export default build;

0 commit comments

Comments
 (0)