Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Connections in cost complexity calculation #761

Open
freshjsw opened this issue Feb 8, 2025 · 0 comments · May be fixed by #762
Open

Support Connections in cost complexity calculation #761

freshjsw opened this issue Feb 8, 2025 · 0 comments · May be fixed by #762

Comments

@freshjsw
Copy link

freshjsw commented Feb 8, 2025

The cost complexity cost-limit plugin does not take into account how many entities are being returned when either the first or last argument are specified at the field level.

These two examples which have the same complexity cost (I have omitted edges and pageInfo to keep these examples simple)

query simpleQuery {
      books {
        title
        author
      }
}

query connectionQuery {
      books(first: 1) {
        title
        author
      }
}

The cost complexity of this query should increase by a factor of the number of books requested

query connectionQuery {
      books(first: 3) {
        title
        author
      }
}

I have a PR that modifies the computeComplexity function in packages/plugins/cost-limit/src/index.ts/ to factor this in to the complexity cost algorithm.

Note the PR does not currently handle VariableDefinitions but will handle the example above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant