Skip to content

Commit 93e49f8

Browse files
authoredNov 4, 2020
fix(cli): resolve from folders correctly (#5032)
* fix(cli): resolve from folders correctly * chore: changesets
1 parent 4ad0319 commit 93e49f8

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed
 

‎.changeset/young-jars-trade.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/cli': patch
3+
---
4+
5+
Correctly resolve relative to the cwd

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
"**/@types/graphql-upload/graphql": "^15.0.0"
125125
},
126126
"dependencies": {
127+
"dotenv": "^8.2.0",
127128
"patch-package": "^6.2.2"
128129
}
129130
}

‎packages/graphql-codegen-cli/src/config.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { DetailedError, Types } from '@graphql-codegen/plugin-helpers';
44
import { env } from 'string-env-interpolation';
55
import yargs from 'yargs';
66
import { GraphQLConfig } from 'graphql-config';
7-
// eslint-disable-next-line
8-
import { createRequire, createRequireFromPath } from 'module';
97
import { findAndLoadGraphQLConfig } from './graphql-config';
108
import { loadSchema, loadDocuments } from './load';
119

@@ -173,8 +171,7 @@ export function parseArgv(argv = process.argv): YamlCliFlags {
173171

174172
export async function createContext(cliFlags: YamlCliFlags = parseArgv(process.argv)): Promise<CodegenContext> {
175173
if (cliFlags.require && cliFlags.require.length > 0) {
176-
const relativeRequire = (createRequire || createRequireFromPath)(process.cwd());
177-
await Promise.all(cliFlags.require.map(mod => import(relativeRequire.resolve(mod))));
174+
await Promise.all(cliFlags.require.map(mod => import(require.resolve(mod, { paths: [process.cwd()] }))));
178175
}
179176

180177
const customConfigPath = getCustomConfigPath(cliFlags);

0 commit comments

Comments
 (0)
Please sign in to comment.