Skip to content

advance transform attribute to access full field metadata#176

Merged
avkonst merged 3 commits into
mainfrom
andrey/exploratory-field-transform-attribute
Jun 23, 2026
Merged

advance transform attribute to access full field metadata#176
avkonst merged 3 commits into
mainfrom
andrey/exploratory-field-transform-attribute

Conversation

@avkonst

@avkonst avkonst commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

📖 Documentation Preview: https://reflectapi-docs-preview-pr-176.partly.workers.dev

Updated automatically from commit 617ee79

@avkonst avkonst requested a review from hardbyte June 19, 2026 11:51
@JosiahBull JosiahBull self-requested a review June 21, 2026 23:21
Comment thread docs/src/getting-started/attributes.md
Comment on lines +51 to +52
/// In Rust this is `reflectapi::Option<String>` (populated by middleware),
/// but clients see it as a required `Option<String>` (nullable, not omittable).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Subtle difference based on reflectapi::Option vs std::Option. As a developer I'd typically expect make_required to do the same regardless of what Option variant it's on - would be a bit of a footgun imo.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

making std option required means removing Undefined and None variants for the non-nullable field.

making reflectapi required means removing Undefined variant, as None is expected possible null value.

the difference is on purpose as the semantics of both types required.

however, the client can provide their own transform functions.

@JosiahBull JosiahBull Jun 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I use a function called make_required on something named Option I would expect the generated client to disallow all None-alike values (None, null, etc).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need to rename something here to make this clearer

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do you know that from reflectapi (and our API standard) required is not equal to not-nullable? These are two distinct things. It is possible to have non-required but nullable and required but nullable and 2 other combos. So the transform function does exactly that: it removes the declaration for the field to be required, which is for non nullable field means no None of the standard Option and for nullable field it means no Undefined of the reflectapi Option.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we can add make_nonnullable, and super set of both make_required_and_nonnullable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would be happy with this outcome, will mark as approved.

@avkonst

avkonst commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

@JosiahBull what change are you requesting to make?

@JosiahBull JosiahBull self-requested a review June 22, 2026 21:16
@avkonst avkonst merged commit e98d576 into main Jun 23, 2026
6 checks passed
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