Skip to content

Commit 0d0d007

Browse files
refactor: reorganize codebase architecture and add CLI (#62)
* refactor: remove unused utility files and streamline module exports - Deleted file-writer utilities and related exports to simplify file handling. - Removed utility functions from index.ts and other utility files to reduce complexity. - Cleaned up scanning utilities by removing unused scanning functions and types. - Eliminated virtual module stubs that are no longer necessary for build processes. - Updated tsconfig paths to reflect changes in file structure and improve module resolution. - Adjusted tsdown configuration to focus on core and ecosystem entry points, enhancing build efficiency. * refactor: consolidate scanning logic into AST-based scanner and streamline directive and resolver scanning * feat(graphql): add Nitro GraphQL integration with route handlers and TypeScript support - Implemented route handler registration for GraphQL endpoints in `src/nitro/setup/routes.ts`. - Added TypeScript configuration and path aliases for GraphQL types in `src/nitro/setup/ts-config.ts`. - Defined Nitro GraphQL type definitions in `src/nitro/types.ts`. - Created virtual module generators for GraphQL schemas, resolvers, and directives in `src/nitro/virtual/generators.ts`. - Added virtual module stubs for GraphQL in `src/nitro/virtual/stubs.ts`. - Developed Nuxt module for Nitro GraphQL integration in `src/nuxt.ts`. - Introduced runtime type stubs for GraphQL types in `src/stubs/index.ts`. - Updated virtual module declarations in `src/virtual.d.ts`. - Adjusted build configuration to include Nitro and runtime type stubs in `tsdown.config.ts`. * feat(cli): add CLI commands, configuration, and GraphQL schema support * feat: implement runtime file generation for resolvers and schema, extend GraphQL server capabilities * refactor: simplify GraphQL extend configuration and add skipLocalScan option * chore: update pnpm workspace configuration and dependencies - Updated '@antfu/eslint-config' from ^6.7.1 to ^6.7.3 - Updated '@graphql-codegen/typescript' from ^5.0.6 to ^5.0.7 - Updated '@graphql-codegen/typescript-operations' from ^5.0.6 to ^5.0.7 - Updated '@graphql-codegen/typescript-resolvers' from ^5.1.4 to ^5.1.5 - Updated '@types/node' from ^24.10.4 to ^25.0.3 - Updated '@vitest/ui' from ^4.0.15 to ^4.0.16 - Updated 'tsdown' from ^0.17.4 to ^0.18.4 - Updated 'vite' from 8.0.0-beta.0 to 8.0.0-beta.5 - Updated 'vitepress-plugin-llms' from ^1.9.3 to ^1.10.0 - Updated 'vitest' from ^4.0.15 to ^4.0.16 - Updated 'zod' from ^4.1.13 to ^4.3.2 - Cleaned up and reorganized pnpm workspace settings - Removed unused dependencies and configurations refactor: streamline code generation imports - Consolidated imports in generate.ts for better readability - Re-exported loadGraphQLDocuments in client.ts for consistency - Cleaned up index.ts by removing redundant export statements - Removed unused imports in scanning.ts - Updated nitro adapter and setup files for improved clarity - Adjusted type imports in nitro/types.ts for better organization - Enhanced generator.ts with clearer null checks * refactor: update generateAll call to respect silent option in watchAndRegenerate
1 parent 1846435 commit 0d0d007

File tree

128 files changed

+5181
-6634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+5181
-6634
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ dist
55
*.log
66
*/.vitepress/cache
77
.rolldown
8-
**/.graphql
8+
**/.graphql
9+
examples/**/bun.*

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default antfu(
4646
rules: {
4747
'unused-imports/no-unused-vars': 'off',
4848
'style/eol-last': 'off',
49+
'pnpm/json-enforce-catalog': 'off',
4950
},
5051
},
5152
)

