Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ packages/graphql-codegen-cli/tests/test-files/error-document.graphql
# Ignore dev-tests with no prettier requirement
dev-test/general/githunt-invalid/invalid.graphql
dev-test/general/test-schema/flow-types.flow.js
dev-test/graphql-config/**/__generated__/
dev-test-apollo-tooling/src/__generated__/
10 changes: 10 additions & 0 deletions dev-test/graphql-config/multi/.graphqlrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
projects:
default:
schema: 'default/schema.graphql'
project1:
schema: 'project1/schema.graphql'
extensions:
codegen:
generates:
'project1/__generated__/types.ts':
plugins: ['typescript']
3 changes: 3 additions & 0 deletions dev-test/graphql-config/multi/default/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Query {
default: String
}
15 changes: 15 additions & 0 deletions dev-test/graphql-config/multi/project1/__generated__/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dev-test/graphql-config/multi/project1/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Query {
project1: String
}
21 changes: 21 additions & 0 deletions dev-test/graphql-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "dev-test-graphql-config",
"version": "0.0.1",
"description": "Test graphql-config integration",
"private": true,
"scripts": {
"generate": "pnpm generate:esm",
"generate:cjs": "pnpm generate:cjs:single && pnpm generate:cjs:multi && pnpm generate:cjs:multi:project1",
"generate:cjs:multi": "node ../../packages/graphql-codegen-cli/dist/cjs/bin.js --config multi/.graphqlrc.yml || [ $? -eq 1 ]",
"generate:cjs:multi:project1": "node ../../packages/graphql-codegen-cli/dist/cjs/bin.js --config multi/.graphqlrc.yml --project project1",
"generate:cjs:single": "node ../../packages/graphql-codegen-cli/dist/cjs/bin.js --config single/.graphqlrc.yml",
"generate:esm": "pnpm generate:esm:single && pnpm generate:esm:multi && pnpm generate:esm:multi:project1",
"generate:esm:multi": "node ../../packages/graphql-codegen-cli/dist/esm/bin.js --config multi/.graphqlrc.yml || [ $? -eq 1 ]",
"generate:esm:multi:project1": "node ../../packages/graphql-codegen-cli/dist/esm/bin.js --config multi/.graphqlrc.yml --project project1",
"generate:esm:single": "node ../../packages/graphql-codegen-cli/dist/esm/bin.js --config single/.graphqlrc.yml"
},
"devDependencies": {
"@graphql-codegen/cli": "workspace:*",
"@graphql-codegen/typescript": "workspace:*"
}
}
6 changes: 6 additions & 0 deletions dev-test/graphql-config/single/.graphqlrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
schema: 'schema.graphql'
extensions:
codegen:
generates:
'__generated__/types.ts':
plugins: ['typescript']
15 changes: 15 additions & 0 deletions dev-test/graphql-config/single/__generated__/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dev-test/graphql-config/single/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Query {
single: String
}
30 changes: 30 additions & 0 deletions packages/graphql-codegen-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# @graphql-codegen/cli

## 7.1.3

### Patch Changes

- [#10335](https://github.com/dotansimha/graphql-code-generator/pull/10335)
[`3280ace`](https://github.com/dotansimha/graphql-code-generator/commit/3280ace4505dcadf5398b6cbf157a8c8d7a713c2)
Thanks [@Diluka](https://github.com/Diluka)! - Fix graphql-config loading order to correctly
detect codegen projects

Previously, a `graphql-config` file like this failed:

```yml
projects:
default:
schema: 'default/schema.graphql'
project1:
schema: 'project1/schema.graphql'
extensions:
codegen:
generates:
'project1/__generated__/types.ts':
plugins: ['typescript']
```

This is because the `default` project doesn't have a `codegen` extension, which caused previous
logic to short circuit before reading `project1`'s config.

The fix reads every named project first, before reading the `default` project to exhaustively go
through every single project.

## 7.1.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/cli",
"version": "7.1.2",
"version": "7.1.3",
"type": "module",
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions packages/graphql-codegen-cli/src/graphql-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ function isGraphQLConfig(config: GraphQLConfig): config is GraphQLConfig {
return false;
}

try {
return config.getDefault().hasExtension('codegen');
} catch {}

try {
for (const projectName in config.projects) {
if (Object.prototype.hasOwnProperty.call(config.projects, projectName)) {
Expand All @@ -69,5 +65,9 @@ function isGraphQLConfig(config: GraphQLConfig): config is GraphQLConfig {
}
} catch {}

try {
return config.getDefault().hasExtension('codegen');
} catch {}

return false;
}
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading