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

language-server: Don't break on bad arguments #1523

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kastermester
Copy link

@kastermester kastermester commented Sep 11, 2019

When dealing with directives without arguments specified,
such as when using Relay - the argument from typeinfo can be
null/undefined.

This change simply avoids throwing errors when hovering these
arguments - and instead provides no help on hover.

I couldn't find any tests for the language server regarding these
parts, but I tried my best testing it in a local project.

TODO:

  • Update CHANGELOG.md* with your change (include reference to issue & this PR)
  • 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 and linter rules pass

When dealing with directives without arguments specified,
such as when using Relay - the argument from typeinfo can be
null/undefined.

This change simply avoids throwing errors when hovering these
arguments - and instead provides no help on hover.

I couldn't find any tests for the language server regarding these
parts, but I tried my best testing it in a local project.
@apollo-cla
Copy link

@kastermester: 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/

@kastermester
Copy link
Author

I'm not quite sure why the tests are breaking - as far as I can see my PR did not change anything related to these failures.

@JakeDawkins
Copy link
Contributor

Hey @kastermester! Thanks for the PR :) Can you drop me a link to a repo where I can reproduce and test these changes? Or at least a snippet of a schema/operation combo that I can use?

@kastermester
Copy link
Author

I will try to find time to put up a repo with a reproduce. But in short it happens when using this package: https://github.com/relay-tools/vscode-apollo-relay

Because it tries to teach the apollo tooling some Relay-isms, when hovering over arguments for directives that do not have documentation/types associated with them, this happens. In Relay this happens when hovering over arguments to ie. @arguments directive.

@kastermester
Copy link
Author

kastermester commented Oct 17, 2019

So ie. create a directive like this:

directive @arguments on FRAGMENT_SPREAD

And apply it to a fragment spread adding arguments to it.

@zionts zionts changed the title Don't break on bad arguments language-server: Don't break on bad arguments Dec 18, 2019
@zionts
Copy link
Contributor

zionts commented Dec 18, 2019

Hi @kastermester , thanks for pointing this out! This seems like something that should generally be done based on the null-handling in the other cases, rather than something specific to Relay's provider, unless I'm misinterpreting?

@kastermester
Copy link
Author

Precisely. All null values should ideally be handled. I’m not entirely sure which other situations there are though.

@zionts
Copy link
Contributor

zionts commented Mar 28, 2020

@kastermester this change seems pretty safe to me; seems to be porting a pattern that's elsewhere to a code path that seems to have missed it, which can cause a poor VS Code experience. Seems like the CHANGELOG is out of date, but that's a quick fix-up. @JakeDawkins, do you have any qualms against merging this?

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

Successfully merging this pull request may close these issues.

4 participants