examples/better-auth/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
"better:init": "npx @better-auth/cli@latest generate --config ./server/utils/auth.ts"
1313
},
1414
"devDependencies": {
15-
"@better-auth/cli": "catalog:",
16-
"@graphql-tools/utils": "catalog:",
17-
"@types/pg": "catalog:",
18-
"better-auth": "catalog:",
19-
"drizzle-kit": "catalog:",
20-
"drizzle-orm": "catalog:",
21-
"drizzle-zod": "catalog:",
22-
"graphql": "catalog:",
23-
"graphql-yoga": "catalog:",
24-
"nitro": "catalog:",
25-
"nitro-graphql": "catalog:",
26-
"pg": "catalog:",
27-
"rolldown": "catalog:",
28-
"tsx": "catalog:",
29-
"uuid": "catalog:",
30-
"zod": "catalog:"
15+
"@better-auth/cli": "^1.4.9",
16+
"@graphql-tools/utils": "^10.11.0",
17+
"@types/pg": "^8.16.0",
18+
"better-auth": "^1.4.9",
19+
"drizzle-kit": "^0.31.8",
20+
"drizzle-orm": "^0.45.1",
21+
"drizzle-zod": "^0.8.3",
22+
"graphql": "^16.12.0",
23+
"graphql-yoga": "^5.18.0",
24+
"nitro": "^3.0.1-alpha.1",
25+
"nitro-graphql": "2.0.0-beta.37",
26+
"pg": "^8.16.3",
27+
"rolldown": "^1.0.0-beta.58",
28+
"tsx": "^4.21.0",
29+
"uuid": "^13.0.0",
30+
"zod": "^4.3.2"
3131
}
3232
}

examples/drizzle-orm/package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
"db:studio": "drizzle-kit studio"
1212
},
1313
"devDependencies": {
14-
"@types/pg": "catalog:",
15-
"drizzle-kit": "catalog:",
16-
"drizzle-orm": "catalog:",
17-
"drizzle-zod": "catalog:",
18-
"graphql": "catalog:",
19-
"graphql-yoga": "catalog:",
20-
"nitro": "catalog:",
21-
"nitro-graphql": "catalog:",
22-
"pg": "catalog:",
23-
"rolldown": "catalog:",
24-
"tsx": "catalog:",
25-
"uuid": "catalog:",
26-
"zod": "catalog:"
14+
"@types/pg": "^8.16.0",
15+
"drizzle-kit": "^0.31.8",
16+
"drizzle-orm": "^0.45.1",
17+
"drizzle-zod": "^0.8.3",
18+
"graphql": "^16.12.0",
19+
"graphql-yoga": "^5.18.0",
20+
"nitro": "^3.0.1-alpha.1",
21+
"nitro-graphql": "2.0.0-beta.37",
22+
"pg": "^8.16.3",
23+
"rolldown": "^1.0.0-beta.58",
24+
"tsx": "^4.21.0",
25+
"uuid": "^13.0.0",
26+
"zod": "^4.3.2"
2727
}
2828
}

examples/vite-react/package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
"lint:type": "tsc -b"
1111
},
1212
"dependencies": {
13-
"@tailwindcss/vite": "catalog:",
14-
"@tanstack/react-query": "catalog:",
15-
"graphql": "catalog:",
16-
"graphql-yoga": "catalog:",
17-
"nitro": "catalog:",
18-
"nitro-graphql": "catalog:",
19-
"ofetch": "catalog:",
20-
"react": "catalog:",
21-
"react-dom": "catalog:",
22-
"react-router-dom": "catalog:",
23-
"tailwindcss": "catalog:"
13+
"@tailwindcss/vite": "^4.1.18",
14+
"@tanstack/react-query": "^5.90.16",
15+
"graphql": "^16.12.0",
16+
"graphql-yoga": "^5.18.0",
17+
"nitro": "^3.0.1-alpha.1",
18+
"nitro-graphql": "2.0.0-beta.37",
19+
"ofetch": "^1.5.1",
20+
"react": "^19.2.3",
21+
"react-dom": "^19.2.3",
22+
"react-router-dom": "^7.11.0",
23+
"tailwindcss": "^4.1.18"
2424
},
2525
"devDependencies": {
26-
"@types/node": "catalog:",
27-
"@types/react": "catalog:",
28-
"@types/react-dom": "catalog:",
29-
"@vitejs/plugin-react": "catalog:",
30-
"graphql-config": "catalog:",
31-
"typescript": "catalog:",
32-
"vite": "catalog:"
26+
"@types/node": "^25.0.3",
27+
"@types/react": "^19.2.7",
28+
"@types/react-dom": "^19.2.3",
29+
"@vitejs/plugin-react": "^5.1.2",
30+
"graphql-config": "^5.1.5",
31+
"typescript": "^5.9.3",
32+
"vite": "8.0.0-beta.5"
3333
}
3434
}

