You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type Query {
user: User
}
type User {
id: ID!
first_name: String!
last_name: String!
full_name: String!
}
If I use typescript-resolvers, it will generate QueryResolvers and User.
Query.user must return a full User instance to match QueryResolvers types.
But I want the Query.user resolver returns only a partial fields - id, first_name & last_name. full_name will be resolved by the type.User.full_name resolver(UserResolvers)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let's start with a sample schema.
If I use
typescript-resolvers
, it will generateQueryResolvers
andUser
.Query.user must return a full User instance to match QueryResolvers types.
But I want the Query.user resolver returns only a partial fields - id, first_name & last_name.
full_name
will be resolved by the type.User.full_name resolver(UserResolvers)query_resolver.user function have a type error by it does not return full_name field. So I must use the type casting
as any
and I want to avoid it.Is there a way to archive fully type safe code?
Beta Was this translation helpful? Give feedback.
All reactions