Skip to content

Task definition helper function (ability to define per-task defaults + typescript as a first-class citizen) #491

Open
@lauri865

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions