New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-fetch-schema

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-fetch-schema - npm Package Compare versions

Comparing version 0.7.2 to 0.8.0

yarn-error.log

9

CHANGELOG.md

@@ -0,1 +1,6 @@

## v0.8.0 (2018-02-15)
* Update GraphQL to v0.13.1
* Remove `sort` option as the schema is sorted by default
## v0.7.2 (2017-12-06)

@@ -13,6 +18,2 @@

## v0.7.0 (2017-08-29)
Update GraphQL to v0.11.2
## v0.6.1 (2017-06-29)

@@ -19,0 +20,0 @@

@@ -64,3 +64,3 @@ 'use strict';

_commander2.default.version(_package2.default.version).usage('<url> [options]').option('-g, --graphql', 'write schema.graphql file').option('-c, --cookie <cookie>', 'pass additional Cookie header').option('-j, --json', 'write schema.json file').option('-o, --output <directory>', 'write to specified directory').option('-s, --sort', 'sort field keys').parse(process.argv);
_commander2.default.version(_package2.default.version).usage('<url> [options]').option('-g, --graphql', 'write schema.graphql file').option('-c, --cookie <cookie>', 'pass additional Cookie header').option('-j, --json', 'write schema.json file').option('-o, --output <directory>', 'write to specified directory').parse(process.argv);

@@ -71,4 +71,3 @@ run(_commander2.default.args[0], {

outputPath: _commander2.default.output,
cookie: _commander2.default.cookie,
sort: !!_commander2.default.sort
cookie: _commander2.default.cookie
});

@@ -23,4 +23,2 @@ 'use strict';

var _utilities = require('graphql/utilities');
var _fs = require('fs');

@@ -30,2 +28,4 @@

var _graphql = require('graphql');
var _nodeFetch = require('node-fetch');

@@ -52,62 +52,6 @@

var sortType = function sortType(type) {
if (type['kind'] === 'OBJECT') {
return sortObject(type);
} else if (type['kind'] === 'INTERFACE') {
return sortInterface(type);
} else if (type['kind'] === 'ENUM') {
return sortEnum(type);
} else if (type['kind'] === 'INPUT_OBJECT') {
return sortInputObject(type);
} else if (type['kind'] === 'UNION') {
return type;
} else if (type.kind === 'SCALAR') {
return type;
}
throw new Error('Unknown kind');
};
var sortObject = function sortObject(type) {
type.interfaces = type.interfaces.sort(function (int1, int2) {
return int1.name.localeCompare(int2.name);
});
type.fields = type.fields.sort(function (field1, field2) {
return field1.name.localeCompare(field2.name);
}).map(sortArgs);
return type;
};
var sortInterface = function sortInterface(type) {
type.fields = type.fields.sort(function (field1, field2) {
return field1.name.localeCompare(field2.name);
});
return type;
};
var sortEnum = function sortEnum(type) {
type.enumValues = type.enumValues.sort(function (value1, value2) {
return value1.name.localeCompare(value2.name);
});
return type;
};
var sortInputObject = function sortInputObject(type) {
type.inputFields = type.inputFields.sort(function (field1, field2) {
return field1.name.localeCompare(field2.name);
});
return type;
};
var sortArgs = function sortArgs(field) {
field.args = field.args.sort(function (arg1, arg2) {
return arg1.name.localeCompare(arg2.name);
});
return field;
};
exports.default = function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(url) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var pathPrefix, headers, res, schema, types, files;
var pathPrefix, headers, res, schema, files;
return _regenerator2.default.wrap(function _callee$(_context) {

@@ -137,3 +81,3 @@ while (1) {

body: (0, _stringify2.default)({
query: _utilities.introspectionQuery
query: (0, _graphql.getIntrospectionQuery)()
})

@@ -149,9 +93,2 @@ });

schema = _context.sent;
if (options.sort) {
types = schema.data.__schema.types.map(sortType);
schema.data.__schema.types = types;
}
files = [];

@@ -162,3 +99,3 @@

filePath: _path2.default.resolve(pathPrefix, 'schema.graphql'),
contents: (0, _utilities.printSchema)((0, _utilities.buildClientSchema)(schema.data))
contents: (0, _graphql.printSchema)((0, _graphql.buildClientSchema)(schema.data))
});

@@ -173,9 +110,9 @@ }

_context.next = 16;
_context.next = 15;
return _promise2.default.all(files.map(writeFile));
case 16:
case 15:
return _context.abrupt('return', files);
case 17:
case 16:
case 'end':

@@ -182,0 +119,0 @@ return _context.stop();

{
"name": "graphql-fetch-schema",
"version": "0.7.2",
"version": "0.8.0",
"description": "Fetch a GraphQL schema from a server and write it to file",

@@ -26,5 +26,5 @@ "repository": {

"babel-runtime": "^6.26.0",
"commander": "^2.12.2",
"graphql": "^0.11.7",
"node-fetch": "^1.7.3"
"commander": "^2.14.1",
"graphql": "^0.13.1",
"node-fetch": "^2.0.0"
},

@@ -37,5 +37,5 @@ "devDependencies": {

"babel-preset-env": "^1.6.1",
"flow-bin": "^0.60.1",
"prettier": "^1.9.1"
"flow-bin": "^0.65.0",
"prettier": "^1.10.2"
}
}

@@ -26,3 +26,2 @@ # graphql-fetch-schema

-o, --output <directory> write to specified directory
-s, --sort sort field keys
```

@@ -40,9 +39,10 @@

cookie: 'cookiename=foo;',
})
.then(() => {
console.log('Schema successfully written')
})
.catch((err) => {
console.error(err)
})
}).then(
() => {
console.log('Schema successfully written')
},
err => {
console.error(err)
},
)
```

@@ -49,0 +49,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc