Skip to content

feat: let a helper method return a support class with no await - #122

Draft
moetemp wants to merge 3 commits into
moe/up/resource-guardfrom
moe/up/helper-sync-method
Draft

moetemp wants to merge 3 commits into
moe/up/resource-guardfrom
moe/up/helper-sync-method

Conversation

@moetemp

@moetemp moetemp commented Nov 15, 2026

Copy link
Copy Markdown
Owner

This PR lets a @nexus.helper method return at once, and lets it return a class of the support package.

  • sync=true on @nexus.helper makes the Python method a plain def. It returns the helper's result with no await.
  • @nexus.support-type python="<class>" on a type alias stands for a class that the support package exports. @nexus.generic on the alias gives its type parameters. nexgen generates nothing for the class, and only a helper method may return it.

The Workflow Stream gets a read that gives each Record as it arrives. Code iterates the result, and then reads from it where and why the read ended. So the method must hand back an object with no await, and that object has behavior, which a generated model can't have.

/// @nexus.support-type python="StreamReading"
/// @nexus.generic "body-t"
type stream-reading = placeholder;

/// @nexus.helper python="iter_stream" targets="workflow" sync=true
iter: func(timeout: option<duration>, from-offset: option<list<u8>>) -> stream-reading;
def iter(
    self, timeout: datetime.timedelta | None = None, from_offset: bytes | None = None
) -> _support.StreamReading[BodyT]:
    return _support.iter_stream(self, timeout=timeout, from_offset=from_offset)

The stream sample has the new method on its Workflow Stream. TypeScript, .NET, Go and Java leave it out, as they do for every helper method, so their sample outputs don't change.

moetemp and others added 3 commits November 15, 2026 01:56
A Workflow read that gives each Record as it arrives must return its object at once, with no await.
That object is a class that the support package writes by hand, so only a helper method returns it.
Workflow code reads each Record as it arrives, then reads where and why the read ended.
The support package gets a small test double of the reading, so the tests run with no Store.
Authors need the `sync` argument of `@nexus.helper` and the new alias directive for a support class.
The changelog notes both for the Python support package.

Co-authored-by: Tim Conley <timothy.conley@temporal.io>
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