-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Feature: Add setting DEFAULT_PK_FIELD_NAME #446
Feature: Add setting DEFAULT_PK_FIELD_NAME #446
Conversation
Signed-off-by: Noam Stolero <nstolero@barracuda.com>
Signed-off-by: Noam Stolero <nstolero@barracuda.com>
@bellini666 I can add more tests if you think are needed. Also, need your help regarding this: https://github.com/strawberry-graphql/strawberry-graphql-django/pull/446/files#diff-87c07c1c9f6db39e2dacd257d14f3123d74b65d0a1db4029364d69f4a707013cR55 |
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.
@noamsto I think this is mostly fine, and I commented on the issue you requested my attention, although I'm not sure it is the correct option in there
@@ -28,6 +30,7 @@ | |||
) | |||
|
|||
_T = TypeVar("_T") | |||
settings = strawberry_django_settings() |
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.
Ditto
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 was thinking,
Maybe it's redundant here?
Anyway key_attr
is propagating to DjangoMutationCUD
and there it will be handled for Update and Delete right?
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #446 +/- ##
==========================================
- Coverage 87.73% 87.71% -0.02%
==========================================
Files 37 37
Lines 3130 3143 +13
==========================================
+ Hits 2746 2757 +11
- Misses 384 386 +2 ☔ View full report in Codecov by Sentry. |
for more information, see https://pre-commit.ci
Signed-off-by: Noam Stolero <nstolero@barracuda.com>
Signed-off-by: Noam Stolero <nstolero@barracuda.com>
337f1ee
to
f1575b6
Compare
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.
Looking good! :)
I think the only thing missing is is the DjangomodelFilterInput
I was thinking about it and probably what we want to do it to create it dynamically if DEFAULT_PK_FIELD_NAME != "pk"
like I suggested at the point where it is being used (it is only used in one place) and save it in a global variable for further usage.
What do you think?
I don't mind doing that, though the usage is in a different file; defined in: It is also used in |
@bellini666 , I need to revisit all the occurrences and see what are necessary changes:
If you think there are places which I mentioned that irrelevant please tell. I added Mutation test and might add others as well as I progress. It might take me a while. |
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.
Hey @noamsto - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 5 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 5 issues found
- 🟢 Complexity: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
This PR was inspired by #159.
I took a different approach which is less granular but easier to implement.
If a fine-grain control is needed it can be implemented in the future.
Description
Add a
DEFAULT_PK_FIELD_NAME
setting which default to"pk"
.This should affect all builtin Django CRUDs, and is backward compatible.
Types of Changes
Issues Fixed or Closed by This PR
Checklist