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

Input unions? #10

Closed
zth opened this issue May 4, 2023 · 1 comment
Closed

Input unions? #10

zth opened this issue May 4, 2023 · 1 comment

Comments

@zth
Copy link
Owner

zth commented May 4, 2023

Something sorely missing from GraphQL is input unions. While we won't extend the GraphQL language ourselves, we could potentially implement input unions server side:

@gql.inputUnion
type timePeriod = Preset({datePreset: datePreset}) | Dates({from: timestamp, to: timestamp})

@gql.field
let data = (_: query, ~timePeriod) => {
  getDataByTimePeriod(timePeriod)
}
type Query {
  data(datePreset: DatePreset, from: Timestamp, to: Timestamp): DataForPeriod
}

We'd have a code generated layer in each resolver using a input union that automatically throws if the argument configuration isn't correct.

@zth
Copy link
Owner Author

zth commented Dec 28, 2023

Integrated in a slightly different version.

@zth zth closed this as completed Dec 28, 2023
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

No branches or pull requests

1 participant