Reccomendations for using the GraphQL LSP to write Trustfall #679
SuperSonicHub1
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@obi1kenobi recommended I write this up after discussing my workflow on Discord. It's simple, but quite useful. I can get this in a document one someone tells me where to put it.
Because the Trustfall query language is a syntactic subset of GraphQL and the semantics have enough in common, it's pretty useful to reuse GraphQL tooling for writing schemas and queries. The GraphQL team maintains their own LSP server for the language; I show here how to use that in the context of writing Trustfall code.
For VSCode and VSCodium users, getting the LSP is as simple as installing the appropriate extension.
Once you have the LSP going, you'll need to write a
.graphqlrc.yml
1 configuration file in order to tell the language server where your schema and queries are relative to the location of the file. Here's the configuration fortrustfall-rustc-adapter
:Having to put your queries in files is a bit annoying seeing as it's quite common for Trustfall projects to store queries as strings in the source code of other languages, but I still believe it to be worth it. For more info on how to write a config file, see the GraphQL-Config docs.
Once the above steps are complete, you'll immediately get the expected IDE features like autocomplete, go to definition, specialized syntax highlighting, a formatter, and squiggles for syntax and semantic errors. Have fun!
Footnotes
One may also prefer using
.graphqlrc.toml
seeing as we're Rust users. ↩Beta Was this translation helpful? Give feedback.
All reactions