happylinks / gqlint

GraphQL (Schema) Linter
MIT License
41 stars 4 forks source link

Improve reading of config file #1

Closed voxpelli closed 7 years ago

voxpelli commented 7 years ago

As part of refactoring a GraphQL server I wanted to focus on getting the GraphQL Schema into the best shape possible and what better tool to help in that, and to ensure that it sticks that way, than a linter? So I was very happy to find that someone had started on making a linter for GraphQL Schemas, very handy!

I did however run across an error with the CLI command and tracked it down to an erroneous expectation of the return data from fs.readFileSync(). When an encoding has been specified, as it has in this case, then it returns a string: https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options

Due to this wrong expectation the defined config file wasn't used but instead a JSON parse error was given whenever a config file was defined.

As an additional fix I reworded the error message to actually note the reason to why it will run with the default config + removed a needless assign to a json const. I hope that's okay and not stretching it too far for a single PR.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 86.667% when pulling b425ac05faa0aa55ca99159a4749ec447e2b3ac9 on voxpelli:patch-1 into 33c82638eb6f54107ea6cf31dbdb242ca3419735 on happylinks:master.

happylinks commented 7 years ago

Sorry this took so long! I didn't see the PR. Thanks for the changes! Are you still using the linter? Curious to hear your thoughts about it :)

voxpelli commented 7 years ago

Thanks for merging @happylinks!

I'm still using it. I've made it part of the tests for our internal GraphQL server at @Sydsvenskan and I'm happy so far 👍