diff --git a/packages/graphql/lib/plugin/utils/plugin-utils.ts b/packages/graphql/lib/plugin/utils/plugin-utils.ts index b90c42dbf..736894d5a 100644 --- a/packages/graphql/lib/plugin/utils/plugin-utils.ts +++ b/packages/graphql/lib/plugin/utils/plugin-utils.ts @@ -1,5 +1,5 @@ import { head } from 'lodash'; -import { posix } from 'path'; +import { isAbsolute, posix } from 'path'; import * as ts from 'typescript'; import { getText, @@ -109,7 +109,10 @@ export function replaceImportPath(typeReference: string, fileName: string) { importPath = importPath.slice(2, importPath.length - 1); let relativePath = posix.relative(posix.dirname(fileName), importPath); - relativePath = relativePath[0] !== '.' ? './' + relativePath : relativePath; + relativePath = + !isAbsolute(relativePath) && relativePath[0] !== '.' + ? './' + relativePath + : relativePath; const nodeModulesText = 'node_modules'; const nodeModulePos = relativePath.indexOf(nodeModulesText);