A Next.js starter project with Sanity and GraphQL/Typescript code generation.
- GraphQL code generation with Typescript integration.
- VSCode auto-complete for GraphQL queries.
- Embedded studio on /studio route.
Note: This setup can easily be installed on Remix or any other framework.
#.env
NEXT_PUBLIC_SANITY_PROJECT_ID=projectId
NEXT_PUBLIC_SANITY_DATASET=production
npm run graphql-deploy
npm run dev
Open http://localhost:3000/studio and publish a few blog posts.
All the queries are being placed on the queries.graphql
file. If you prefer to use tags on typescript files, you will have to edit graphql.config.ts
and codegen.ts
.
Make sure to restart the VSCode GraphQL process whenever you deploy schema changes!
Look for Gustavo Bremm on Sanity Slack.