Skip to content

Add max depth option to ExecutableNormalizedOperationFactory #3268

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

Merged
merged 4 commits into from
Jul 12, 2023

Conversation

gnawf
Copy link
Contributor

@gnawf gnawf commented Jul 12, 2023

No description provided.

int curLevel,
int maxLevel) {
if (curLevel > maxLevel) {
throw new AbortExecutionException("Maximum query depth exceeded " + curLevel + " > " + maxLevel);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied this from MaxQueryDepthInstrumentation but let me know if I should make a more specific exception class.

Copy link
Member

Choose a reason for hiding this comment

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

This makes sense - this is our stop exception class

@@ -23,7 +23,7 @@ public class FieldCollectorNormalizedQueryParams {
private final GraphQLContext graphQLContext;
private final Locale locale;

public List<PossibleMerger> possibleMergerList = new ArrayList<>();
private final List<PossibleMerger> possibleMergerList = new ArrayList<>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason for it to be public or not-final. The class is marked as@Internal so shouldn't break anything.

@@ -64,6 +65,50 @@
*/
@PublicApi
public class ExecutableNormalizedOperationFactory {
public static class Options {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this new Options class which mimicks the Options pattern seen in the repo.

This stores things not directly related to the operation info.

@gnawf
Copy link
Contributor Author

gnawf commented Jul 12, 2023

Adding this code so we can remove reliance on QueryTraverser in the gateway.

public int getMaxChildrenDepth() {
return maxChildrenDepth;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice one!

but can we have some javadoc on what they do please since its API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 😄

public List<PossibleMerger> getPossibleMergerList() {
return possibleMergerList;
}

Copy link
Member

Choose a reason for hiding this comment

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

nice one

Copy link
Member

@dondonz dondonz left a comment

Choose a reason for hiding this comment

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

Great!

@dondonz dondonz added this pull request to the merge queue Jul 12, 2023
Merged via the queue into graphql-java:master with commit fa8cf1b Jul 12, 2023
@dondonz dondonz added this to the 2023 October milestone Jul 12, 2023
Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

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

Great 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.

3 participants