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

feat: add a check for deprecation errors #93

Merged
merged 4 commits into from
Nov 29, 2017

Conversation

koddsson
Copy link
Contributor

@koddsson koddsson commented Nov 9, 2017

Hey there! 👋

#14 describes the need for warnings on deprecated fields which is something I'd like as well so I fiddled around a bit and came up with this that seems to be working in my tests at least. Not sure if I need to make tests for appollo & graphql separately or handle any logic there separately. Also not sure if this should live somewhere else then where I put it. If there should be a rule to opt into or what so I'd appreciate any help on getting this PR up to standard 😄

TODO:

  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests pass
  • Update CHANGELOG.md with your change
  • If this was a change that affects the external API, update the README

@apollo-cla
Copy link

@koddsson: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@koddsson
Copy link
Contributor Author

koddsson commented Nov 9, 2017

Those 4 tests were failing when I checked out the project FWIW

@jnwng jnwng self-assigned this Nov 9, 2017
@jnwng jnwng self-requested a review November 9, 2017 15:55
@jnwng
Copy link
Contributor

jnwng commented Nov 9, 2017

@koddsson thanks for the PR! overall, things look good, and this is one of our oldest outstanding issues.

a couple of things that would be useful to add to this — like other rules in eslint, it would be nice to be able to configure how important these errors ultimately are. take a look at the required-fields and some other custom rules we have in place. this will allow us to ship this sooner rather than later without throwing errors on people's setups.

i think the test case you've provided is sufficient to test the functionality provided here.

when you have a chance, make sure to sign the CLA and fulfill the tasks laid out in the PR checklist. as for CI, im hoping its a transient error, but its an infrastructural problem, not a code problem. we'll get it sorted out as this PR progresses.

@jnwng jnwng added the feature New addition or enhancement to existing solutions label Nov 9, 2017
Copy link
Contributor

@jnwng jnwng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a rule to toggle the severity of these errors?

@jnwng
Copy link
Contributor

jnwng commented Nov 9, 2017

@koddsson if you could rebase, #91 should have resolved some issues with the graphql-js dependency

@koddsson koddsson force-pushed the error-on-deprecated-fields branch from 1c7901c to ba24262 Compare November 9, 2017 16:47
@koddsson
Copy link
Contributor Author

koddsson commented Nov 9, 2017

@jnwng Can you help me with how I put a guard in place to only report if the rule is enabled? I've been digging around and I'm not sure how I'd do that.

edit: nevermind, I think I got it figured out.

@@ -427,6 +427,7 @@ const parserOptions = {
greetings: () => Relay.QL\`
fragment on Greetings {
hello,
hi,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this here to validate that the rule is not reporting when it's not enabled.

@koddsson
Copy link
Contributor Author

koddsson commented Nov 10, 2017

I basically took the code from graphql/graphql-js@063148d instead of importing the function findDeprecatedUsages and calling that.

@koddsson
Copy link
Contributor Author

@jnwng Could you take another peek at this if you have a spare moment 🙇

Copy link
Contributor

@jnwng jnwng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woohoo! looks great. thank you for adding test cases and documentation :)

@jnwng jnwng merged commit a04d457 into apollographql:master Nov 29, 2017
@jnwng
Copy link
Contributor

jnwng commented Nov 29, 2017

@koddsson thank you so much for your hard work and patience. i'm just double checking with @stubailo about the code we're taking from graphql-js and once that's all resolved, i'll publish to npm

@jnwng
Copy link
Contributor

jnwng commented Nov 29, 2017

@koddsson in retrospect, it feels a little simpler to import the findDeprecatedUsages helper from graphql-js itself. do you mind clarifying why you wanted to pull the code from there instead of using that helper?

@koddsson
Copy link
Contributor Author

koddsson commented Dec 6, 2017

Hey @jnwng! Sorry I've been out for a bit.

do you mind clarifying why you wanted to pull the code from there instead of using that helper?

If memory serves me right, it's because findDeprecatedUsages takes in the whole AST and iterates through it and gives you back the errors, if any. Since we are already iterating and don't have access to the whole AST we can't use that function here and needed to copy paste from the original.

@nodkz
Copy link
Contributor

nodkz commented Jan 8, 2018

@jnwng @stubailo any progress with publishing this merged changes to npm?

@jnwng
Copy link
Contributor

jnwng commented Jan 8, 2018 via email

@koddsson koddsson deleted the error-on-deprecated-fields branch January 8, 2018 19:05
@koddsson
Copy link
Contributor Author

Hey @jnwng! Is there something I can help with to get this published? I'm not sure what "Just one quick change to make sure we’re pointing to source" is or if that's something I can help with but feel free to ping me if I can help in any way <3

@jnwng
Copy link
Contributor

jnwng commented Jan 15, 2018

@koddsson i wanted to add attribution for the code that was moved here from graphql-js, as well as address #100 (the code here doesn't take into account enum values). the problem with #100 right now is that its failing in older versions of node, so i'm just trying to root down the problem there before releasing this. once #100 is resolved we can publish.

@koddsson
Copy link
Contributor Author

Thanks for the update @jnwng!

@jnwng
Copy link
Contributor

jnwng commented Jan 16, 2018

@koddsson okay, took me a bit to figure out what was going on, but this should be working and released as of [email protected]. let me know if you have any problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants