graphql-schema-linter
graphql-schema-linter copied to clipboard
Add --fix option
In some error cases, the linter can programmatically know what the schema should have been.
It would be awesome to provide a --fix
option that would automatically resolve these errors.
Some example rules that could be fixed by the linter this way:
-
EnumValuesAllCaps
-
EnumValuesSortedAlphabetically
-
FieldsAreCamelCased
-
InputObjectValuesAreCamelCased
-
TypesAreCapitalized
@cjoudrey I'd like to check this out, I might not be able to get to it for a few days as I'm at graphql summit but I'll start messing around with it. Cool idea by the way π.
That would be awesome @bbohen. π
Whenever you do poke at it, let me know if you need help or want to discuss solutions.
Absolutely! I think it would be really nice to be able to use this with ESLint per #21.
@cjoudrey @bbohen - Is this still being worked on? If not, I may take a stab at it
Iβm not working on it atm. If @bbohen isnβt, Iβd say go for it. π
@cjoudrey - I'll wait to see what @bbohen says
@iamclaytonray Go for it! I was all excited to work on this and then work got really busy π¬ .
Thanks @bbohen!
No promises but I'll try to get a rough copy up and then we can iterate π
Sorry for being so late on this. Totally dropped the ball. Umm... @cjoudrey - Can we add a task list to the original issue that includes which rules should be fixable?
I'll be working on this for at least today and hopefully more. I've never written a lint fixer so I'm in new waters. May take a bit but I'll do my best π
@iamclaytonray I've never written something like this before either. π I would have looked into ESLint and Rubocop.
Conceptually, I was thinking each rule would be able to optionally provide a function that the linter would use to fix the issue. I think we'll want to make these changes by manipulating the AST at some point.
One challenge is that the AST we use during validation is the concatenation of all .graphql
files. We may want to have a second step after validation called fix
which would take the reported errors, parse the individual files causing the mistake, and have the rule fix that AST.
Can we add a task list to the original issue that includes which rules should be fixable?
:+1: Done
That makes sense to me! Thanks for the kind words π
I've been looking into TSLint and ESLint. Didn't think of Rubocop. I'll have to check that one out. Thanks!
Disregard:
(So that I can check these off)
- [ ] EnumValuesAllCaps
- [ ] EnumValuesSortedAlphabetically
- [ ] FieldsAreCamelCased
- [ ] InputObjectValuesAreCamelCased
- [ ] TypesAreCapitalized
@cjoudrey - I'd like to integrate this fix feature (when it's done) with graphql-cli
as well. Do you have any thoughts on that? I'm sure Johannes would love to chime in too
I'd like to integrate this fix feature (when it's done) with graphql-cli as well.
@iamclaytonray yeah, that makes sense. You might be interested by this open issue: https://github.com/graphql-cli/graphql-cli/issues/14
At the moment graphql lint
does schema linting, but I recall Johannes mentioning he wanted to have graphql lint schema
. graphql lint
would be for queries.
You might want to have that discussion with him in that issue to confirm that's still what he had in mind.
Sounds good!
@iamclaytonray have you managed to make any progress on this by any chance? ππ
@cjoudrey - Sorry, no :/
I had a family emergency that's had me busy for the past week.
I actually just started picking this up again this morning.
@iamclaytonray No need to be sorry! I was just curious. π Hope all is well.
Hey @cjoudrey. I am still hacking away at this, a little bit at a time. I just got super slammed with work so I've been doing what I can in my off time. If anyone else in the community wants to help me out, I would definitely appreciate it π
@cjoudrey Hello, do you still want this feature? I think it might be helpful for us too :P
@cjoudrey Hello, do you still want this feature? I think it might be helpful for us too :P
Hi @jlwt90! πI still think this would be helpful. I'm not actively working on it though. PRs are welcome.
can we please merge this, it will be super helpful
@cjoudrey +1 can we please merge this? It seems like this project has been abandoned for a while. If the owner of the project is not working on it anymore can the ownership be at least shared with others who are working on the project so that a great PR like this can be merged and released?