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

Add copy operation command #4778

Closed

Conversation

tobias-tengler
Copy link
Contributor

@tobias-tengler tobias-tengler commented Aug 29, 2024

I often find myself in a situation where I want to quickly run a Relay query outside of the configured Relay environment, i.e. a GraphQL IDE or another tool. When not using persisted operations, I need to go to the artifact, copy out the value of the text property and get rid of all the \n line breaks in the text. For persisted operations it's less tedious, I just grab the id from the artifact and look up the operation in the operation store, but it's still more cumbersome than it has to be.

This implements a new relay/printOperation request in the LSP that returns the transformed operation text of the operation under the cursor or the first operation inside the document. The VS Code Extension is also updated with a relay.copyOperation command that invokes that LSP request and copies the operation text to the clipboard.

Example of the command in action

@tobias-tengler tobias-tengler force-pushed the print-operation-command branch from 32ea7f5 to f1262f3 Compare August 29, 2024 17:30
@tobias-tengler tobias-tengler changed the title Add print operation command Add copy operation command Aug 29, 2024
@tobias-tengler
Copy link
Contributor Author

tobias-tengler commented Aug 29, 2024

Seems like your internal Rust version no longer matches the one defined in the CI. It's failing since you've merged 176f96f

EDIT: Fixed in #4779

@zth
Copy link
Contributor

zth commented Sep 2, 2024

Really nice! Did you consider making it a code action instead?

@tobias-tengler
Copy link
Contributor Author

At least for me the extension command seemed faster, as I don't first have to locate the operation inside the document if there's only one.
Where would you see the benefits of a code action?

@facebook-github-bot
Copy link
Contributor

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

@tobias-tengler
Copy link
Contributor Author

@captbaritone Had to update the minimum compiler version check to 18.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@captbaritone merged this pull request in 8d2380b.

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.

3 participants