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 GraphQL syntax highlighting to GFM code fences #2637

Closed
steveluscher opened this issue Sep 16, 2015 · 12 comments · Fixed by #2947
Closed

Add GraphQL syntax highlighting to GFM code fences #2637

steveluscher opened this issue Sep 16, 2015 · 12 comments · Fixed by #2947

Comments

@steveluscher
Copy link

Opening this issue to track the addition of GraphQL syntax highlighting to GFM.

```graphql
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.

@steveluscher
Copy link
Author

cc @leebyron @dschafer @schrockn

@pchaigno
Copy link
Contributor

Is the file extension for GraphQL .js? Is there a way to differentiate GraphQL files from JavaScript files?

@leebyron
Copy link

File extension is recommended to be .graphql - .js should never be treated as GraphQL.

@pchaigno
Copy link
Contributor

File extension is recommended to be .graphql - .js should 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?

@pchaigno
Copy link
Contributor

Is there a color from an official logo I could use for the language bar?

@leebyron
Copy link

#E535AB

@pchaigno
Copy link
Contributor

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)?

@steveluscher
Copy link
Author

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: facebook/relay#114

Another issue altogether is how to syntax highlight fragments of GraphQL found inside JS Relay.QL templates. See “getFatQuery()” here: facebook/relay#126 (comment)

@leebyron
Copy link

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.

@pchaigno
Copy link
Contributor

pchaigno commented Oct 9, 2015

Could we only add support for GraphQL without a file extension (only for code snippets as it was the original request)?

@arfon @bkeepers ☝️

@arfon
Copy link
Contributor

arfon commented Oct 14, 2015

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?

jparise added a commit to jparise/vim-graphql that referenced this issue Jan 1, 2016
.graphql appears to be the recommended file extension, per @leebyron:

  github-linguist/linguist#2637 (comment)

We'll continue to support the abbreviated .gql extension.
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants