Types for context.query
#8498
dcousens
announced in
Technical Discussion
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A copy of our internal team sparring, dated 2022-02-03
The problem is that a
context.query.*.find*
result cannot be statically translated to produce accurate Typescript types, and as such the result currently is that we return aRecord<string, any>
.For example, casting to a
Post
is the approach typically taken by users, but that can be wrong.Even if you assumed
Partial<Post>
(or similar fornull
s), the inherent capability of GQL aliases means the naming may not be 1:1 and thus types cannot be automatically inferred.Proposal: Domain Specific Language (try for a
minor
)For
context.query
add a newfields
key which adds support for an object-based query language.The the
where
/take
syntax remains the same, and the existingfind*
experience only improves.For aliasing, we could support a syntax like
{ as: ... }
Signal 📶
context.query
#7095context.query
types #7249context.query
types" #7302Beta Was this translation helpful? Give feedback.
All reactions