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

Enable goto def in LSP to goto the actual schema definition #4434

Closed
wants to merge 4 commits into from

Conversation

bigfootjon
Copy link
Member

@bigfootjon bigfootjon commented Sep 4, 2023

I basically just took @captbaritone 's POC and made it configurable based on our conversation on Threads

This should be reasonably generalized to support different use-cases, but I'm open to rewriting all of this.

Test plan:

cd compiler
cargo build --release --bin relay
cd ../vscode-extension
yarn build-local

In a private project, I configured the new option and overrode the relay binary location:

+ "relay.pathToExtraDataProviderScript": "../scripts/graphql_lookup.sh",
+ "relay.pathToRelay": ".../relay/compiler/target/release/relay"

I manually installed the relay-2.1.0.vsix file in my VSCode and reloaded

I opened a file with a Relay GraphQL query in it and ctrl-clicked (goto def on my machine) and it went to the correct file!

Copy link
Contributor

@captbaritone captbaritone left a comment

Choose a reason for hiding this comment

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

Awesome!! Thank you for working on this.

compiler/crates/relay-bin/src/main.rs Outdated Show resolved Hide resolved
compiler/crates/relay-bin/src/main.rs Outdated Show resolved Hide resolved
vscode-extension/README.md Show resolved Hide resolved
vscode-extension/README.md Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@bigfootjon has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@bigfootjon merged this pull request in 3b96b01.

@bigfootjon bigfootjon deleted the oss-goto-real-def branch September 6, 2023 05:21
@captbaritone
Copy link
Contributor

captbaritone commented Jan 18, 2024

With v2.1.0 of the VSCode extension now published (thanks @alex-statsig ), I have an example repo showing this feature working with Grats: captbaritone/grats-relay-example@64a5ed4

It's a bit of a bummer that I need a separate script. I wonder if it would be nicer to allow the config option to be a bash command, rathe than just a path to an executable. But in that world, it's a bit unclear how the project and entity name get passed (if it were just one thing stdin would be fine)

Maybe you could pass the LSP an option like:

relay lsp --locateCommand="pnpm run grats locate %entity"

Or something?

@alex-statsig
Copy link
Contributor

Another thought on this - it would be great to have a separate "locateCommand" setting for "Go to implementations"

I used this setting to allow easier navigation to our backend resolvers (which is amazing), but now theres no easy way to get to the schema (currently manually defined, ideally will be code-first eventually).

Perhaps another way to support that would be to allow returning two locations, or more conveniently an option to still include the schema.graphql definition that relay finds rather than replacing it.

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

Successfully merging this pull request may close these issues.

4 participants