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
This works but clearly doesn't feel right as I keep adding up Subset types and end up having to override a lot of non-nullable fields that I don't query.
I was wondering if there was not an easier way to handle that.
My end goal is to be able to type (React/TS) Component Props based on the minimum info I'm certain I'll get in all queries. For instance <PostAuthor author={post.author} /> with author: UserSubset, <UserDropdown user={user} /> with user: UserSubset, etc...
Are "GraphQL Fragments" the way to go? How can I share the fragments in multiple queries & use their types? (I tried that, but had lots of type issues with the Fragments themselves)
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
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say I have multiple queries that return User, Post etc..
I can get them with
getUserById(),getFeaturedUsers(),getPostById(),getPostsByUserId(), etc...How can I easily "share" a subset of a query result around in my client app?
For instance I want some "subsets" like this:
This works but clearly doesn't feel right as I keep adding up Subset types and end up having to override a lot of non-nullable fields that I don't query.
I was wondering if there was not an easier way to handle that.
My end goal is to be able to type (React/TS) Component Props based on the minimum info I'm certain I'll get in all queries. For instance
<PostAuthor author={post.author} />withauthor: UserSubset,<UserDropdown user={user} />withuser: UserSubset, etc...Are "GraphQL Fragments" the way to go? How can I share the fragments in multiple queries & use their types? (I tried that, but had lots of type issues with the Fragments themselves)
Beta Was this translation helpful? Give feedback.
All reactions