examples/vite-vue/package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
"lint:type": "vue-tsc -b"
1111
},
1212
"dependencies": {
13-
"@pinia/colada": "catalog:",
14-
"@tailwindcss/vite": "catalog:",
15-
"graphql": "catalog:",
16-
"graphql-yoga": "catalog:",
17-
"nitro": "catalog:",
18-
"nitro-graphql": "catalog:",
19-
"ofetch": "catalog:",
20-
"pinia": "catalog:",
21-
"tailwindcss": "catalog:",
22-
"vue": "catalog:",
23-
"vue-router": "catalog:"
13+
"@pinia/colada": "^0.20.0",
14+
"@tailwindcss/vite": "^4.1.18",
15+
"graphql": "^16.12.0",
16+
"graphql-yoga": "^5.18.0",
17+
"nitro": "^3.0.1-alpha.1",
18+
"nitro-graphql": "2.0.0-beta.37",
19+
"ofetch": "^1.5.1",
20+
"pinia": "^3.0.4",
21+
"tailwindcss": "^4.1.18",
22+
"vue": "^3.5.26",
23+
"vue-router": "^4.6.4"
2424
},
2525
"devDependencies": {
26-
"@types/node": "catalog:",
27-
"@vitejs/plugin-vue": "catalog:",
28-
"@vue/tsconfig": "catalog:",
29-
"graphql-config": "catalog:",
30-
"typescript": "catalog:",
31-
"vite": "catalog:",
32-
"vue-tsc": "catalog:"
26+
"@types/node": "^25.0.3",
27+
"@vitejs/plugin-vue": "^6.0.3",
28+
"@vue/tsconfig": "^0.8.1",
29+
"graphql-config": "^5.1.5",
30+
"typescript": "^5.9.3",
31+
"vite": "8.0.0-beta.5",
32+
"vue-tsc": "^3.2.1"
3333
}
3434
}

examples/vite/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
"name": "nitro-app",
33
"type": "module",
44
"private": true,
5-
"packageManager": "pnpm@10.25.0",
5+
"packageManager": "pnpm@10.27.0",
66
"scripts": {
77
"build": "vite build",
88
"dev": "vite dev",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"graphql": "catalog:",
13-
"graphql-yoga": "catalog:",
14-
"nitro-graphql": "catalog:",
15-
"rolldown": "catalog:"
12+
"graphql": "^16.12.0",
13+
"graphql-yoga": "^5.18.0",
14+
"nitro-graphql": "2.0.0-beta.37",
15+
"rolldown": "^1.0.0-beta.58"
1616
},
1717
"devDependencies": {
18-
"nitro": "catalog:",
19-
"vite": "catalog:"
18+
"nitro": "^3.0.1-alpha.1",
19+
"vite": "8.0.0-beta.5"
2020
}
2121
}

