Skip to content

Forcefully add special subproperties to the selection of RichText, file, and role fields#852

Merged
MillanWangGadget merged 1 commit intomainfrom
mill/forceProperSelectionForSpecialFields
Mar 18, 2026
Merged

Forcefully add special subproperties to the selection of RichText, file, and role fields#852
MillanWangGadget merged 1 commit intomainfrom
mill/forceProperSelectionForSpecialFields

Conversation

@MillanWangGadget
Copy link
Contributor

  • UPDATE
    • Previously, passing in a select override could have some friction if you selected richText, role, or file fields.
      • {richTextField: true, fileField:true, roleField:true} would lead to errors
      • Selections like this were needed instead to make things work
        • {richText:{markdown: true, truncatedHTML: true}, }
        • {fileField: {url: true, mimeType: true, fileName: true,}}
        • {roleField: {key: true, name: true,}}
    • Those object based selections are not intuitive. Now, a simple true bool for the whole field will be autoTranslated into the object based selection so you don't gotta look up the inner details of the field in order to select it

Copy link
Contributor

@airhorns airhorns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me and is a big improvement but I wish we had it for non-AutoForm use cases as well like a plain old api.widget.findMany({select: { gizmos: true }});. It bugs me a little that the two will be inconsistent, but since this is a step in the right direction we should go for it and then move it down a layer when we can.

addRequiredFieldsToSelection(field.apiIdentifier, field);
}

return select;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is complicated enough to deserve a test -- if you're outskie today LMK and I can whip one up!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be around until about 4pm. I'll try to get one up before then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I gotta run now. If you could add some quick tests, that would be spectacular 🫡

@MillanWangGadget MillanWangGadget force-pushed the mill/forceProperSelectionForSpecialFields branch from 13ee708 to 737b1d7 Compare February 25, 2026 03:03
@MillanWangGadget MillanWangGadget force-pushed the mill/forceProperSelectionForSpecialFields branch from 737b1d7 to 7e17098 Compare March 17, 2026 22:29
Copy link
Contributor

@airhorns airhorns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is a great idea but api-client-core has been replaced with @gadgetinc/core and @gadgetinc/connection in the monorepo, gotta make these changes over there

* When a user passes `{ field: true }` for a field that requires sub-selections
* (like richText, file, or role fields), auto-expand it using the defaultSelection.
*/
const normalizeSelection = (selection: FieldSelection, defaultSelection: FieldSelection): FieldSelection => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly api-client-core is no more -- this change has to go in the generated code inside the monorepo now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly?

  • gladly * api-client-core is no more. I'm closing this to rely on API side only change for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops - fat fingered a merge but reverted immediately here #964

@MillanWangGadget MillanWangGadget merged commit 3c1718f into main Mar 18, 2026
12 checks passed
@MillanWangGadget MillanWangGadget deleted the mill/forceProperSelectionForSpecialFields branch March 18, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants