Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support for ignore in package.json #273

Open
shellscape opened this issue Jan 8, 2021 · 5 comments
Open

Feature Request: Support for ignore in package.json #273

shellscape opened this issue Jan 8, 2021 · 5 comments

Comments

@shellscape
Copy link

I must admit I'm a bit baffled as to why --ignore accepts JSON but not from package.json, where the format is also JSON. If at all possible, please consider supporting the ignore option within package.json. It would save a whole lot of headache. 🍻

@cjoudrey
Copy link
Owner

cjoudrey commented Jan 8, 2021

Hey @shellscape, thanks for opening this issue.

This is definitely an oversight if that's the case. It might also just be missing from the README.md.

I agree that people should be able to do something like this in their package.json:

{
  "graphql-schema-linter": {
    "ignore": {
      "fields-have-descriptions": ["Obvious", "Query.obvious", "Query.something.obvious"]
    }
  }
}

If this is actually broken, I would start by looking here: https://github.com/cjoudrey/graphql-schema-linter/blob/c2876f3b93bd2a262c2af838f17cca5e21c23848/src/options.js

@cjoudrey
Copy link
Owner

cjoudrey commented Jan 8, 2021

I took a closer look and we have a test for this use case:

describe('getIgnoreList', () => {
it('pulls ignore list from the package.json file', () => {
const options = loadOptionsFromConfigDir(
temporaryConfigDirectory({
ignore: {
'fields-have-descriptions': [
'Obvious',
'Query.obvious',
'Query.something.obvious',
],
},
})
);
const configuration = new Configuration(emptySchema, options);
const ignoreList = configuration.getIgnoreList();
assert.deepEqual(ignoreList, {
'fields-have-descriptions': [
'Obvious',
'Query.obvious',
'Query.something.obvious',
],
});
});

So either the test is broken or perhaps we're just missing some documentation in the README.md about the above use case.

@shellscape
Copy link
Author

Yeah my first stop was the README. The text here: https://github.com/cjoudrey/graphql-schema-linter#configuration-file, states that ignore is not an option that it accepts. So I gave it a shot anyways, and it didn't work. Triple checked the syntax and no joy. (I was ignoring an unused type). Once added on the command line option, worked as expected. So if it is supported, something is definitely off.

@silospen
Copy link

FWIW I tried the ignore syntax in package.json and it worked fine for me.

"graphql-schema-linter": { "ignore": { "types-have-descriptions": [ ... ] } }

@defsteph
Copy link

Seems to work fine in package.json, but I couldn't get it to work with .graphql-schema-linterrc

I have this in my package.json, working quite alright with a TypeGraphQL generated schema.

{
"graphql-schema-linter": {
   "ignore": {
      "arguments-have-descriptions": ["Query._entities"],
      "fields-are-camel-cased": ["Query._entities", "Query._service"],
      "fields-have-descriptions": ["Query", "Mutation"],
      "types-are-capitalized": ["_Service"],
      "types-have-descriptions": ["Query", "Mutation", "_Any", "_Entity", "_Service"]
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants