Fix create and update nested relational items marked as required instead of optional#25835
Fix create and update nested relational items marked as required instead of optional#25835br41nslug merged 11 commits intodirectus:mainfrom
Conversation
|
Yes, of course! I updated the functions you mentioned. I also found these functions which were not on your list, but are
|
|
I indeed left a couple out because they have no real relations in them (some like notification do have a user relation but its not really expected to be creating the user while creating a notification) |
Co-authored-by: daedalus <[email protected]>
That’s understandable. My only concern is that this makes the SDK a bit opinionated about how developers “should” use Directus. I’d argue the SDK should support any usage the API itself allows, even if it’s uncommon. This feels especially important because system collections, even those without default relations, can be extended with relations to custom collections. I’ve used Directus in some unusual setups myself, and it would be frustrating to switch to the SDK only to find that nested create/updates sometimes work, but not always. That’s essentially why I opened this PR, because the API supports a documented feature, but the SDK didn’t always allow it. Extending NestedPartial consistently across all collections where the API supports it would prevent similar issues from cropping up again. Right now the changes in this PR feel inconsistent, since most Of course the decision is yours, I just wanted to share my perspective. Happy to update those extra functions if you think this reasoning holds, or leave them as is if not. |
This comment was marked as outdated.
This comment was marked as outdated.
br41nslug
left a comment
There was a problem hiding this comment.
I have 1 final type change I'd want fixed and a nitpick on the changeset when those are resolved im happy to merge this! Thanks in advance for improving the consistency in the SDK types ❤️
…ead of optional (directus#25835) * Changes createItem type to NestedPartial; fixes directus#21212 * Updates changeset * Adds `NestedPartial` to more POST/PATCH functions * Update .changeset/beige-lamps-relate.md Co-authored-by: daedalus <[email protected]> * Update .changeset/beige-lamps-relate.md * Fixes sdk item type on additional `POST` and `PATCH` functions * Update .changeset/beige-lamps-relate.md Co-authored-by: Brainslug <[email protected]> * Removes unintended non-nullish type for `data` * Update sdk/src/rest/commands/update/singleton.ts --------- Co-authored-by: daedalus <[email protected]> Co-authored-by: Brainslug <[email protected]>
Scope
Changes SDK
createItemitem type fromitem: Partial<UnpackList<Schema[Collection]>>toitem: NestedPartial<UnpackList<Schema[Collection]>>, to address #21212 and bryantgillespie/directus-sdk-typegen#15.Potential Risks / Drawbacks
N/A -- This just makes nested (relational) properties partial, instead of only the top-level item properties, so that items can be created using this structure on the docs.
Tested Scenarios
I do not think any test or docs updates are required.