Skip to content

August 20, 2024

Compare
Choose a tag to compare
@theguild-bot theguild-bot released this 20 Aug 17:13
· 17 commits to main since this release
04cf1b0

@envelop/core@5.0.2

Patch Changes

@envelop/on-resolve@4.1.1

Patch Changes

  • #2292
    c3dd2c3
    Thanks @ardatan! - Refactor the plugin to avoid extra promises with
    `mapMaybePromise`

  • Updated dependencies
    [c3dd2c3]:

    • @envelop/core@5.0.2

@envelop/rate-limiter@6.2.0

Minor Changes

  • #2292
    c3dd2c3
    Thanks @ardatan! - Now you can define a custom string interpolation
    function to be used in the rate limit message. This is useful when you want to include dynamic
    values in the message.

    useRateLimiter({
      configByField: [
        {
          type: 'Query',
          field: 'search', // You can also use glob patterns
          max: 10,
          window: '1m',
          message:
            'My custom message with interpolated values: ${args.searchTerm} and ${context.user.id}'
        }
      ],
      interpolateMessage: (message, args, context) => {
        return message.replace(/\${(.*?)}/g, (_, key) => {
          return key.split('.').reduce((acc, part) => acc[part], { args, context })
        })
      }
    })
  • #2292
    c3dd2c3
    Thanks @ardatan! - New directive SDL;

    directive @rateLimit(
      max: Int
      window: String
      message: String
      identityArgs: [String]
      arrayLengthField: String
      readOnly: Boolean
      uncountRejected: Boolean
    ) on FIELD_DEFINITION
  • #2292
    c3dd2c3
    Thanks @ardatan! - Programmatic API to define rate limit
    configuration in addition to directives

    useRateLimiter({
      configByField: [
        {
          type: 'Query',
          field: 'search', // You can also use glob patterns
          max: 10,
          window: '1m'
        }
      ]
    })

Patch Changes