My graphql codegen has produced this type for me:
export type GetOffersForMembershipQuery = {
__typename?: "Query";
offers:
| { __typename?: "BaseError" }
| {
__typename?: "QueryOffersSuccess";
data: Array<{
__typename?: "Offer";
title: string;
details: string;
identifier: string;
merchant?: {
__typename?: "Merchant";
logoImageUrl?: string | null;
} | null;
}>;
}
| { __typename?: "ValidationError" };
};
I am looking to extract the type of data
. How can I achieve this?
I attempted to do it like so:
GetOffersForMembershipQuery["offers"]["data"];
However, I encountered an issue because ["data"]
does not exist if the __typename
is not "QueryOffersSuccess"
.