Opening this issue to track the addition of GraphQL syntax highlighting to GFM.
``````
query FooQuery {
field(call:$value) @directive(awesome:true, number:42, strings:"yes") {
subfield as alias
}
}
``````
Use the syntax highlighter from https://github.com/rmosolgo/language-graphql
Click here for an example of highlighted source.
cc @leebyron @dschafer @schrockn
Is the file extension for GraphQL .js? Is there a way to differentiate GraphQL files from JavaScript files?
File extension is recommended to be .graphql - .js should never be treated as GraphQL.
File extension is recommended to be
.graphql-.jsshould never be treated as GraphQL.
Oh, great! (I had this impression because facebook/graphql is using .js for its example files).
I can open a pull request to add detection for GraphQL. Do you have a sample file I could use though?
https://github.com/graphql/graphql-js/blob/master/src/language/__tests__/kitchen-sink.graphql and https://github.com/graphql/graphql-js/blob/master/src/language/__tests__/schema-kitchen-sink.graphql are pretty good places to start! :)
Is there a color from an official logo I could use for the language bar?
Hum, I'm getting ahead of myself. I don't think there are enough .graphql files on GitHub to add support for it in Linguist (see the guidelines).
@arfon Could we only add support for GraphQL without a file extension (only for code snippets as it was the original request)?
I'm most concerned at this point with syntax highlighting than I am with showing the percentage of .graphql files in any given repo.
We have many examples in the Relay universe that could benefit from this treatment.
See “Proposed API” of this issue: https://github.com/facebook/relay/issues/114
Another issue altogether is how to syntax highlight fragments of GraphQL found inside JS Relay.QL templates. See “getFatQuery()” here: https://github.com/facebook/relay/issues/126#issuecomment-133107693
Even with wide proliferation of GraphQL the use of .graphql files will probably not be all that common. However GraphQL code blocks in markdown files will be.
Could we only add support for GraphQL without a file extension (only for code snippets as it was the original request)?
@arfon @bkeepers :point_up:
Could we only add support for GraphQL without a file extension (only for code snippets as it was the original request)?
I've just closed a pull request asking for the same thing so I really don't want to make an exception here unless we can demonstrate more wide-scale usage of the syntax.
@leebyron/@pchaigno - do you have any suggestions for finding more files that might contain GraphQL snippets?
Most helpful comment
Even with wide proliferation of GraphQL the use of .graphql files will probably not be all that common. However GraphQL code blocks in markdown files will be.