Search⌘ K

The Generated Book Type

Explore the generated Book type created by the GraphQL Code Generator and understand its key differences from the original type, including __typename and Scalars. Learn how to integrate and use this type in your React components to improve type safety and code quality.

Let’s start by breaking down the generated.tsx file and looking at each type.

The generated Book type and the old Book type

The first type in this file that we’ll look at is the new generated Book type.

export type Book = {
__typename?: 'Book';
id: Scalars['ID'];
title: Scalars['String'];
};
Book type generated using GraphQL Code Generator

This type looks a lot like the old Book ...