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.

Field coloring varies based on newlines

See original GitHub issue

Actual Behavior

Field coloring varies depending whether the opening brace or directive is on the same line as the type definition. Especially in more complex cases (the Bar example below) it may be preferable to have directives on their own lines.

See field: String below:

Screenshot 2019-05-06 at 14 33 44

Expected Behavior

Colors don’t change based on locations.

Steps to Reproduce the Problem Or Description

Example code from screenshot:

type Foo1 {
  field: String
}

type Foo2
{
  field: String
}

type Bar1 @auth(rules: [
  { allow: groups, groups: ["Admin"] }
  { allow: groups, groups: ["Everyone"], operations: [read] }
]) {
  field: String
}

type Bar2
@auth(rules: [
  { allow: groups, groups: ["Admin"] }
  { allow: groups, groups: ["Everyone"], operations: [read] }
]) {
  field: String
}

Specifications

  • GraphQL for VSCode Extension Version: 0.1.7
  • VSCode Version: 1.32.3
  • OS Name: macOS
  • OS Version: Mojave

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
abc-moviestarplanetcommented, Nov 8, 2021

I just spent some hours to see if I could learn something about grammars and be able to fix it. With my very limited knowledge, what I found out was that as soon as the { is in a new line, it gets the meta.selectionset.graphql scope.

So if I modify the graphql-operation-def entry in the grammar file, to include #graphql-type-object before #graphql-selection-set then it all seemed to work fine.

Unfortunately I am unaware of side effects of this change and probably will need several more hours to learn grammars, so I’m hoping it at leasts helps someone else.

"graphql-operation-def": {
      "patterns": [
        { "include": "#graphql-query-mutation" },
        { "include": "#graphql-name" },
        { "include": "#graphql-variable-definitions" },
        { "include": "#graphql-directive" },
        { "include": "#graphql-type-object" },  // added this
        { "include": "#graphql-selection-set" }
      ]
    },
1reaction
acaocommented, Jan 10, 2021

@hkumar0132 possibly? if you’re familiar with regular expressions then definately. all these issues labelled “grammar” will just involve modifying the expressions in the grammar json files. here’s where to get started:

https://github.com/graphql/vscode-graphql#development

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with (wanted) line breaks and the Table > Email tools
I have a workflow that pulls from SharePoint, slices into various pieces based on project owner and status, and mails out separate tables ......
Read more >
Prevent `less -R` from resetting colours across newlines
How do I tell less , with -R or otherwise, not to reset colors across newlines( \n )? Here's an example of what...
Read more >
Replace space with new line - Unix & Linux Stack Exchange
The above says to substitute one or more whitespace characters ( \s\+ ) with a newline ( \n ). The -i parameter stands...
Read more >
Make line breaks work when you render text in a React or Vue ...
Prove it, Cassidy · No changes · Replace with br · Use CSS white-space.
Read more >
How to add Multi-Line Text to Fields in a PDF Forms Document
Java uses "\n" and "\r" to signify newline and carriage return characters. The interpretation of these characters varies across platforms.
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