-
-
Notifications
You must be signed in to change notification settings - Fork 537
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
wip: Initial work for first class pydantic usage #3268
base: main
Are you sure you want to change the base?
wip: Initial work for first class pydantic usage #3268
Conversation
) | ||
) | ||
|
||
return fields |
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.
the code itself is quite simple for now!
# Or just store them in a dict rather than on the model itself. | ||
@pytest.mark.xfail(reason="Need to fix this") | ||
def test_both_output_and_input_type(): | ||
@first_class(name="WorkInput", is_input=True) |
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.
marked failing things in test_basic.py with xfail
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.
One problem is when your pydantic type needs to be both a Input and Output type. Now you can't mark them with the same decorator - because that will override the existing __strawberry_definition__
.
Hi, thanks for contributing to Strawberry 🍓! We noticed that this PR is missing a So as soon as this PR is merged, a release will be made 🚀. Here's an example of Release type: patch
Description of the changes, ideally with some examples, if adding a new feature. Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :) Here's the tweet text:
|
1 similar comment
Hi, thanks for contributing to Strawberry 🍓! We noticed that this PR is missing a So as soon as this PR is merged, a release will be made 🚀. Here's an example of Release type: patch
Description of the changes, ideally with some examples, if adding a new feature. Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :) Here's the tweet text:
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3268 +/- ##
==========================================
- Coverage 96.60% 96.40% -0.20%
==========================================
Files 482 486 +4
Lines 29954 30633 +679
Branches 3694 3783 +89
==========================================
+ Hits 28937 29533 +596
- Misses 833 915 +82
- Partials 184 185 +1 |
CodSpeed Performance ReportMerging #3268 will not alter performanceComparing Summary
|
class Query: | ||
@strawberry.field | ||
def user(self) -> User: | ||
return User(id=1, name="Patrick") |
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.
this is how you use the api @patrick91 .
- decorate it
- Return it in your Query class
1cb57b7
to
a4bc9ae
Compare
for more information, see https://pre-commit.ci
reason="""No way to manually handle errors | ||
the validation goes boom in convert_argument, not in the create_user resolver""" | ||
) | ||
def test_mutation_with_validation_and_error_type(): |
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.
issue 2: no way to manually handle validation errors for now
Initial work that allows you to use pydantic classes out of the box, without converting it into a strawberry dataclass type.
Start of #2181
What works
What doesn't work (Alot of things, don't use this yet)
What is tested so far
Two issues I encountered while implementing
__strawberry_definition__
. When you register it as a input type, and after an output type, that original definition for the input type gets overwritten. wip: Initial work for first class pydantic usage #3268 (comment)Description
Types of Changes
Issues Fixed or Closed by This PR
Checklist