From e1567f1a0e4092cf4a7df3199155b3280a3296c5 Mon Sep 17 00:00:00 2001 From: Igor Zhukovich Date: Sat, 11 May 2019 13:09:46 +0300 Subject: [PATCH] feat: relative paths --- src/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3b595f6..bef7800 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,14 @@ -import { importSchema } from 'graphql-import' +import { importSchema, parseSDL } from 'graphql-import' +import { dirname, resolve } from 'path' -export default function(source) { +export default function (source) { const callback = this.async(); - this.cacheable() + this.cacheable(); - callback(null, `module.exports = \`${importSchema(source).replace(/`/g, '\\`')}\``) + parseSDL(source).forEach(rawModule => { + this.addDependency(resolve(dirname(this.resourcePath), rawModule.from)); + }); + + callback(null, `module.exports = \`${importSchema(this.resourcePath).replace(/`/g, '\\`')}\``); }