Description
Feature description
It would be great if there was a better helper function to define tasks, such as a createTask
, that would enable inline payload validation as well as defining task defaults (retries, and other options).
There's many cases when a task e.g. calls an expensive API, and I only want it to be retried a few times if any, and I need to always configure it at the task caller level, which makes maintenance less straight forward than it needs to be.
This change would also help make typescript a first-class citizen and tremendously improve the DX of creating typescript-based tasks, which currently involves importing helper types and "manually" parsing payloads to validate them, and manually adding types for the payload to make sure that callers are aware of them. I think Zod could easily be a first-party integration here for the helper function to define payloads, which would then help to pass them through for implementations as well.
I really like the first benchmark below.
Motivating example
Benchmarks:
- https://x.com/ImSh4yy/status/1816677686116229522
- https://github.com/ben-pr-p/graphile-worker-zod
- https://www.inngest.com/docs/reference/functions/create
- https://trigger.dev/docs/tasks/overview
Breaking changes
It doesn't have to come with any breaking changes.
Supporting development
I [tick all that apply]:
- am interested in building this feature myself (happy to design the helper function, but could use help from the maintainer on extending the DB schema to hold the task defaults)
- am interested in collaborating on building this feature
- am willing to help testing this feature before it's released
- [] am willing to write a test-driven test suite for this feature (before it exists)
- am a Graphile sponsor ❤️
- have an active support or consultancy contract with Graphile
Activity