-
Notifications
You must be signed in to change notification settings - Fork 83
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
Highlighting GraqphQL queries #242
Comments
I'll add a Relay.QL and gql tag`` option to the grammar. No way to highlight sql queries. I could add another template sql``and call |
There are a few relatively unknown libraries trying to add tagged sql strings but they don't have much attention at all relative to |
Is that possible in Atom? |
No it's not really possible to make it configurable as it would mean dynamically patching the grammar, and that has other attendant issues, such as running the specs. |
I think you're actually expected to use query variables rather than directly do string interpolation. http://docs.apollostack.com/apollo-client/core.html#query So yea not supporting |
Just rolled out 2.37.0 that has support for |
edit: actually reading above indicates that yes, that's the problem. overall i'm finding my fragments to have no additional highlighting but have completely lost the useful bits that used to be there. 👋 hi there, It seems like this update actively makes these queries less readable. My interpolations are now blending in completely to the rest of the string template, whereas before it correctly did normal js syntax highlighting inside the |
that's not quite right, relay requires you do interpolation here for composing fragments: Relay.QL`
fragment on AnalysisImage @relay(plural: true) {
${AnalysisImagePlot.getFragment('image')}
extension
href
}
`, |
Hmm maybe we should either disable syntax highlighting for |
Ok, I'm not a relay user but I would agree that the language-graphql package doesn't seem to add much in the way of syntax highlighting and also means I loose control over interpolation. There are no sensible ways to support an embedded language inside a template literal unless it is done natively inside language-babel. I could do a PR against the language-graphql grammar so that when a ${} is found he passes control back to me. That would work, but I doubt the author would accept that PR. I need a view as to what I should do. Revert back to normal template highlighting or follow on this course |
I just took a look a the graphql spec and it is pretty simple. I've decided I'll support it directly inside my grammar. I'll then support interpolation and nested queries. Hopefully, I'll release this by the weekend. |
@tonyxiao @jquense @jonboiser 2.39.0 has native support for GraphQL inside Relay.QL and gql tagged template strings. Also supports interpolation and the correct commenting using the Atom keyboard shortcut. I'm not sure on the scopes of the various components - should some bits be function, variables, types, keys....,, being unfamiliar with GraphQL any input appreciated. I'm also a bit hazy on some of the grammar as it seems to be a work in progress as far as the spec is concerned. |
looks great! so far it's working nicely for me :) thanks! |
This is wild @gandm! |
Just tweaked the grammar and added a /* Graph QL /* as a template prefix. See https://github.com/gandm/language-babel#graphql-code-highlighting |
Wow that's awesome. Thank you @gandm ! |
How modular is this feature? I was wishing to work on something similar soon and I wish I can write a plugin that can extend support for this. my need: // js code here...
// then...
var fragmentShader = GLSL`
precision highp float;
varying vec2 uv;
void main () {
gl_FragColor = vec4(uv.x, uv.y, 0.5, 1.0);
}
` How can I hook https://github.com/hughsk/language-glsl to this basically? (currently it will obviously highlight as:) // js code here...
// then...
var fragmentShader = GLSL`
precision highp float;
varying vec2 uv;
void main () {
gl_FragColor = vec4(uv.x, uv.y, 0.5, 1.0);
}
` |
@gre Quite simple to do this - Look at the this section of the readme |
@gandm thanks, awesome! |
Look at this section of the readme https://github.com/gandm/language-babel#javascript-tagged-template-literal-grammar-extensions Sent from my Windows Phone From: Gaëtan Renaudeaumailto:notifications@github.com How modular is this feature? I was wishing to work on something similar soon and I wish I can write a plugin that can extend support for it. my need: // js code here...
// then...
var fragmentShader = GLSL`
precision highp float;
varying vec2 uv;
void main () {
gl_FragColor = vec4(uv.x, uv.y, 0.5, 1.0);
}
` You are receiving this because you were mentioned. |
For es6 tagged strings starting with
Relay.QL
orgql
,Related
PS: Is there a way to highlight SQL queries already?
The text was updated successfully, but these errors were encountered: