Skip to content

Commit 1bf974e

Browse files
igorvelmiekargoigorzhvelmie
authored andcommitted
feat: relative paths
1 parent 586e4ee commit 1bf974e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import { importSchema } from 'graphql-import'
1+
import { importSchema, parseSDL } from 'graphql-import'
2+
import { dirname, resolve } from 'path'
23

3-
export default function(source) {
4-
const callback = this.async();
4+
export default function (source) {
5+
const callback = this.async()
56

67
this.cacheable()
78

8-
callback(null, `module.exports = \`${importSchema(source).replace(/`/g, '\\`')}\``)
9+
parseSDL(source).forEach(rawModule => {
10+
this.addDependency(resolve(dirname(this.resourcePath), rawModule.from))
11+
})
12+
13+
callback(null, `module.exports = \`${importSchema(this.resourcePath).replace(/`/g, '\\`')}\``)
914
}

0 commit comments

Comments
 (0)