@envelop/rate-limiter
Changelog for @envelop/rate-limiter: every release with its changes and the pull requests behind them.
11.0.0
Major Changes
-
#4574
79b0e8bThanks @egoodwinx! - ### Breaking Changes- Node: minimum supported version is now Node 22. Node 18 and 20 are no longer supported. Future releases will only support Node >=22.
- GraphQL: minimum supported version is now GraphQL 16. GraphQL 14 and 15 are no longer supported.
- Request body parsing: Yoga now limits request bodies to 25,000,000 bytes by default.
Enforcing this limit streams the body through a byte counter, making POST body parsing
asynchronous even for an in-memory body. As a result,
yoga.fetch()can return a Promise where it previously returned a synchronous Response, even when all resolvers and plugins are synchronous.
Migration
- If you’re on Node 18/20, upgrade to Node 22 or later before upgrading this package.
- If you’re on graphql 14/15, upgrade to graphql 16 or 17 first.
- Await
yoga.fetch()and response body parsing instead of relying on synchronous results. SetmaxRequestBodySize: falseincreateYogato disable the body-size limit and preserve synchronous parsing for in-memory bodies, but only if you enforce an appropriate request-body limit elsewhere.
-
#4623
be89d05Thanks @ardatan! - ### Dependencies- Bump
@graphql-tools/utilsto^13.1.1,@graphql-tools/schemato^11.0.0, and@graphql-tools/executorto^4.1.2.
Incremental delivery
Yoga maps the GraphQL HTTP
Acceptheader throughINCREMENTAL_DELIVERY_SPECSfrom@graphql-tools/utilsonto executorincrementalSpec.multipart/mixed;incrementalSpec=v0.2runs the v0.2 payload format and echoes that spec onContent-Type.multipart/mixed;deferSpec=20220824or baremultipart/mixedstays on v0.1. An unsupported incremental spec yields 406.A later incremental spec is a graphql-tools table row plus an executor publisher. Yoga, Hive Gateway, and HTTP executors pick it up by bumping
@graphql-tools/utils/@graphql-tools/executor.Breaking Changes
createGraphQLErroris removed. Usenew GraphQLError(message, options)fromgraphql. To attach Yoga’s experimental schema coordinate, usewithSchemaCoordinate(error, coordinate)and read withgetSchemaCoordinatefrom@graphql-tools/utils.mapMaybePromiseis removed (was exported from Yoga /@envelop/core). UsehandleMaybePromisefrom@whatwg-node/promise-helpers.- Yoga no longer re-exports helpers that already live upstream:
getSchemaCoordinate->@graphql-tools/utilsmergeSchemas->@graphql-tools/schemaDisposableSymbols->@whatwg-node/servermapAsyncIterator/isPromise/fakePromise/handleMaybePromise/MaybePromise->@whatwg-node/promise-helpers
@envelop/coreutilsno longer re-exportsmapAsyncIteratororisPromise. Import from@whatwg-node/promise-helpers.- Use
asGetArgumentValuesVariables/coerceGetVariableValuesResultfrom@graphql-tools/utilsfor GraphQL 16/17VariableValuescompatibility.
Migration
import { GraphQLError } from 'graphql' import { withSchemaCoordinate } from 'graphql-yoga' import { mergeSchemas } from '@graphql-tools/schema' import { getSchemaCoordinate } from '@graphql-tools/utils' import { handleMaybePromise, isPromise, type MaybePromise } from '@whatwg-node/promise-helpers' import { DisposableSymbols } from '@whatwg-node/server' throw withSchemaCoordinate(new GraphQLError('not found'), 'Query.user') - Bump
Patch Changes
- Updated dependencies
[
862447a,79b0e8b,be89d05,79b0e8b]:- @envelop/core@6.0.0
- @envelop/on-resolve@8.0.0
10.2.3
Patch Changes
- #4607
d8b8860Thanks @enisdenjo! - dependencies updates:- Updated dependency
@graphql-tools/utils@^12.0.3↗︎ (from^11.2.2, independencies)
- Updated dependency
10.2.2
Patch Changes
- #4604
c6febdcThanks @enisdenjo! - dependencies updates:- Updated dependency
@graphql-tools/utils@^11.2.2↗︎ (from^11.2.0, independencies)
- Updated dependency
10.2.1
Patch Changes
-
#4577
7bff35cThanks @egoodwinx! - Add homepage and bugs.url to package.json files -
Updated dependencies [
7bff35c]:- @envelop/on-resolve@7.2.1
- @envelop/core@5.6.1
10.2.0
Minor Changes
-
#4545
94ebe5bThanks @egoodwinx! - Update to support graphql-js 17Bump package versions, fix expected typing, and update compatability with subscribe.
Patch Changes
- Updated dependencies
[
94ebe5b]:- @envelop/on-resolve@7.2.0
- @envelop/core@5.6.0
10.1.0
Minor Changes
-
#4530
62c2cd1Thanks @enisdenjo! - Field config now accepts anidentifiertemplate string as a lightweight alternative toidentifyFnSupports
{args.argName}and{context.propName}dot-path interpolation, equivalent to using@rateLimit(identityArgs: [...])via the directive but available in programmatic config.useRateLimiter({ identifyFn: ctx => ctx.ip, configByField: [ { type: 'Query', field: 'getProduct', window: '1m', max: 10, identifier: '{args.id}' }, { type: 'Query', field: 'search', window: '1m', max: 30, identifier: '{context.ip}' } ] }) -
#4530
62c2cd1Thanks @enisdenjo! -identifyFnnow receives field argument values as a second parameter when used viaconfigByFieldThe per-field
identifyFnonConfigByFieldreceives the resolved argument values, making it straightforward to rate limit unauthenticated requests by argument value without a directive.useRateLimiter({ identifyFn: ctx => ctx.ip, configByField: [ { type: 'Query', field: 'getProduct', // getProduct(id: ID!): Product! window: '1m', max: 10, identifyFn: (ctx, args) => String(args.id) } ] })Note: the root
identifyFnalso receives args as a second parameter when it acts as the fallback for aconfigByFieldentry, but args will be empty when it is invoked for directive-based rate limiting.