Skip to content

Commit de12edf

Browse files
feat: examples nuxt 5
1 parent 289fa83 commit de12edf

File tree

19 files changed

+203
-82
lines changed

19 files changed

+203
-82
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default antfu(
5050
'unused-imports/no-unused-vars': 'off',
5151
'style/eol-last': 'off',
5252
'pnpm/json-enforce-catalog': 'off',
53+
'pnpm/json-prefer-workspace-settings': 'off',
5354
},
5455
},
5556
)

examples/better-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"graphql": "^16.12.0",
2323
"graphql-yoga": "^5.18.0",
2424
"nitro": "^3.0.1-alpha.1",
25-
"nitro-graphql": "2.0.0-beta.57",
25+
"nitro-graphql": "2.0.0-beta.61",
2626
"pg": "^8.16.3",
2727
"rolldown": "^1.0.0-beta.59",
2828
"tsx": "^4.21.0",

examples/drizzle-orm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"graphql": "^16.12.0",
1919
"graphql-yoga": "^5.18.0",
2020
"nitro": "^3.0.1-alpha.1",
21-
"nitro-graphql": "2.0.0-beta.57",
21+
"nitro-graphql": "2.0.0-beta.61",
2222
"pg": "^8.16.3",
2323
"rolldown": "^1.0.0-beta.59",
2424
"tsx": "^4.21.0",

examples/nitro-apollo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@apollo/server": "^5.2.0",
1010
"graphql": "^16.12.0",
1111
"nitro": "^3.0.1-alpha.1",
12-
"nitro-graphql": "2.0.0-beta.57",
12+
"nitro-graphql": "2.0.0-beta.61",
1313
"rolldown": "^1.0.0-beta.59"
1414
}
1515
}

examples/nitro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"graphql": "^16.12.0",
1010
"graphql-yoga": "^5.18.0",
1111
"nitro": "^3.0.1-alpha.1",
12-
"nitro-graphql": "2.0.0-beta.57",
12+
"nitro-graphql": "2.0.0-beta.61",
1313
"rolldown": "^1.0.0-beta.59"
1414
}
1515
}

examples/nuxt/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.nuxt
3+
.output
4+
.graphql
5+
dist

examples/nuxt/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Nuxt + nitro-graphql Example
2+
3+
This example demonstrates using nitro-graphql with Nuxt 4.
4+
5+
## Setup
6+
7+
```bash
8+
pnpm install
9+
pnpm dev
10+
```
11+
12+
## Features
13+
14+
- GraphQL Yoga server at `/api/graphql`
15+
- Auto-generated TypeScript types
16+
- GraphQL Playground (Apollo Sandbox)
17+
18+
## Structure
19+
20+
```
21+
server/graphql/
22+
├── schema.graphql # GraphQL schema
23+
└── hello.resolver.ts # Query resolvers
24+
```
25+
26+
## Try it
27+
28+
1. Run `pnpm dev`
29+
2. Open http://localhost:3000
30+
3. Or visit http://localhost:3000/api/graphql for the playground

examples/nuxt/app/app.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script setup lang="ts">
2+
const { data } = await useFetch('/api/graphql', {
3+
method: 'POST',
4+
headers: { 'Content-Type': 'application/json' },
5+
body: { query: '{ hello }' },
6+
})
7+
</script>
8+
9+
<template>
10+
<div>
11+
<h1>Nuxt + nitro-graphql</h1>
12+
<p>GraphQL Response: {{ data?.data?.hello }}</p>
13+
<p>
14+
<a href="/api/graphql" target="_blank">Open GraphQL Playground</a>
15+
</p>
16+
</div>
17+
</template>

examples/nuxt/nuxt.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import graphql from 'nitro-graphql'
2+
3+
// https://nuxt.com/docs/api/configuration/nuxt-config
4+
export default defineNuxtConfig({
5+
compatibilityDate: '2025-07-15',
6+
devtools: { enabled: true },
7+
nitro: {
8+
builder: 'rolldown',
9+
modules: [
10+
graphql({
11+
framework: 'graphql-yoga',
12+
}),
13+
],
14+
},
15+
})

examples/nuxt/package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "nuxt-5-graphql-example",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"build": "nuxt build",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
"preview": "nuxt preview",
10+
"postinstall": "nuxt prepare"
11+
},
12+
"dependencies": {
13+
"@nuxt/kit": "https://pkg.pr.new/@nuxt/kit@33005",
14+
"@nuxt/schema": "https://pkg.pr.new/@nuxt/schema@33005",
15+
"graphql": "^16.12.0",
16+
"graphql-yoga": "^5.16.2",
17+
"nitro-graphql": "^2.0.0-beta.61",
18+
"nuxt": "https://pkg.pr.new/nuxt@33005",
19+
"vue": "^3.5.26",
20+
"vue-router": "^4.2.2"
21+
},
22+
"pnpm": {
23+
"overrides": {
24+
"@nuxt/kit": "https://pkg.pr.new/@nuxt/kit@33005",
25+
"@nuxt/schema": "https://pkg.pr.new/@nuxt/schema@33005",
26+
"graphql": "^16.12.0",
27+
"nitro": "https://pkg.pr.new/nitrojs/nitro@99691fc",
28+
"nuxt": "https://pkg.pr.new/nuxt@33005",
29+
"vite": "8.0.0-beta.7"
30+
}
31+
},
32+
"overrides": {
33+
"@nuxt/kit": "https://pkg.pr.new/@nuxt/kit@33005",
34+
"@nuxt/schema": "https://pkg.pr.new/@nuxt/schema@33005",
35+
"graphql": "^16.12.0",
36+
"nitro": "https://pkg.pr.new/nitrojs/nitro@99691fc",
37+
"nuxt": "https://pkg.pr.new/nuxt@33005",
38+
"vite": "8.0.0-beta.7"
39+
}
40+
}

0 commit comments

Comments
 (0)