Skip to content

Commit

Permalink
fix: block strings syntax highlighting in cm6-graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
Gasser-Aly committed Jan 14, 2024
1 parent 88ae243 commit 647ee31
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'cm6-graphql': patch
---

fix: block strings syntax highlighting
32 changes: 32 additions & 0 deletions packages/cm6-graphql/__tests__/cases.txt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const graphqlLanguage = LRLanguage.define({
styleTags({
Variable: t.variableName,
BooleanValue: t.bool,
Description: t.docComment,
StringValue: t.string,
Comment: t.lineComment,
IntValue: t.integer,
Expand Down
5 changes: 4 additions & 1 deletion packages/cm6-graphql/src/syntax.grammar
Original file line number Diff line number Diff line change
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 647ee31

Please sign in to comment.