cjoudrey / graphql-schema-linter

Validate GraphQL schema definitions against a set of rules
MIT License
694 stars 62 forks source link

Unable to configure a subset of rules #236

Closed qrsor closed 4 years ago

qrsor commented 4 years ago

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".

cjoudrey commented 4 years ago

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: https://github.com/cjoudrey/graphql-schema-linter/blob/e21bcefe9d6cd68cdb9e12fe77433f3060bb9f8d/src/configuration.js#L170-L175.

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