Skip to content

feat: let a resource declare its type parameters - #78

Merged
moetemp merged 0 commit into
moe/up/dotnet-client-targetfrom
moe/up/resource-type-parameters
Nov 4, 2026
Merged

moetemp merged 0 commit into
moe/up/dotnet-client-targetfrom
moe/up/resource-type-parameters

Conversation

@moetemp

@moetemp moetemp commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR lets a resource declare its type parameters, in Python, TypeScript and .NET. With @nexus.type-parameter "<alias>", the resource class is generic.

  • An operation that returns the resource takes a runtime type for each parameter. So the stream sample's Python create_stream(Turn, id=...) returns a Stream[Turn].
  • A method takes a runtime type only for a parameter that only its output uses. So the read takes one, and the append takes none. Each language decodes generic response values with the handle's runtime types.
  • Go and Java refuse a generic resource. nexgen also refuses one as a record field, or as the result of an operation with no @nexus.proto message, since neither gives the type arguments.

Why?

The proposal's Stream API is generic in its value type, as in Stream[Turn], so a read must decode the body as the handle's type, not as a raw payload. A resource couldn't use a type parameter at all.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

The Python, TypeScript and .NET tests read typed values. A parser unit test covers a type parameter alias that use brings in from another interface.

@moetemp
moetemp force-pushed the moe/up/resource-type-parameters branch from fbdc32c to 9791e30 Compare October 29, 2026 04:00
@moetemp
moetemp force-pushed the moe/up/python-poll branch from 12e5348 to 888e56f Compare October 29, 2026 04:00
@moetemp
moetemp force-pushed the moe/up/resource-type-parameters branch from 9791e30 to 5f8ad4f Compare October 31, 2026 13:08
@moetemp
moetemp changed the base branch from moe/up/python-poll to moe/up/dotnet-client-target October 31, 2026 13:09
@moetemp
moetemp force-pushed the moe/up/dotnet-client-target branch from 841a56f to 1457f2a Compare November 3, 2026 15:22
@moetemp
moetemp force-pushed the moe/up/resource-type-parameters branch from 5f8ad4f to 1180181 Compare November 3, 2026 15:22
@moetemp moetemp closed this Nov 4, 2026
@moetemp
moetemp force-pushed the moe/up/resource-type-parameters branch from 1180181 to de74981 Compare November 4, 2026 09:34
@moetemp
moetemp merged commit de74981 into moe/up/dotnet-client-target Nov 4, 2026
@moetemp
moetemp force-pushed the moe/up/dotnet-client-target branch from 1457f2a to ba06fdf Compare November 4, 2026 09:34
@moetemp

moetemp commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

GitHub marked this as merged after the restack, since its old base came to contain it. It continues upstream as temporalio#358.

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