support /* GraphQL */ among other patterns
See original GitHub issueWhen trying VSCode after Atom, I noticed that not all graphql scheama definitions are correctly found. Here’s the one I struggled with:
export default /* GraphQL */ `
# graphql types etc. (expected to be highlighted, but it did not)
`;
I guess this can be fixed by tweaking begin
in syntaxes/graphql.js.json
, which currently equals to:
"begin": "(Relay\\.QL|gql|graphql(\\.experimental)?)(`)",
In Atom’s language-babel package the definition of a similar concept is a bit more complex:
"begin": "\\s*+(?:((Relay)(?:(\\?\\.)|(\\.))(QL))|(gql|graphql|graphql\\.experimental)|(/\\* GraphQL \\*/))\\s*((`))",
In addition to /* GraphQL */
, looks like the latter RegExp also supports spacing between a template literal and `
(e.g. both graphql`
and graphql `
).
I’m not sure I’ll be ready to submit a PR because I’m new to VSCode and won’t find enough time to go through all potential difficulties of a newcomer. But still hope that my mini-investigation helps!
WDYT @kumarharsh? BTW thanks a lot for this handy extension! 💯
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
GraphQL Best Practices Resources and Design Patterns
GraphQL is becoming the hottest new trend for APIs. We collected some awesome resources and articles on best practices and design patterns.
Read more >GraphQL Best Practices
Some client tools for GraphQL, such as Relay, know about the Connections pattern and can automatically provide support for client-side pagination when a...
Read more >Moving toward GraphQL consolidation
In this section, you'll learn about the advantages of a consolidated GraphQL architecture and how a common, federated graph allows you to realize...
Read more >Common anti-patterns in GraphQL schema design
GraphQL supports only limited scalar types: Int , Float , String , Boolean and ID . Assuming they are self-explanatory, there are many...
Read more >When and why to use GraphQL.. Design Patterns ... - Medium
It is technically true that any of these patterns could be implemented with a different tool. I'd argue using GraphQL would make most...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another reason to support this is that prettier will format this:
to this:
which will break highlighting. This makes it a non-option for prettier users. The comment form doesn’t have this issue.
Thanks for hinting on
export default `#graphql
! That’s useful, but I guess it’d be still great to support/* GgraphQL */ `
too, at least because it’s already supported by the Atom’s package. Others switching to vscode may have similar expectations and get confused as well.I’ve seen
/* GgraphQL */ `
in a few places around github and I guess its’ a convention of some sort (perhaps, even a wider one, not just GraphQL-specific) 😉 I’m using it in apollo-server, where you don’t need to apply agraphql
string literal when defining a schema – the string is just passed tomakeExecutableSchema
later on.