[WIP] Introduce `QueryComplexityCalculator` to allow computing complexities outside of instrumentation by xuorig · Pull Request #3217 · graphql-java/graphql-java · GitHub
Skip to content

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

Closed
xuorig wants to merge 1 commit into
graphql-java:masterfrom
xuorig:query-complexity-calculator
Closed

[WIP] Introduce QueryComplexityCalculator to allow computing complexities outside of instrumentation#3217
xuorig wants to merge 1 commit into
graphql-java:masterfrom
xuorig:query-complexity-calculator

Conversation

@xuorig

@xuorig xuorig commented May 16, 2023

Copy link
Copy Markdown

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
Copy Markdown
Member

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

public class QueryComplexityCalculator {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs @publicapi

@xuorig

xuorig commented Jun 28, 2023

Copy link
Copy Markdown
Author

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
Copy Markdown
Member

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.

2 participants