silverwolf-x/project / examples /with-typescript-graphql
32.9 GB
31,201 files
Updated 2 months ago
Name
Size
lib
pages
test
.gitignore547 Bytes
xet
README.md1.82 kB
xet
codegen.ts427 Bytes
xet
jest.config.js423 Bytes
xet
next.config.js226 Bytes
xet
package.json1.14 kB
xet
tsconfig.json557 Bytes
xet
README.md

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

Deploy with Vercel

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

Contributors