Skip to content

Commit 473d13f

Browse files
committed
Add manual types
1 parent 50ab947 commit 473d13f

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

docs/source/data/typescript.mdx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,22 @@ Like `useQuery`, you provide `useMutation` a `TypedDocumentNode`. This adds the
323323
```tsx
324324
import { gql, TypedDocumentNode } from "@apollo/client";
325325
import { useMutation } from "@apollo/client/react";
326-
import {
327-
SaveRocketMutation,
328-
SaveRocketMutationVariables,
329-
} from "@/types/__generated__/graphql";
326+
327+
// In a real application, consider generating types from your schema
328+
// instead of writing them by hand
329+
type SaveRocketMutation = {
330+
saveRocket: {
331+
model: string;
332+
} | null;
333+
};
334+
335+
type SaveRocketMutationVariables = {
336+
rocket: {
337+
model: string;
338+
year: number;
339+
stock: number;
340+
};
341+
};
330342

331343
const SAVE_ROCKET: TypedDocumentNode<
332344
SaveRocketMutation,
@@ -459,10 +471,16 @@ Like `useQuery`, you provide `useSubscription` a `TypedDocumentNode`. This adds
459471
```tsx
460472
import { gql, TypedDocumentNode } from "@apollo/client";
461473
import { useSubscription } from "@apollo/client/react";
462-
import {
463-
GetLatestNewsSubscription,
464-
GetLatestNewsSubscriptionVariables,
465-
} from "@/types/__generated__/graphql";
474+
475+
// In a real application, consider generating types from your schema
476+
// instead of writing them by hand
477+
type GetLatestNewsSubscription = {
478+
latestNews: {
479+
content: string;
480+
};
481+
};
482+
483+
type GetLatestNewsSubscriptionVariables = Record<string, never>;
466484

467485
const LATEST_NEWS: TypedDocumentNode<
468486
GetLatestNewsSubscription,

0 commit comments

Comments
 (0)