Skip to content

Conversation

phryneas
Copy link
Member

No description provided.

Copy link
Contributor

github-actions bot commented Oct 18, 2024

You can download the latest build of the extension for this PR here:
vscode-apollo-0.0.0-build-1752596687.pr-230.commit-a561ce6.zip.

To install the extension, download the file, unzip it and install it in VS Code by selecting "Install from VSIX..." in the Extensions view.

Alternatively, run

code --install-extension vscode-apollo-0.0.0-build-1752596687.pr-230.commit-a561ce6.vsix --force

from the command line.

For older builds, please see the edit history of this comment.

@phryneas phryneas marked this pull request as ready for review October 28, 2024 14:38
Copy link
Member

@dylan-apollo dylan-apollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be honest, I don't really understand how this works, but your demo looked great! Added a few questions/comments

Comment on lines 42 to 43
"1":
name: "string.unquoted.NamedPathSelection.alias"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So can each of these sections get their own colors? I'd love to have one color for the "output" name (alias in this case) and another for things that are inputs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they can!

Open a text editor and execute the "Developer: inspect editor tokens and scopes" command

image

that will give you this pop-up:

image

And then you can move your cursor around and see what tokens things in other languages have, as an inspiration.


image
image

You see that GraphQL uses string.unquoted and variable as highlighting scopes here, but I also see that the alias is never applied because variable.KeyPath.key.identifier seems to have a higher priority somehow.

I'll debug that :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... with some changes:

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! A couple more notes on what we might want to add in future iterations:

  1. $ and @ as well as an identifier following $, like $args, $this, etc. are sort of our keywords? They're special, at very least, and might be worth highlighting separately.
  2. Anything in $() or as an argument to a method is sort of a different language mode. We call them literals, but they can also have some expressions within them. So ${ blah: $.blah } and $({ blah: $.blah }) are both valid, and look very similar, but do different things. It'd be nice to highlight that difference somehow (effectively, just the presence of the parens causes it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can configure {( and )} as a special kind of bracket pairs (this is VSCode, not TextMate!) so they will always have the same color and highlight in pairs together:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lennyburdette then I'm undoing that change and we go back to this:
image

Honestly I don't know if I can do a lot to visually highlight that difference more, apart from adding a full other "sub-language", which I'd rather avoid as this would become even more unmaintainable 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we just color parens differently than {} for now, since parens always represent entering literal mode? We could do something special with semantic tokens or something if we really want in the future

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @ and $ stuff looks great!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we just color parens differently than {} for now, since parens always represent entering literal mode? We could do something special with semantic tokens or something if we really want in the future

We'll need to test that out in the non-VSCode editors. VSCode pretty much ignores everything else and applies its "bracket pair coloring" logic over the top of configured bracket pairs (which we want to have so it highlights start and end).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then maybe it's just fine 😅. Certainly shouldn't block getting the highlighting of the rest of the language out there

@phryneas phryneas requested a review from dylan-apollo October 29, 2024 12:29
@phryneas
Copy link
Member Author

Okay, finalizing the colors. Here are a few impressions:

image

Here you can see that the object syntax (top) is different from the selection syntax (bottom).
This mimicks the colors that GraphQL syntax is using:

image

Another thing to point out is that builtin functions are highlighted differently:

image

The colors look very different here, but that's theme-specific. I'm using entity.name.function for a random function name and keyword.builtin, entity.name.function for known function names.

@phryneas phryneas requested a review from dylan-apollo July 11, 2025 14:35
Copy link
Member

@dylan-apollo dylan-apollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about the implementation, but I'm thrilled to have syntax highlighting!

My only note stylistically is I feel like the identifier on the left side of a : and the value on the right should have their colors swapped. In the screenshot, it makes sense to be that the short form is the same as the property side of objects (in headers). But in the long form, it seems like the key side should match the keys in objects and the value side should match the literal value $("blah").

If that doesn't make sense, happy to huddle on it!

Image Image

@@ -0,0 +1,10 @@
---
name: New Connector
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentionally a full clone of that repo? Should we trim out some bits like this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a subtree as that's the easiest way to keep those in sync.

git subtree pull --prefix sampleWorkspace/connectors-community https://github.com/apollographql/connectors-community.git main --squash

There are ways of syncing with subfolders of subtrees, but honestly that didn't seem to be worth the added complexity.

@phryneas
Copy link
Member Author

phryneas commented Jul 15, 2025

Yeah, happy to huddle on that property colorization issue.

From how I've interpreted it, most languages have two approaches and highlight them differently:

JavaScript:

const value = 1
// object construction (props and values)
const foo = {
  prop: value
}
// object destructuring (props and aliases)
const { 
  prop,
  prop: alias 
} = foo
query (value: "1000") {
  # objects in arguments (props and values)
  field(arg: {
    prop: $value
  }) {
    # field selections (fields and aliases)
    field
    alias: field
  }
}

And in the connectors syntax I tried to apply that similarly:

# inside lit: object construction with props and values
$({
  prop: $value
})

# outside lit: field selection with aliases
alias: field
field
image

As that doesn't exist in a vacuum, here the GraphQL example from above next to it so you can see how the color choices are similar:

image

And the JS example:

image

PS: interesting to see how GitHub itself doesn't make that distinction in their code highlighting

@phryneas phryneas merged commit 8626acc into main Jul 15, 2025
8 of 16 checks passed
@phryneas phryneas deleted the pr/textmate branch July 15, 2025 16:28
@github-actions github-actions bot mentioned this pull request Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants