3 ms·
This doesn't help in your case, but this is what GraphQL was invented for. TS libraries for GQL queries can dynamically infer the response shape from the shape
by gavinray 1y ago
This doesn't help in your case, but this is what GraphQL was invented for.
TS libraries for GQL queries can dynamically infer the response shape from the shape of the selected fields.
Such that the query
query {
user {
username
posts {
text
}
}
}
Would be
type Response = {
user: {
username: string
posts: Array<{
text: string
}>
}
}
And a query with just { user { username } } would have the posts property omitted entirely.