Skip to content

Commit

Permalink
Merge pull request prisma-labs#6 from jgeschwendt/fix-backticks
Browse files Browse the repository at this point in the history
fix(loader): escape backtick characters that may lie within comments
  • Loading branch information
schickling authored Mar 26, 2018
2 parents b3dd9ba + 4f07e62 commit 586e4ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default function(source) {

this.cacheable()

callback(null, `module.exports = \`${importSchema(source)}\``)
callback(null, `module.exports = \`${importSchema(source).replace(/`/g, '\\`')}\``)
}
3 changes: 3 additions & 0 deletions test/fixtures/a.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Comment with escaped `backticks`
"""
type A {
id: ID!
valueA: String
Expand Down
3 changes: 3 additions & 0 deletions test/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const complex = `module.exports = \`type Complex {
d: D!
}
"""
Comment with escaped \\\`backticks\\\`
"""
type A {
id: ID!
valueA: String
Expand Down

0 comments on commit 586e4ee

Please sign in to comment.