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

count_introspection_fields for max_complexity #4873

Closed
jstrojil opened this issue Mar 5, 2024 · 2 comments · Fixed by #4939
Closed

count_introspection_fields for max_complexity #4873

jstrojil opened this issue Mar 5, 2024 · 2 comments · Fixed by #4939

Comments

@jstrojil
Copy link

jstrojil commented Mar 5, 2024

Currently, count_introspection_fields is only supported for max_depth.

Also, overriding complexity calculation doesn't work for introspection, it seems that this is never called.

      def calculate_complexity(query:, nodes:, child_complexity:)

Would be nice to find a way how to support both, max_depth and max_complexity.

Thanks a lot

@rmosolgo
Copy link
Owner

rmosolgo commented Mar 6, 2024

Hey, thanks for reporting this. I agree that complexity should handle introspection similar to depth. I'm not sure why that method is skipped for introspection fields... I would have guessed that it worked the same as anything else!

Feel free to take a try at addressing this if you have time before I do, otherwise, I'll follow up here after I make time to investigate.

@rmosolgo
Copy link
Owner

Hey, I added that new option, in #4939.

Also, I added a spec for complexity_for in 3afe931. It "works" -- but you have to set up your base field class using field_class. Also, I discovered some weirdness where you have to use GraphQL::Schema::LateBoundType.new(...) in order to use the built-in types from GraphQL-Ruby. If you reference them directly, it doesn't work.

I hope one of those options works for you -- please let me know if it doesn't!

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.

2 participants