Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
graphql-schema-linter
Advanced tools
Command line tool and package to validate GraphQL schemas against a set of rules.
This package provides a command line tool to validate GraphQL schema definitions against a set of rules.
If you're looking to lint your GraphQL queries, check out this ESLint plugin: apollographql/eslint-plugin-graphql.
Yarn:
yarn global add graphql-schema-linter
npm:
npm install -g graphql-schema-linter
Usage: graphql-schema-linter [options] [schema.graphql ...]
Options:
-r, --rules <rules>
only the rules specified will be used to validate the schema
example: --rules fields-have-descriptions,types-have-descriptions
-f, --format <format>
choose the output format of the report
possible values: json, text
-s, --stdin
schema definition will be read from STDIN instead of specified file
--version
output the version number
-h, --help
output usage information
In addition to being able to specify rules on the command line, config can also be placed in the following locations:
package.json
{
"graphql-schema-linter": {
"rules": ["enum-values-sorted-alphabetically"]
}
}
.graphql-schema-linterrc
{
"rules": ["enum-values-sorted-alphabetically"]
}
graphql-schema-linter.config.js
module.exports = {
rules: ['enum-values-sorted-alphabetically'],
};
defined-types-are-used
This rule will validate that all defined types are used at least once in the schema.
deprecations-have-a-reason
This rule will validate that all deprecations have a reason.
enum-values-all-caps
This rule will validate that all enum values are capitalized.
enum-values-sorted-alphabetically
This rule will validate that all enum values are sorted alphabetically.
fields-have-descriptions
This rule will validate that all fields have a description.
types-are-capitalized
This rule will validate that interface types and object types have capitalized names.
types-have-descriptions
This will will validate that interface types and object types have descriptions.
The format of the output can be controlled via the --format
option.
The following formatters are currently available: text
, json
.
TextFormatter
(default)Sample output:
5:1 The object type `QueryRoot` is missing a description.
6:3 The field `QueryRoot.a` is missing a description.
2 errors detected
Each error is prefixed with the line number and column the error occurred on.
JSONFormatter
Sample output:
{
"errors": [
{
"message": "The object type `QueryRoot` is missing a description.",
"location": {
"line": 5,
"column": 1,
"file": "schema.graphql"
}
},
{
"message": "The field `QueryRoot.a` is missing a description.",
"location": {
"line": 6,
"column": 3,
"file": "schema.graphql"
}
}
]
}
Verifying the exit code of the graphql-schema-lint
process is a good way of programmatically knowing the
result of the validation.
If the process exits with 0
it means all rules passed.
If the process exits with 1
it means one or many rules failed. Information about these failures can be obtained by
reading the stdout
and using the appropriate output formatter.
If the process exits with 2
it means an uncaught error happen. This most likely means you found a bug.
FAQs
Command line tool and package to validate GraphQL schemas against a set of rules.
The npm package graphql-schema-linter receives a total of 47,213 weekly downloads. As such, graphql-schema-linter popularity was classified as popular.
We found that graphql-schema-linter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.