graphql / graphiql

GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
MIT License
16.13k stars 1.73k forks source link

Feature: Support graphql tagged heredoc string literals in non-js files #2346

Open TSMMark opened 4 years ago

TSMMark commented 4 years ago

Thanks for making this awesome plugin. Works great for our js codebase

However our graphql api is written using graphql-ruby and so all of our graphql specs are Ruby files. In these files we define heredoc string literals like this:

# spec/whatever_spec.rb

<<~GRAPHQL
  query Whatever {
    whatever {
      id
    }
  }
GRAPHQL

Would it be possible to support Ruby files with this plugin?

If so, is it something a new contributor would be able to tackle? I wouldn't mind taking a stab at implementing it if someone gives me a few pointers where to start.

Thanks again!

acao commented 4 years ago

hey! i would like to support this. we would want to create a grammars/graphql.rb.json file, and sprinkle in a few regexes for detecting these delimiters, for highlighting support at least

acao commented 4 years ago

we could even just borrow this from apollo:

https://github.com/apollographql/apollo-tooling/blob/master/packages/vscode-apollo/syntaxes/graphql.rb.json

now, parsing ruby on the language server side for full-featured language support is another matter. we would need a node/typescript compatible tool for that.

acao commented 4 years ago

@TSMMark let me know if you're still interested! sorry I just took the project over a couple months ago

TSMMark commented 4 years ago

I can try to dedicate some time but I really have no experience doing syntax parsing or editor plugins so any pointers of files I would have to touch and tests I should write would be a huge help getting me started

TSMMark commented 4 years ago

@acao Still very interested in this but not sure how to start or how to test. Also I have no need for syntax highlighting, as that's covered by another plugin I'm using https://marketplace.visualstudio.com/items?itemName=kumar-harsh.graphql-for-vscode

parsing ruby on the language server side for full-featured language support is another matter

Would we actually need to parse the Ruby language just to examine query strings? I found this opal package, something like that? https://github.com/opal/opal

acao commented 3 years ago

the language grammar files are where this happens for highlighting. they are json files with regular expressions for selecting tokens. if you see a graphql highlighting mode another extension has, you can open a PR

for actually supporting language features other than highlighting, that logic lives in the seperate LSP server repo that this repo depends on