Skip to content

fix: bind a resource field only into a request field of its type - #309

Closed
moetemp wants to merge 2 commits into
moe/up/resource-type-params-through-protosfrom
moe/up/resource-binding-types
Closed

moetemp wants to merge 2 commits into
moe/up/resource-type-params-through-protosfrom
moe/up/resource-binding-types

Conversation

@moetemp

@moetemp moetemp commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What changed?

This PR makes a resource method fill a request field from a same-name resource field or parameter only when their types match. An optional field also takes a source of its inner type, but a required field doesn't take an optional source.

With no match, an optional field is unset or built from its own fields, as before. A required field leaves an implicit method unbound, and fails generation for a method with @nexus.operation.

The first commit adds an email flag to the user-service notify request with today's output, and the second is the fix.

It's based on #304.

Why?

Brook's Stream resource has a status of one enum, and its close request has a status of another, so close filled the request with the Stream's own status. Brook's WIT hides the bug with a status parameter on close, so user-service reproduces it.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

At the first commit, each language fills the option<bool> flag with the email string. A unit test covers an implicit method, and a rejection fixture covers @nexus.operation.

@moetemp
moetemp force-pushed the moe/up/resource-binding-types branch 2 times, most recently from be0ed9f to d9ed245 Compare October 28, 2026 16:37
This was referenced Oct 28, 2026
@moetemp
moetemp changed the base branch from main to moe/up/resource-type-params-through-protos October 28, 2026 22:57
@moetemp
moetemp force-pushed the moe/up/resource-binding-types branch from d9ed245 to 8d7b2b8 Compare October 29, 2026 04:00
@moetemp
moetemp force-pushed the moe/up/resource-type-params-through-protos branch from 2acc4e9 to fb0aedf Compare October 29, 2026 06:28
@moetemp
moetemp force-pushed the moe/up/resource-binding-types branch from 8d7b2b8 to 5c24067 Compare October 29, 2026 06:28
@moetemp
moetemp force-pushed the moe/up/resource-type-params-through-protos branch from fb0aedf to cc6f8ba Compare October 29, 2026 07:00
@moetemp
moetemp force-pushed the moe/up/resource-binding-types branch from 5c24067 to 33695de Compare October 29, 2026 07:00
The flag has the name of the user's own email, with another type. Today's output fills the flag
with the user's email.
A resource method filled each request field from the resource field or param of the same name,
whatever its type. So the user's own email went into the notify request's email flag. A source
binds only when its type is the field's type, or the inner type of an optional field.
@moetemp
moetemp force-pushed the moe/up/resource-type-params-through-protos branch from cc6f8ba to e7f9b2e Compare October 29, 2026 07:35
@moetemp
moetemp force-pushed the moe/up/resource-binding-types branch from 33695de to a27caee Compare October 29, 2026 07:35
@moetemp

moetemp commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Closing this. The Streams stack doesn't need it.

@moetemp moetemp closed this Oct 29, 2026
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.

1 participant