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

[WIP] Introduce QueryComplexityCalculator to allow computing complexities outside of instrumentation #3217

Closed

Conversation

xuorig
Copy link

@xuorig xuorig commented May 16, 2023

Hey folks,

Opening this as a discussion rather than a complete implementation for now. We have use cases where it would be nice to be able to compute the complexity of documents outside of instrumentation. For example validating complexity on the registry of a persisted query.

The complexity calculation logic is rather simple at the moment and we could build our own using QueryTraverser, however I'd love for the logic to be consolidated somewhere outside an instrumentation. Thoughts on extracting some of the logic to its own QueryComplexityCalculator?

Example included in this PR.

@bbakerman
Copy link
Member

I am more the happy for the calculator to be moved out of the intrumentation code so it can be 1 re-used and 2 better tested

import static graphql.Assert.assertNotNull;
import static java.util.Optional.ofNullable;

public class QueryComplexityCalculator {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs @publicapi

@xuorig
Copy link
Author

xuorig commented Jun 28, 2023

Sorry for not coming back to this pr @bbakerman , and thank you for merging a similar solution 🙇

@xuorig xuorig closed this Jun 28, 2023
@bbakerman
Copy link
Member

Sorry for not coming back to this pr @bbakerman , and thank you for merging a similar solution 🙇

This is just your code cleaned up a fraction - thanks for the original idea

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 this pull request may close these issues.

None yet

2 participants