package.json

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nitro-graphql",
33
"type": "module",
44
"version": "2.0.0-beta.37",
5-
"packageManager": "pnpm@10.25.0",
5+
"packageManager": "pnpm@10.27.0",
66
"description": "GraphQL integration for Nitro",
77
"license": "MIT",
88
"repository": {
@@ -12,66 +12,65 @@
1212
"sideEffects": false,
1313
"imports": {
1414
"#graphql/server": {
15-
"types": "./dist/graphql/server.d.mts",
16-
"import": "./dist/graphql/server.mjs"
15+
"types": "./dist/stubs/index.d.mts",
16+
"import": "./dist/stubs/index.mjs"
1717
},
1818
"#nitro-graphql/graphql-config": {
19-
"types": "./dist/virtual/graphql-config.d.mts",
20-
"import": "./dist/virtual/graphql-config.mjs"
19+
"types": "./dist/nitro/virtual/stubs.d.mts",
20+
"import": "./dist/nitro/virtual/stubs.mjs"
2121
},
2222
"#nitro-graphql/server-schemas": {
23-
"types": "./dist/virtual/server-schemas.d.mts",
24-
"import": "./dist/virtual/server-schemas.mjs"
23+
"types": "./dist/nitro/virtual/stubs.d.mts",
24+
"import": "./dist/nitro/virtual/stubs.mjs"
2525
},
2626
"#nitro-graphql/server-resolvers": {
27-
"types": "./dist/virtual/server-resolvers.d.mts",
28-
"import": "./dist/virtual/server-resolvers.mjs"
27+
"types": "./dist/nitro/virtual/stubs.d.mts",
28+
"import": "./dist/nitro/virtual/stubs.mjs"
2929
},
3030
"#nitro-graphql/server-directives": {
31-
"types": "./dist/virtual/server-directives.d.mts",
32-
"import": "./dist/virtual/server-directives.mjs"
31+
"types": "./dist/nitro/virtual/stubs.d.mts",
32+
"import": "./dist/nitro/virtual/stubs.mjs"
3333
},
3434
"#nitro-graphql/module-config": {
35-
"types": "./dist/virtual/module-config.d.mts",
36-
"import": "./dist/virtual/module-config.mjs"
35+
"types": "./dist/nitro/virtual/stubs.d.mts",
36+
"import": "./dist/nitro/virtual/stubs.mjs"
3737
},
3838
"#nitro-graphql/debug-info": {
39-
"types": "./dist/virtual/debug-info.d.mts",
40-
"import": "./dist/virtual/debug-info.mjs"
39+
"types": "./dist/nitro/virtual/stubs.d.mts",
40+
"import": "./dist/nitro/virtual/stubs.mjs"
4141
}
4242
},
4343
"exports": {
4444
".": {
4545
"types": "./dist/index.d.mts",
4646
"import": "./dist/index.mjs"
4747
},
48-
"./utils": {
49-
"types": "./dist/utils/index.d.mts",
50-
"import": "./dist/utils/index.mjs"
48+
"./core": {
49+
"types": "./dist/core/index.d.mts",
50+
"import": "./dist/core/index.mjs"
51+
},
52+
"./cli": {
53+
"types": "./dist/cli/index.d.mts",
54+
"import": "./dist/cli/index.mjs"
5155
},
5256
"./define": {
5357
"types": "./dist/define.d.mts",
5458
"import": "./dist/define.mjs"
5559
},
56-
"./utils/apollo": {
57-
"types": "./dist/utils/apollo.d.mts",
58-
"import": "./dist/utils/apollo.mjs"
60+
"./apollo": {
61+
"types": "./dist/nitro/apollo.d.mts",
62+
"import": "./dist/nitro/apollo.mjs"
5963
},
6064
"./nuxt": {
61-
"types": "./dist/ecosystem/nuxt.d.mts",
62-
"import": "./dist/ecosystem/nuxt.mjs"
63-
},
64-
"./vite": {
65-
"types": "./dist/vite.d.mts",
66-
"import": "./dist/vite.mjs"
67-
},
68-
"./types": {
69-
"types": "./dist/types/index.d.mts",
70-
"import": "./dist/types/index.mjs"
65+
"types": "./dist/nuxt.d.mts",
66+
"import": "./dist/nuxt.mjs"
7167
}
7268
},
7369
"module": "./dist/index.mjs",
7470
"types": "./dist/index.d.mts",
71+
"bin": {
72+
"nitro-graphql": "./dist/cli/index.mjs"
73+
},
7574
"files": [
7675
"dist"
7776
],
@@ -87,6 +86,7 @@
8786
"docs:dev": "cd .docs && pnpm install && pnpm update:metadata && pnpm dev",
8887
"docs:build": "cd .docs && pnpm install && pnpm update:metadata && pnpm build",
8988
"docs:preview": "cd .docs && pnpm preview",
89+
"cli": "node ./dist/cli/index.mjs",
9090
"lint": "eslint .",
9191
"lint:fix": "eslint . --fix",
9292
"test": "vitest",
@@ -122,6 +122,7 @@
122122
"@graphql-tools/url-loader": "catalog:",
123123
"@graphql-tools/utils": "catalog:",
124124
"chokidar": "catalog:",
125+
"citty": "catalog:",
125126
"consola": "catalog:",
126127
"defu": "catalog:",
127128
"graphql-config": "catalog:",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// THIS FILE IS GENERATED, DO NOT EDIT!
2+
/* eslint-disable eslint-comments/no-unlimited-disable */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
/* prettier-ignore */
6+
import type * as Types from '#graphql/client';
7+
8+
import type { ExecutionResult } from 'graphql';
9+
10+
export const HelloDocument = /*#__PURE__*/ `
11+
query Hello {
12+
hello
13+
}
14+
`;
15+
export type Requester<C = {}, E = unknown> = <R, V>(doc: string, vars?: V, options?: C) => Promise<ExecutionResult<R, E>> | AsyncIterable<ExecutionResult<R, E>>
16+
export function getSdk<C, E>(requester: Requester<C, E>) {
17+
return {
18+
Hello(variables?: Types.HelloQueryVariables, options?: C): Promise<ExecutionResult<Types.HelloQuery, E>> {
19+
return requester<Types.HelloQuery, Types.HelloQueryVariables>(HelloDocument, variables, options) as Promise<ExecutionResult<Types.HelloQuery, E>>;
20+
}
21+
};
22+
}
23+
export type Sdk = ReturnType<typeof getSdk>;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
query Hello {
2+
hello
3+
}

0 commit comments

Comments
 (0)