graphql-hive / graphql-hive/envelop

Unable to customize the thrown rate limit error.

Open
#2,822 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
827
Forks
132
PR merge metrics
No merged PRs in 30d

Description

### Issue workflow progress

_Progress of the issue based on the
[Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-contributor-workflow)_

- [ ] 1. The issue provides a
[minimal reproduction](https://en.wikipedia.org/wiki/Minimal_reproducible_example) available on
[Stackblitz](https://stackblitz.com/fork/node).
- _Please install the latest `@envelop/*` packages that you are using._
- _Please make sure the reproduction is as small as possible._
- [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review

---

**Describe the bug**

The documentation for @envelop/rate-limiter says:

```
All options available to the graphql-rate-limit getGraphQLRateLimiter function may also be passed into useRateLimiter.

You can find more details here: https://github.com/teamplanes/graphql-rate-limit#readme
```

However, this does not appear to be true for 2 reasons:
- This project (no longer?) imports and references graphql-rate-limit
- The available settings for this object do not respond to `createError` that the above uses.
- I'm unclear if this is even intentional. When I install @envelop/rate-limiter@9.0.0, I get typescript type defs specifying that `createError` is a valid option, but the actual code seems to not have this ([here](https://github.com/graphql-hive/envelop/blob/d9aece243674a313c8c9632241e31de5379ae650/packages/plugins/rate-limiter/src/types.ts#L78) and [here](https://github.com/graphql-hive/envelop/blob/d9aece243674a313c8c9632241e31de5379ae650/packages/plugins/rate-limiter/src/index.ts#L89)

**To Reproduce** Steps to reproduce the behavior:

1. Configure a rateLimiter with the `createError` option set to throw a custom error
2. Trigger a rate limit event.

**Expected behavior**

createError is used to allow customization of the error.

**Environment:**

- OS: 6.18.2-arch2-1
- NodeJS: v24.12.0
- `@envelop/*` versions:
- `@envelop/core`: `5.4.0`
- `@envelop/rate-limiter`: `9.0.0`

**Additional context**

Using with `graphql-yoga@5.18.0`

I need to customize the error logic, as graphql-yoga expects the status code to be reported with the `status` property in `extensions.http` ([see here](https://the-guild.dev/graphql/yoga-server/docs/features/error-masking#modifying-http-status-codes-and-headers)), but this plugin is [using statusCode](https://github.com/graphql-hive/envelop/blob/d9aece243674a313c8c9632241e31de5379ae650/packages/plugins/rate-limiter/src/index.ts#L302)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.