cjoudrey / graphql-schema-linter

Validate GraphQL schema definitions against a set of rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to configure a subset of rules

qrsor opened this issue · comments

commented

Node version: 12.16.3
Command executed: npx graphql-schema-linter aws_appsync.graphql schema.graphql
Configuration file: graphql-schema-linter.config.js

module.exports = {
rules: ["defined_types_are_used"],
};

Expected: schema is validated using a single rule
Actual: A message is being displayed:

Warning on rules: The following rule(s) are invalid: Defined_types_are_used

I was able to get it working by replacing the rule name with "DefinedTypesAreUsed".

Hello @qrsor, I'm glad you managed to get it to work.

The rules are named with hyphens (-) as per: https://github.com/cjoudrey/graphql-schema-linter#built-in-rules

Here's an example: https://github.com/cjoudrey/graphql-schema-linter#in-packagejson

In your case, this should work:

module.exports = {
  rules: ["defined-types-are-used"],
};

In case you're curious, the reason "DefinedTypesAreUsed" also works is because internally they are named with camel-cases. The hyphen names get converted to camel case here:

function toUpperCamelCase(string) {
return string
.split('-')
.map(part => part[0].toUpperCase() + part.slice(1))
.join('');
}
.

Feel free to re-open this if you have other issues.