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
Add privateAttributes to global and per model response #7331
Add privateAttributes to global and per model response #7331
Conversation
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #7331 +/- ##
==========================================
+ Coverage 27.16% 27.21% +0.04%
==========================================
Files 1163 1164 +1
Lines 15518 15519 +1
Branches 2410 2411 +1
==========================================
+ Hits 4216 4223 +7
+ Misses 9534 9528 -6
Partials 1768 1768
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Any chance of getting a review before there are more conflicts? Thank you. @Convly |
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 globally good.
Some questions/concerns about the ignoreGlobalPrivateAttributes
attribute.
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Changes done! Hope it's all OK. @Convly |
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.
Almost there!
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Hello @Convly. I've done the changed you requested.
I decided to add another helper for the ignored private attributes ( About the GraphQL plugin, I've never used GraphQL. So I've been guessing how the function works thanks to the way it was done on the previous PR (#6002). Also, there was no tests for this code, so I had no way to test it. I would appreciate if you could tell me if everything is ok. I'll try to read more about GraphQL and I'll try to test if this code works as it should. |
Would love to see this feature merged as without it there is often too much unnecessary response data and insights (when was something created/updated) especially with auto populating relationships. |
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.
It looks good to me. Thanks again for your contribution, we really appreciate that!
However, before merging this, I would like to have feedback from @alexandrebodin both on ignorePrivateFor
and the GraphQL modifications.
Even if I can't give you a precise ETA for this review, it should be during next week.
I hope you can understand, have a good day! 🙂
Hope it gets merged soon! Would be really helpful. Have a good day! :D |
Alex is currently out of the office until next week, after which I'm sure he will get some time to review it. 😃 |
Hi @Convly @derrickmehaffy, are there any updates on this? Thank you. |
Sorry Alex had a lot to catch up on, if he doesn't respond by tmrw I'll try and poke him ;) |
Hi, This looks pretty good but I think there is one point I want to change to simplify the usage. I think we should remove the One more thing: I would just like to see the utils in the ContentType utils in strapi-utils to be reused in graphql and in the core instead of having to duplicate the logic :) Thanks for the work ! |
Hi @alexandrebodin,
I do agree with you that it is better to add fields locally only, but it might happen that someone might need to exclude an specific global private attribute in only 1 model. This wouldn't follow the DRY principle, as you would end up adding that attribute to all the other models individually. That's just my opinion, but if you believe it should be removed I'll do it.
I didn't know that was possible. How should I import the const { sanitizeEntity } = require('strapi-utils'); Also, what do you mean with |
For now I would rather not add too many options :)
You can export the utils like |
@alexandrebodin I'll work on the changes this weekend and it should be ready for review on Monday. |
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Signed-off-by: Diego Albitres <diego.albitres@gmail.com>
Hi @alexandrebodin. I've done the changes you requested. Is there anything else missing to merge this PR? |
Hi, @alexandrebodin. Have you had any chance to review the latest changes? Is there anything else needed? |
@derrickmehaffy can you check if the doc is good for you ? |
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 looks awesome, docs are great and I am already seeing a spot we can set the default limit
now also in ./config/api.js
:P
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.
LGTM
thank you @dalbitresb12 for implementing this feature and sticking with it 🚀 |
@alexandrebodin Do you have an approximate release date for 3.2.0? |
Hello @dalbitresb12, 3.1.6 has been released and includes the |
This pull request has been mentioned on Strapi Community. There might be relevant details there: https://forum.strapi.io/t/privateattributes-not-working-in-my-model/171/2 |
Description of what you did:
Restarting the work made from PR's #6002 and #4914. Also added the option to ignore the global private attributes per model using
options.ignoreGlobalPrivateAttributes
. Finally, new tests were added for sanitizeEntity.Fixes #4342.
(I previously opened another PR for the same (#7330), but I forgot the sign for DCO. Force-pushing didn't seem to work, so I opened a new one.)