HarperFast / HarperFast/apollo

ERR_REQUIRE_ESM when using graphql-query-complexity complexity hooks in ESM projects

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
bug from-jira
Dominant language
JavaScript
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Description

A customer reports `ERR_REQUIRE_ESM` when trying to implement GraphQL query complexity limiting (via `graphql-query-complexity`) alongside `@harperdb/apollo` in a project that uses `"type": "module"`.

## Symptoms

The error occurs during the complexity hook implementation despite consistent ESM usage throughout the codebase (`"type": "module"` in `package.json`, all `import`/`export` syntax). Suspected cause: a CommonJS boundary somewhere in the `@harperdb/apollo` or its dependencies that fails when loaded from an ESM context.

## Relevant stack

- `@harperdb/apollo: ^1.2.0`
- `graphql-query-complexity: ^1.1.0`
- `graphql: ^16.7.1`
- Full ESM project (`"type": "module"`)

## Ask

- Document the correct import pattern for `@harperdb/apollo` from an ESM project.
- If the package ships CJS only, either add an ESM entry point or document the conditional import workaround.
- If `graphql-query-complexity` is the CJS culprit, add a note in the docs about compatible versions / the dynamic-import pattern.

---

🤖 Filed by Claude on behalf of Kris.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.