Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to type GraphQL union responses with TypeScript and Apollo Client?

$
0
0

I'm using Apollo Server and Apollo Client with React Native and TypeScript. I'm trying to do my error handling via GraphQL unions but don't know how to type these. Looking at the example underneath, I want the result type for the useQuery hook to cover both graphql fragments. Is there any way to do so? Thanks.

const GET_USER = gql`    query GetUser ($id: String!) {        user(id: $id) {            ... on User {                email,                username            }            ... on Error {                message            }        }    }`;

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>