Skip to content

[@graphql-codegen/near-operation-file-preset@v5.2.0] codegen fails with "Unable to find template plugin matching 'add'" #1466

Description

@jlowcs

Which packages are impacted by your issue?

@graphql-codegen/near-operation-file-preset

Describe the bug

Summary

After bumping@graphql-codegen/near-operation-file-preset from 5.1.0 to 5.2.0 in our app, running codegen fails to resolve the add plugin, even though @graphql-codegen/add@^7.0.0 is declared as a direct dependency of our app.

Error

> graphql-codegen --config codegen.ts

✔ Parse Configuration
⚠ Generate outputs
  ❯ Generate to src/
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ✖
              Unable to find template plugin matching 'add'
              Install one of the following packages:

              - @graphql-codegen/add
              - @graphql-codegen/add-template
              - @graphql-codegen/add-plugin
              - graphql-codegen-add
              - graphql-codegen-add-template
              - graphql-codegen-add-plugin
              - codegen-add
              - codegen-add-template
              - add

Suspected cause

The bump from 5.1.05.2.0 triggered a large lockfile dedupe (30 insertions / 176 deletions in our pnpm-lock.yaml). Notably, several older transitive copies were dropped:

  • @graphql-codegen/add@6.0.1 (removed)
  • @graphql-codegen/plugin-helpers@6.3.0 (removed)
  • @graphql-codegen/visitor-plugin-common@6.3.0 (removed)

The new preset 5.2.0 likely now resolves plugins through its own module resolution path (e.g., @graphql-codegen/visitor-plugin-common@7.0.1), which no longer reaches the workspace's @graphql-codegen/add@7.0.0 declared in apps/front-end. The CLI's plugin loader walks require.resolve from the preset's location rather than the workspace root, so the directly-declared add dependency is invisible to it under pnpm's strict, non-hoisted layout.

I wonder if it's an issue of dependencies vs peerDependencies.

Environment

pnpm v10.14.0

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

N/A

Expected behavior

N/A

Screenshots or Videos

No response

Platform

  • OS: macOS
  • NodeJS: 24.11.0
  • pnpm: 10.14.0
  • @graphql-codegen/add: 7.0.0
  • @graphql-codegen/cli: 7.0.0
  • @graphql-codegen/near-operation-file-preset: 5.2.0
  • @graphql-codegen/typescript: 6.0.0
  • @graphql-codegen/typescript-operations: 6.0.0
  • @graphql-eslint/eslint-plugin: 4.4.0

Codegen Config File

{
overwrite: true,
schema: '[...]',
hooks: { afterAllFileWrite: ['pnpm oxfmt'] },
documents,
generates: {
'src/': {
preset: 'near-operation-file',
presetConfig: {
extension: '.graphql.d.ts',
baseTypesPath: '[...]',
},
plugins: [
'typescript-operations',
{
add: {
content: /* * This file is generated by graphql-codegen and should not be modified manually. * If you need to update this file, please run "pnpm codegen" (see also README). */ ,
},
},
],
config: {
addOperationExport: true,
skipTypename: true,
},
},
},
}

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions