question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support /* GraphQL */ among other patterns

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
cjhowedevcommented, Feb 19, 2018

Another reason to support this is that prettier will format this:

export default `#graphql
  ...your graphql code here
`;

to this:

export default `
  #graphql
  ...your graphql code here
`;

which will break highlighting. This makes it a non-option for prettier users. The comment form doesn’t have this issue.

2reactions
kachkaevcommented, Feb 7, 2018

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 a graphql string literal when defining a schema – the string is just passed to makeExecutableSchema later on.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found