feat: Type and Query complexity callbacks#273
Merged
zachdaniel merged 3 commits intoash-project:mainfrom Feb 11, 2025
Merged
Conversation
A custom complexity callback can be provided for a type to be used when that type is resolved through a relationship. A query-level complexity callback applies when the resource has a top-level query in the schema.
mbuhot
commented
Feb 10, 2025
zachdaniel
reviewed
Feb 10, 2025
| default: [] | ||
| ], | ||
| complexity: [ | ||
| type: :mod_arg, |
Contributor
There was a problem hiding this comment.
Suggested change
| type: :mod_arg, | |
| type: :mfa, |
I think we should make these MFAs.
zachdaniel
reviewed
Feb 10, 2025
Contributor
zachdaniel
left a comment
There was a problem hiding this comment.
Looks great! I think we should make these MFAs instead of just mod/fun pairs (hardcoded args get prepended to our arguments). That allows better reuse, i.e complexity {MyApp.Complexity, :complexity, [__MODULE__, :very_complex]} etc.
Contributor
Author
|
@zachdaniel I'm having some trouble forwarding the MFA through to Absinthe: It looks like only functions, {mod, fun} tuples and constants are supported: |
Contributor
|
Ah, right you are. I had a similar complication at some point in the past and did some super hacky shit to get around it. In that case, never mind 😄 |
Contributor
|
Please run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #270
A custom complexity callback can be provided for a type to be used when that type is resolved through a relationship.
A query-level complexity callback applies when the resource has a top-level query in the schema.
Contributor checklist