Skip to content

Commit

Permalink
fix: block strings syntax highlighting in cm6-graphql (#3505)
Browse files Browse the repository at this point in the history
* fix: block strings syntax highlighting in cm6-graphql
* make Description tagged as string
  • Loading branch information
Gasser-Aly committed Jan 24, 2024
1 parent 7f05c10 commit a562c96
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/new-tools-unite.md
@@ -0,0 +1,5 @@
---
'cm6-graphql': patch
---

fix: block strings syntax highlighting
32 changes: 32 additions & 0 deletions packages/cm6-graphql/__tests__/cases.txt
Expand Up @@ -113,3 +113,35 @@ Document(
Document(
OperationDefinition(SelectionSet("{",Selection(Field(FieldName)),Selection(Field(FieldName,SelectionSet("{",Selection(Field(FieldName)),"}"))),"}"))
)



# Test case for blockStringCharacter in a Description

"""
This is a block string description
with multiple lines.
It can contain any character except for \""".
"""
type Example {
id: ID
}

==>

Document(
TypeSystemDefinition(
TypeDefinition(
ObjectTypeDefinition(
Description(StringValue),
TypeKeyword(type),
Name,
FieldsDefinition(
"{",
FieldDefinition(Name, NamedType(Name)),
"}"
)
)
)
)
)
1 change: 1 addition & 0 deletions packages/cm6-graphql/src/language.ts
Expand Up @@ -20,6 +20,7 @@ export const graphqlLanguage = LRLanguage.define({
styleTags({
Variable: t.variableName,
BooleanValue: t.bool,
Description: t.string,
StringValue: t.string,
Comment: t.lineComment,
IntValue: t.integer,
Expand Down
5 changes: 4 additions & 1 deletion packages/cm6-graphql/src/syntax.grammar
Expand Up @@ -393,7 +393,10 @@ Name { name }
// https://spec.graphql.org/October2021/#BlockStringCharacter
blockStringCharacter {
'\\"""' |
'"' '"'? !["]
'"' '"'? !["] |
stringCharacter |
'\n' |
'\r\n'
}

// https://spec.graphql.org/October2021/#EscapedUnicode
Expand Down

0 comments on commit a562c96

Please sign in to comment.