feat(demand-control): allow maxCost to accept a dynamic function#2133
Draft
feat(demand-control): allow maxCost to accept a dynamic function#2133
maxCost to accept a dynamic function#2133Conversation
…cost limiting Adds a new `DemandControlMaxCostPayload` interface and allows `maxCost` in `DemandControlPluginOptions` to accept a sync or async function that receives the `operationCost`, `totalCost`, `subgraphName`, and `executionRequest` and returns the maximum allowed cost. This lets users implement dynamic cost limiting (e.g., per-user or per-subgraph limits) and access the estimated cost before a request is sent to the subgraph. Re-exports `DemandControlMaxCostPayload` from the main package types for consumers to use when typing their `maxCost` functions. Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add estimated operation cost during onSubgraphExecute hook
feat(demand-control): allow Mar 19, 2026
maxCost to accept a dynamic function
Copilot stopped work on behalf of
ardatan due to an error
March 19, 2026 22:04
Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
Collaborator
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-hive/gateway |
2.5.12-alpha-bb7cb0747a2f268a4a03e2f7f7f2ccd1364ded49 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/nestjs |
2.0.53-alpha-bb7cb0747a2f268a4a03e2f7f7f2ccd1364ded49 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/plugin-opentelemetry |
1.4.9-alpha-bb7cb0747a2f268a4a03e2f7f7f2ccd1364ded49 |
npm ↗︎ unpkg ↗︎ |
@graphql-mesh/plugin-prometheus |
2.1.28-alpha-bb7cb0747a2f268a4a03e2f7f7f2ccd1364ded49 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/gateway-runtime |
2.8.0-alpha-bb7cb0747a2f268a4a03e2f7f7f2ccd1364ded49 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/gateway-testing |
7.0.0-alpha-bb7cb0747a2f268a4a03e2f7f7f2ccd1364ded49 |
npm ↗︎ unpkg ↗︎ |
Collaborator
Collaborator
Collaborator
Collaborator
Collaborator
Collaborator
🚀 Snapshot Release (Bun Docker Image)The latest changes of this PR are available as image on GitHub Container Registry (based on the declared |
Collaborator
🚀 Snapshot Release (Node Docker Image)The latest changes of this PR are available as image on GitHub Container Registry (based on the declared |
…pes.ts Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
maxCostFnat plugin initialization (done in previous session)@typescript-eslint/no-explicit-anydisable comment fromuseDemandControl.tsuseDemandControl.ts(@whatwg-node→~internal/env→graphql)maxCost?:union type to multi-line inuseDemandControl.tsDemandControlPluginOptionsto single line intypes.tsexport type { DemandControlMaxCostPayload }after all imports intypes.tsOriginal prompt
onSubgraphExecutehook #1389📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.