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
StrawberryResolver object #543
StrawberryResolver object #543
Conversation
… changes broken enum tests and async tests Will resolve shortly
Codecov Report
@@ Coverage Diff @@
## master #543 +/- ##
==========================================
+ Coverage 97.54% 97.68% +0.13%
==========================================
Files 63 64 +1
Lines 1916 1943 +27
Branches 278 272 -6
==========================================
+ Hits 1869 1898 +29
+ Misses 24 23 -1
+ Partials 23 22 -1 |
|
We need to double check why this codepaths aren't tested anymore: https://codecov.io/gh/strawberry-graphql/strawberry/pull/543/src?path=types%2Ftypes.py#L311 |
…solver # Conflicts: # poetry.lock # strawberry/field.py
| @@ -44,8 +44,8 @@ | |||
| main:22: note: Revealed type is 'builtins.str' | |||
| main:23: note: Revealed type is 'builtins.str' | |||
| main:24: note: Revealed type is 'builtins.str' | |||
| main:25: note: Revealed type is 'def (self: main.Example, info: Any) -> builtins.str' | |||
| main:26: note: Revealed type is 'def (self: main.Example, info: Any) -> builtins.str' | |||
| main:25: note: Revealed type is 'strawberry.field.StrawberryField' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should all the fields have revealed types as StrawberryField? I anticipate being able to make StrawberryField generic so I think it could be
main:21: note: Revealed type is 'strawberry.field.StrawberryField[str]'
for each.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good question, that's only for the class? The instance types would still be 'builtins.str', right?
| @cached_property | ||
| def arguments(self) -> List[ArgumentDefinition]: | ||
| # TODO: Move to StrawberryArgument? StrawberryResolver ClassVar? | ||
| SPECIAL_ARGS = {"root", "self", "info"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured I'd turn this into a constant, but I wasn't quite sure where to put it. Not sure if it would be better within StrawberryResolver or the future StrawberryArgument
|
Thanks for adding the Here's a preview of the changelog:
|
This look brilliant! I'm going to test this on our code base just to make sure all works fine :)
…solver # Conflicts: # poetry.lock
Strawberry resolvers has been changed by pull request strawberry-graphql/strawberry#543. This change has been done in v0.42.0
| @@ -33,6 +33,7 @@ typing_extensions = "^3.7.4" | |||
| opentelemetry-api = {version = "^0.13b0",optional = true} | |||
| opentelemetry-sdk = {version = "^0.13b0",optional = true} | |||
| python-dateutil = "^2.7.0" | |||
| cached-property = "^1.5.2" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason to use this library instead of functools.cached_property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to use that, but we still support python 3.7. The library is basically a backport (well actually the library came first and then was added to the stdlib iirc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed that. Thanks



Description
Wrap resolvers in a custom class. This is the first step towards implementing #489.
Types of Changes
Issues Fixed or Closed by This PR
Checklist