-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

GraphQL Best Practices
By :

Before we start creating components and styling them, we need to create a good communication layer between our backend and frontend. To do this, we will write selectors and prepare the client to communicate with the backend.
Here, we will expand upon the layer we started in Chapter 9. The reason behind this is we want to prepare a seamless way to communicate with the backend to limit the amount of communication code within React components to a minimum.
Like in Chapter 9, we will create the src/graphql/selectors.ts
file and then add content inside it to create the type-safe communication layer with our GraphQL types.
Let’s start making the selectors. The first selectors will be for the client and salon, which we will use inside the hooks later:
import { FromSelector, Selector } from '@/zeus'; export const ClientSelector = Selector('Client')({ _id: true, createdAt: true, ...