Skip to content

Commit

Permalink
fix: skip #import+ comments
Browse files Browse the repository at this point in the history
Closes #94
  • Loading branch information
schickling authored Feb 27, 2018
2 parents 6f1d7b6 + 55ce73c commit 9bd6064
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ test('parseImportLine: different path', t => {
})
})

test('parseSDL: non-import comment', t => {
t.deepEqual(parseSDL(`#importent: comment`), [])
})

test('parse: multi line import', t => {
const sdl = `\
# import A from "a.graphql"
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function parseSDL(sdl: string): RawModule[] {
return sdl
.split('\n')
.map(l => l.trim())
.filter(l => l.startsWith('# import') || l.startsWith('#import'))
.filter(l => l.startsWith('# import ') || l.startsWith('#import '))
.map(l => l.replace('#', '').trim())
.map(parseImportLine)
}
Expand Down

0 comments on commit 9bd6064

Please sign in to comment.