Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static type safety for required selection #1133

Open
jasonkuhrt opened this issue Sep 26, 2024 · 0 comments
Open

static type safety for required selection #1133

jasonkuhrt opened this issue Sep 26, 2024 · 0 comments

Comments

@jasonkuhrt
Copy link
Member

jasonkuhrt commented Sep 26, 2024

Perceived Problem

This will cause a runtime error:

const pokemons = await pokemon.query.$batch({
  pokemons: {
    $include: true,
    // name: true, <-- at least one field must be selected
  },
})

Ideas / Proposed Solution(s)

  • At-least one field semantics will probably require some complex type utilities.
  • (x) Thinking statically... we could define a union of all selection sets combinations wherein one field is required and rest are optional, but that would be a huge a union and probably not great on intelligence meaning this static approach wouldn't be much better or even worse than a fully type utility approach.

Big concerns here are reducing type legibility and/or performance without significant benefit.

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

No branches or pull requests

1 participant