-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Fix interfaces with duplicate directives #3674
Conversation
Reviewer's Guide by SourceryThis pull request addresses a bug where directives were being added multiple times, causing VSCode errors. The fix involves deduplicating directives when applying permissions to a field, ensuring that each directive is only added once. Class diagram for StrawberryField directive handlingclassDiagram
class StrawberryField {
+List~Directive~ directives
}
class Permission {
+Directive schema_directive
}
class PermissionHandler {
+apply(field: StrawberryField) void
}
PermissionHandler --> StrawberryField : apply
PermissionHandler --> Permission : uses
note for StrawberryField "Field directives are now deduplicated when applying permissions."
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
for more information, see https://pre-commit.ci
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 @Speedy1991 - I've reviewed your changes - here's some feedback:
Overall Comments:
- The fix looks good, but please include the test you mentioned (using the sandbox setup) in this PR to ensure the bug doesn't resurface in the future.
- Consider if any user-facing documentation needs to be updated to reflect this fix, especially if users might have encountered this issue before.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Thanks for adding the Here's a preview of the changelog: This release addresses a bug where directives were being added multiple times when defined in an interface which multiple objects inherits from. The fix involves deduplicating directives when applying extensions/permissions to a field, ensuring that each directive is only added once. Here's the tweet text:
|
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 ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3674 +/- ##
=======================================
Coverage 97.01% 97.02%
=======================================
Files 503 503
Lines 33458 33492 +34
Branches 5618 5626 +8
=======================================
+ Hits 32460 32495 +35
+ Misses 792 791 -1
Partials 206 206 |
CodSpeed Performance ReportMerging #3674 will not alter performanceComparing Summary
|
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 @Speedy1991 ,
Thank you very much for this!
Could we have a test for this to avoid any future regressions?
yea, i wasn't sure if refactoring the directives from a list to a set would be a more stable fix, see this comment:
|
Refactoring it into a |
Hm I think I need to refactor this a littlebit if the order matters, because the current fix cast the lists to sets and calculates the difference. As far i know casting to/from a set does not guarantee to keep the order. |
Good point, I actually missed that (even though I commented about this same very issue lol) |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
@bellini666 I refactored the code to keep the order + added a test with a permission class. |
Description
Directives are added multiple times leading to VSC errors like
The directive "@featuresRequired" can only be used once at this location.
Another option to fix this would be to make field.directives a
set
but this is used on multiple places and I don't think it's worth the rework. If the fix is ok for you I'll add a test with e.g. this sandbox setupTypes of Changes
Issues Fixed or Closed by This PR
Checklist
Summary by Sourcery
Fix the issue of multiple directives being added to a field by deduplicating permission directives before extending the field's directives list.
Bug Fixes:
Enhancements: