Skip to content

Commit 920d8e9

Browse files
authoredNov 29, 2020
Allow loading configuration from package.json file (#5144)
1 parent feaf472 commit 920d8e9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎.changeset/hot-trainers-fail.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/cli': patch
3+
---
4+
5+
Allow loading configuration from package.json file

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function generateSearchPlaces(moduleName: string) {
2525
// gives .codegenrc.json... but no .codegenrc.config.js
2626
const dot = extensions.filter(ext => ext !== 'config.js').map(ext => `.${moduleName}rc.${ext}`);
2727

28-
return regular.concat(dot);
28+
return [...regular.concat(dot), 'package.json'];
2929
}
3030

3131
function customLoader(ext: 'json' | 'yaml' | 'js') {
@@ -54,6 +54,7 @@ export async function loadContext(configFilePath?: string): Promise<CodegenConte
5454
const moduleName = 'codegen';
5555
const cosmi = cosmiconfig(moduleName, {
5656
searchPlaces: generateSearchPlaces(moduleName),
57+
packageProp: moduleName,
5758
loaders: {
5859
'.json': customLoader('json'),
5960
'.yaml': customLoader('yaml'),

0 commit comments

Comments
 (0)
Please sign in to comment.