Buckets:
32.9 GB
31,201 files
Updated 2 months ago
Ctrl+K
| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| lib | 7 items | ||
| pages | 4 items | ||
| test | 2 items | ||
| .gitignore | 547 Bytes xet | e231a02d | |
| README.md | 1.82 kB xet | ca5e0958 | |
| codegen.ts | 427 Bytes xet | 0d444f11 | |
| jest.config.js | 423 Bytes xet | 964f4cb9 | |
| next.config.js | 226 Bytes xet | a8b493b2 | |
| package.json | 1.14 kB xet | 2cf938d6 | |
| tsconfig.json | 557 Bytes xet | 98c99635 |
TypeScript and GraphQL Example
One of the strengths of GraphQL is enforcing data types on runtime. Further, TypeScript and GraphQL Code Generator (graphql-codegen) make it safer by typing data statically, so you can write truly type-protected code with rich IDE assists.
This template gives you the best start to use GraphQL with fully typed queries (client-side) and resolvers (server-side), all this with minimum bundle size 📦
import { useQuery } from "@apollo/client";
import { ViewerDocument } from "lib/graphql-operations";
const News = () => {
// Typed already️⚡️
const {
data: { viewer },
} = useQuery(ViewerDocument);
return <div>{viewer.name}</div>;
};
Deploy your own
How to use
Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:
npx create-next-app --example with-typescript-graphql with-typescript-graphql-app
yarn create next-app --example with-typescript-graphql with-typescript-graphql-app
pnpm create next-app --example with-typescript-graphql with-typescript-graphql-app
Deploy it to the cloud with Vercel (Documentation).
- Total size
- 32.9 GB
- Files
- 31,201
- Last updated
- Sep 26
- Pre-warmed CDN
- US EU US EU