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
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Master
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup env
uses: the-guild-org/shared-config/setup@main
- name: Prettier Check
Expand All @@ -40,7 +40,7 @@ jobs:
- 'esm'
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup env
uses: the-guild-org/shared-config/setup@main
- name: Build
Expand All @@ -56,7 +56,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup env
uses: the-guild-org/shared-config/setup@main
- name: Build
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup env
uses: the-guild-org/shared-config/setup@main
- name: Build
Expand All @@ -139,7 +139,7 @@ jobs:
graphql_version: 16
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup env
uses: the-guild-org/shared-config/setup@main
with:
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
graphql_version: 16
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup env
uses: the-guild-org/shared-config/setup@main
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
publish-rust-swc-plugin:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/website-integrity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- name: Fetch
run: git fetch origin master
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Publish a message
if: always() && contains(steps.diff_result.outputs.result, 'diff')
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
message: |
```diff
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push'
steps:
- name: checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,23 @@ Some repos may have multiple Codegen projects, each generating types for operati
const config: CodegenConfig = {
// ...
generates: {
'src/shared/base-types.generated.ts': {
'src/graphql/base-types.generated.ts': {
plugins: ['typescript']
},
'src/project-1/types.generated.ts': {
documents: 'src/project-1/**/*.graphql.ts',
preset: 'import-types',
plugins: ['typescript-operations'],
presetConfig: {
typesPath: '../shared/base-types.generated.ts'
typesPath: '../graphql/base-types.generated.ts'
}
},
'src/project-2/types.generated.ts': {
documents: 'src/project-2/**/*.graphql.ts',
preset: 'import-types',
plugins: ['typescript-operations'],
presetConfig: {
typesPath: '../shared/base-types.generated.ts'
typesPath: '../graphql/base-types.generated.ts'
}
}
}
Expand All @@ -121,7 +121,7 @@ Now, it is possible to do this with just `typescript-operations`, as it supports
const config: CodegenConfig = {
// ...
generates: {
'src/shared/base-types.generated.ts': {
'src/graphql/base-types.generated.ts': {
documents: 'src/**/*.graphql.ts' // Parses all files with GraphQL documents to generate Enum and Input types that are used by every project
plugins: ['typescript-operations'],
config: {
Expand All @@ -146,6 +146,67 @@ const config: CodegenConfig = {
}
```

#### near-operation-file-preset setups

[near-operation-file-preset](https://the-guild.dev/graphql/codegen/plugins/presets/near-operation-file-preset) is commonly used to generate a file next to operation document a.k.a. near-operation file.

Previously, shared types were always generated into a shared file using the `typescript` plugin, and reused in every near-operation file:

```typescript filename="codegen.ts"
const config: CodegenConfig = {
// ...
generates: {
'src/graphql/base-types.generated.ts': {
plugins: ['typescript']
},
'src/': {
preset: 'near-operation-file',
presetConfig: {
baseTypesPath: './graphql/base-types.generated.ts'
},
plugins: ['typescript-operations']
}
}
}
```

Now, it is still possible to reuse shared types, but with the decoupling from the `typescript` plugin, we can just use `typescript-operations` for both base type and operation type generation.

```typescript filename="codegen.ts"
const config: CodegenConfig = {
// ...
generates: {
'src/graphql/base-types.generated.ts': {
plugins: ['typescript-operations'],
config: {
generateOperationTypes: false
}
},
'src/': {
preset: 'near-operation-file',
plugins: ['typescript-operations'],
config: {
importSchemaTypesFrom: 'src/graphql/base-types.generated.ts'
}
}
}
}
```

Alternatively, base types and operation types can all be generated into every near-operation file:

```typescript filename="codegen.ts"
const config: CodegenConfig = {
// ...
generates: {
'src/': {
preset: 'near-operation-file',
plugins: ['typescript-operations']
}
}
}
```

## Breaking changes

1. Object types are no longer generated
Expand Down
Loading