Closed fireteam99 closed 1 year ago
+1 (I agree with bug
label)
here is the patch to correct this:
Index: strawberry_django/filters.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/strawberry_django/filters.py b/strawberry_django/filters.py
--- a/strawberry_django/filters.py (revision b9c2127a179f26df05ccfe1830f35c7f42908d09)
+++ b/strawberry_django/filters.py (revision c6bd0a1b81c4cd370106c3d0059360296c730215)
@@ -182,7 +182,7 @@
filters = self.get_filters()
if self.django_model and not self.is_list:
if self.is_relation is False:
- arguments.append(argument("pk", strawberry.ID))
+ arguments.append(argument("pk", strawberry.ID, is_optional=False))
elif filters and filters is not UNSET:
arguments.append(argument("filters", filters))
return super().arguments + arguments
here is the pull request (test passes) https://github.com/strawberry-graphql/strawberry-graphql-django/pull/214
@fireteam99 the pull request i made to correct this is merged. You can test it. If OK you can close this issue.
I'll close the issue, considering that the PR fixed it. If that's not the case we can reopen it :)
@stygmate thanks for fixing!
Describe the Bug
Given the following code:
Will generate the following schema:
When it should probably generate:
If you accidentally forget to pass the
pk
argument you will get a slightly more misleadingget() returned more than one Foo -- it returned xyz!
System Information
Additional Context
Upvote & Fund