Skip to content

Commit 586e4ee

Browse files
authored
Merge pull request #6 from jgeschwendt/fix-backticks
fix(loader): escape backtick characters that may lie within comments
2 parents b3dd9ba + 4f07e62 commit 586e4ee

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export default function(source) {
55

66
this.cacheable()
77

8-
callback(null, `module.exports = \`${importSchema(source)}\``)
8+
callback(null, `module.exports = \`${importSchema(source).replace(/`/g, '\\`')}\``)
99
}

test/fixtures/a.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Comment with escaped `backticks`
3+
"""
14
type A {
25
id: ID!
36
valueA: String

test/loader.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const complex = `module.exports = \`type Complex {
1414
d: D!
1515
}
1616
17+
"""
18+
Comment with escaped \\\`backticks\\\`
19+
"""
1720
type A {
1821
id: ID!
1922
valueA: String

0 commit comments

Comments
 (0)