graphql-schema-linter icon indicating copy to clipboard operation
graphql-schema-linter copied to clipboard

Cannot disable relay-page-info-spec

Open shellscape opened this issue 5 years ago • 7 comments

Please consider the schema below. The comment at the top follows the docs for disabling a rule. When running the linter against that schema, the error A ``PageInfo`` object type is required as per the Relay spec. is thrown even though the linter is being instructed to ignore it.

# lint-disable relay-page-info-spec

##
# GraphQL Service
#   Name: batman-service
#   Intent: This service summons batman to fight villans
#
##

""" A hero character. These are the good guys """
type Hero {
  enemies: [Villain]
  friends: [Hero]
  id: ID!
  name: String!
}

""" A villain character. These are the bad guys """
type Villain {
  enemies: [Hero]
  friends: [Villain]
  id: ID!
  name: String!
}

""" Query Root """
type Query {
  """ Summons batman """
  summon: Hero
}

shellscape avatar Dec 18 '20 01:12 shellscape

Hey @shellscape! Thanks for opening this issue.

That's odd. 🤔

It might have to do with how the PageInfo rule reports its error and that error's location possibly being less than 1. 🤔

Definitely something weird going on.

In the meantime, you could use --except or --rules if this is a blocker for you.

cjoudrey avatar Dec 18 '20 02:12 cjoudrey

Thanks for replying so quickly. I'm going the route of explicitly defining all rules (sans that one) in package.json. Added bonus of being declarative for folks wondering what it's validating, but I wanted to make the project aware of the issue.

shellscape avatar Dec 18 '20 02:12 shellscape

Awesome! ☺️

but I wanted to make the project aware of the issue.

Thanks I really appreciate the help. ☺️🎉

cjoudrey avatar Dec 18 '20 02:12 cjoudrey

graphql-schema-linter --except relay-page-info-spec worked for me, thanks!

jacquayj avatar Jun 08 '22 16:06 jacquayj

Found that # lint-disable-line relay-page-info-spec can disable the rule.

% npx graphql-schema-linter --version
3.0.1

-> % npx graphql-schema-linter issue-269.graphql --rules relay-page-info-spec
/Users/uasi/tmp/graphql-schema-linter/issue-269.graphql
1:1 A `PageInfo` object type is required as per the Relay spec.  relay-page-info-spec

✖ 1 error detected

-> % sed -i.bak '1s/lint-disable/lint-disable-line/' issue-269.graphql

-> % npx graphql-schema-linter issue-269.graphql --rules relay-page-info-spec


✔ 0 errors detected

uasi avatar Aug 30 '22 09:08 uasi

I believe the problem is because lint-disable does not affect the line it is written on, so the error at 1:1 is not silenced by it.

https://github.com/cjoudrey/graphql-schema-linter/blob/fb0dd421138a5385de9be783393fd5f684219400/src/validator.js#L141

uasi avatar Aug 30 '22 09:08 uasi

Small bump on the above issue since the given workaround will not work much longer: ‼ The --only and --except command line options have been deprecated. They will be removed in v1.0.0.

sjoerdk-ahold avatar Nov 28 '22 14:11 sjoerdk-ahold