graphql-schema-linter
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -11,2 +11,13 @@ # Changelog | ||
## 0.2.4 (January 27st, 2020) | ||
### New features | ||
- Add a third output format named `compact` that can be used in conjunction with programs like `grep`. See [README.md](https://github.com/cjoudrey/graphql-schema-linter#output-formatters) for sample output. [#209](https://github.com/cjoudrey/graphql-schema-linter/pull/209) (Thanks @MatthewRines) | ||
### Bug fixes | ||
- Allow `first` argument to be a non-nullable integer when connection only supports forward pagination. [#203](https://github.com/cjoudrey/graphql-schema-linter/pull/203) (Thanks @swac) | ||
- Allow `last` argument to be a non-nullable integer when connection only supports backward pagination. [#203](https://github.com/cjoudrey/graphql-schema-linter/pull/203) (Thanks @swac) | ||
## 0.2.3 (December 1st, 2019) | ||
@@ -16,3 +27,3 @@ | ||
- Add support for `schemaPaths` to be configured via `package.json`. See [README.md](https://github.com/cjoudrey/graphql-schema-linter/blob/5dfe1f0550ac80319b2550ddcaff7535b2ef7ee5/README.md#configuration-file) for examples. [#](https://github.com/cjoudrey/graphql-schema-linter/pull/196) (Thanks @gagoar) | ||
- Add support for `schemaPaths` to be configured via `package.json`. See [README.md](https://github.com/cjoudrey/graphql-schema-linter/blob/5dfe1f0550ac80319b2550ddcaff7535b2ef7ee5/README.md#configuration-file) for examples. [#196](https://github.com/cjoudrey/graphql-schema-linter/pull/196) (Thanks @gagoar) | ||
@@ -19,0 +30,0 @@ ## 0.2.2 (October 31st, 2019) |
@@ -32,2 +32,6 @@ 'use strict'; | ||
var _compact_formatter = require('./formatters/compact_formatter.js'); | ||
var _compact_formatter2 = _interopRequireDefault(_compact_formatter); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -130,2 +134,4 @@ | ||
return _text_formatter2.default; | ||
case 'compact': | ||
return _compact_formatter2.default; | ||
} | ||
@@ -132,0 +138,0 @@ } |
@@ -47,4 +47,13 @@ 'use strict'; | ||
if (firstArgument) { | ||
if (firstArgument.type.kind != 'NamedType' || firstArgument.type.name.value != 'Int') { | ||
return context.reportError(new _validation_error.ValidationError('relay-connection-arguments-spec', 'Fields that support forward pagination must include a `first` argument that takes a non-negative integer as per the Relay spec.', [firstArgument])); | ||
if (hasBackwardPagination) { | ||
// first and last must be nullable if both forward and backward pagination are supported. | ||
if (firstArgument.type.kind != 'NamedType' || firstArgument.type.name.value != 'Int') { | ||
return context.reportError(new _validation_error.ValidationError('relay-connection-arguments-spec', 'Fields that support forward and backward pagination must include a `first` argument that takes a nullable non-negative integer as per the Relay spec.', [firstArgument])); | ||
} | ||
} else { | ||
// first can be non-nullable if only forward pagination is supported. | ||
var type = unwrapType(firstArgument.type); | ||
if (type.kind != 'NamedType' || type.name.value != 'Int') { | ||
return context.reportError(new _validation_error.ValidationError('relay-connection-arguments-spec', 'Fields that support forward pagination must include a `first` argument that takes a non-negative integer as per the Relay spec.', [firstArgument])); | ||
} | ||
} | ||
@@ -54,4 +63,13 @@ } | ||
if (lastArgument) { | ||
if (lastArgument.type.kind != 'NamedType' || lastArgument.type.name.value != 'Int') { | ||
return context.reportError(new _validation_error.ValidationError('relay-connection-arguments-spec', 'Fields that support forward pagination must include a `last` argument that takes a non-negative integer as per the Relay spec.', [lastArgument])); | ||
if (hasForwardPagination) { | ||
// first and last must be nullable if both forward and backward pagination are supported. | ||
if (lastArgument.type.kind != 'NamedType' || lastArgument.type.name.value != 'Int') { | ||
return context.reportError(new _validation_error.ValidationError('relay-connection-arguments-spec', 'Fields that support forward and backward pagination must include a `last` argument that takes a nullable non-negative integer as per the Relay spec.', [lastArgument])); | ||
} | ||
} else { | ||
// last can be non-nullable if only backward pagination is supported. | ||
var _type = unwrapType(lastArgument.type); | ||
if (_type.kind != 'NamedType' || _type.name.value != 'Int') { | ||
return context.reportError(new _validation_error.ValidationError('relay-connection-arguments-spec', 'Fields that support backward pagination must include a `last` argument that takes a non-negative integer as per the Relay spec.', [lastArgument])); | ||
} | ||
} | ||
@@ -58,0 +76,0 @@ } |
@@ -27,3 +27,3 @@ 'use strict'; | ||
function run(stdout, stdin, stderr, argv) { | ||
var commander = new _commander.Command().usage('[options] [schema.graphql ...]').option('-r, --rules <rules>', 'only the rules specified will be used to validate the schema. Example: fields-have-descriptions,types-have-descriptions').option('-f, --format <format>', 'choose the output format of the report. Possible values: json, text').option('-s, --stdin', 'schema definition will be read from STDIN instead of specified file.').option('-c, --config-directory <path>', 'path to begin searching for config files.').option('-p, --custom-rule-paths <paths>', 'path to additional custom rules to be loaded. Example: rules/*.js').option('--comment-descriptions', 'use old way of defining descriptions in GraphQL SDL').option('--old-implements-syntax', 'use old way of defining implemented interfaces in GraphQL SDL') | ||
var commander = new _commander.Command().usage('[options] [schema.graphql ...]').option('-r, --rules <rules>', 'only the rules specified will be used to validate the schema. Example: fields-have-descriptions,types-have-descriptions').option('-f, --format <format>', 'choose the output format of the report. Possible values: json, text, compact').option('-s, --stdin', 'schema definition will be read from STDIN instead of specified file.').option('-c, --config-directory <path>', 'path to begin searching for config files.').option('-p, --custom-rule-paths <paths>', 'path to additional custom rules to be loaded. Example: rules/*.js').option('--comment-descriptions', 'use old way of defining descriptions in GraphQL SDL').option('--old-implements-syntax', 'use old way of defining implemented interfaces in GraphQL SDL') | ||
// DEPRECATED - This code should be removed in v1.0.0. | ||
@@ -30,0 +30,0 @@ .option('-o, --only <rules>', 'This option is DEPRECATED. Use `--rules` instead.') |
{ | ||
"name": "graphql-schema-linter", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Command line tool and package to validate GraphQL schemas against a set of rules.", | ||
@@ -30,3 +30,3 @@ "author": "Christian Joudrey", | ||
"mocha": "6.2.2", | ||
"prettier": "1.18.2" | ||
"prettier": "1.19.1" | ||
}, | ||
@@ -33,0 +33,0 @@ "babel": { |
@@ -41,3 +41,3 @@ # graphql-schema-linter [![Travis CI](https://travis-ci.org/cjoudrey/graphql-schema-linter.svg?branch=master)](https://travis-ci.org/cjoudrey/graphql-schema-linter) [![npm version](https://badge.fury.io/js/graphql-schema-linter.svg)](https://yarnpkg.com/en/package/graphql-schema-linter) | ||
possible values: json, text | ||
possible values: compact, json, text | ||
@@ -240,3 +240,3 @@ -s, --stdin | ||
### `relay-page-info-spec` | ||
Note: If only forward pagination is enabled, the `first` argument can be specified as non-nullable (i.e., `Int!` instead of `Int`). Similarly, if only backward pagination is enabled, the `last` argument can be specified as non-nullable. | ||
@@ -263,5 +263,5 @@ This rule will validate the schema adheres to [section 5 (PageInfo)](https://facebook.github.io/relay/graphql/connections.htm#sec-undefined.PageInfo) of the [Relay Cursor Connections Specification](https://facebook.github.io/relay/graphql/connections.htm). | ||
The following formatters are currently available: `text`, `json`. | ||
The following formatters are currently available: `text`, `compact`, `json`. | ||
### `TextFormatter` (default) | ||
### Text (default) | ||
@@ -271,6 +271,10 @@ Sample output: | ||
``` | ||
app/schema.graphql | ||
5:1 The object type `QueryRoot` is missing a description. types-have-descriptions | ||
6:3 The field `QueryRoot.a` is missing a description. fields-have-descriptions | ||
6:3 The field `QueryRoot.songs` is missing a description. fields-have-descriptions | ||
2 errors detected | ||
app/songs.graphql | ||
1:1 The object type `Song` is missing a description. types-have-descriptions | ||
3 errors detected | ||
``` | ||
@@ -280,6 +284,18 @@ | ||
### `JSONFormatter` | ||
### Compact | ||
Sample output: | ||
``` | ||
app/schema.graphql:5:1 The object type `QueryRoot` is missing a description. (types-have-descriptions) | ||
app/schema.graphql:6:3 The field `QueryRoot.a` is missing a description. (fields-have-descriptions) | ||
app/songs.graphql:1:1 The object type `Song` is missing a description. (types-have-descriptions) | ||
``` | ||
Each error is prefixed with the path, the line number and column the error occurred on. | ||
### JSON | ||
Sample output: | ||
```json | ||
@@ -286,0 +302,0 @@ { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
348153
35
1111
351