@stonecrop/nuxt-grafserv 0.13.12 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/dist/module.d.mts +8 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -3
- package/dist/runtime/handler.js +11 -2
- package/package.json +9 -9
- package/dist/runtime/graphql.d.ts +0 -6
- package/dist/runtime/graphql.js +0 -9
- package/dist/runtime/ruru.d.ts +0 -6
- package/dist/runtime/ruru.js +0 -9
package/README.md
CHANGED
|
@@ -138,7 +138,7 @@ Use `type: 'postgraphile'` for PostGraphile-based GraphQL APIs:
|
|
|
138
138
|
| `schemas` | `string[]` | ❌ | PostgreSQL schemas to expose (default: `['public']`). Ignored when `preset` is set. |
|
|
139
139
|
| `explain` | `boolean` | ❌ | Enable Ruru Explain tab. **Never use in production.** Ignored when `preset` is set. |
|
|
140
140
|
| `url` | `string` | ❌ | GraphQL endpoint URL (default: `/graphql/`) |
|
|
141
|
-
| `graphiql` | `boolean` | ❌ |
|
|
141
|
+
| `graphiql` | `boolean` | ❌ | Serve the Ruru GraphiQL IDE and its static assets. Defaults to `true` in development and `false` in production. |
|
|
142
142
|
|
|
143
143
|
**Minimal example (no preset file):**
|
|
144
144
|
|
|
@@ -181,7 +181,7 @@ Use `type: 'schema'` for custom GraphQL schemas with Grafast resolvers:
|
|
|
181
181
|
| `schema` | `string \| string[] \| SchemaProvider` | ✅ | Path(s) to .graphql files or schema provider function |
|
|
182
182
|
| `resolvers` | `string` | ❌ | Path to resolvers file (required for .graphql files) |
|
|
183
183
|
| `url` | `string` | ❌ | GraphQL endpoint URL (default: `/graphql/`) |
|
|
184
|
-
| `graphiql` | `boolean` | ❌ |
|
|
184
|
+
| `graphiql` | `boolean` | ❌ | Serve the Ruru GraphiQL IDE and its static assets. Defaults to `true` in development and `false` in production. |
|
|
185
185
|
|
|
186
186
|
**Example with files:**
|
|
187
187
|
|
|
@@ -551,13 +551,11 @@ This package lives inside the Stonecrop Rush monorepo. Use `rushx` instead of `p
|
|
|
551
551
|
# Install all monorepo dependencies (run from the repo root)
|
|
552
552
|
rush install
|
|
553
553
|
|
|
554
|
-
# Bootstrap the playground database (first time only — requires Docker)
|
|
555
|
-
cd playground && node scripts/bootstrap.mjs
|
|
556
|
-
|
|
557
554
|
# Generate type stubs
|
|
558
555
|
rushx dev:prepare
|
|
559
556
|
|
|
560
|
-
# Develop with the playground (from nuxt_grafserv/)
|
|
557
|
+
# Develop with the playground (from nuxt_grafserv/).
|
|
558
|
+
# Starts + migrates the Postgres container (Docker required), then runs Nuxt.
|
|
561
559
|
rushx dev
|
|
562
560
|
|
|
563
561
|
# Build the module
|
|
@@ -571,7 +569,7 @@ rushx test
|
|
|
571
569
|
rushx test:watch
|
|
572
570
|
```
|
|
573
571
|
|
|
574
|
-
The playground runs against a PostgreSQL container managed by Docker Compose.
|
|
572
|
+
The playground runs against a PostgreSQL container managed by Docker Compose. `rushx dev` starts the container and applies migrations automatically (via `playground/scripts/bootstrap.mjs`) before launching Nuxt, so Docker must be running; both steps are idempotent, so this is a fast no-op once the container exists (it persists via a named volume). To manage the database on its own, run `pnpm db:up` / `pnpm db:down` (or `node scripts/bootstrap.mjs` to recreate and migrate) from `playground/`.
|
|
575
573
|
|
|
576
574
|
<!-- Badges -->
|
|
577
575
|
[npm-version-src]: https://img.shields.io/npm/v/@stonecrop/nuxt-grafserv/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
package/dist/module.d.mts
CHANGED
|
@@ -110,7 +110,10 @@ interface PostGraphileConfig {
|
|
|
110
110
|
debug?: boolean;
|
|
111
111
|
/** GraphQL endpoint URL (default: '/graphql/') */
|
|
112
112
|
url?: string;
|
|
113
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Serve the GraphiQL IDE (Ruru) and its static assets. Defaults to `true` in
|
|
115
|
+
* development and `false` in production.
|
|
116
|
+
*/
|
|
114
117
|
graphiql?: boolean;
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
@@ -165,7 +168,10 @@ interface SchemaConfig {
|
|
|
165
168
|
resolvers?: string;
|
|
166
169
|
/** GraphQL endpoint URL (default: '/graphql/') */
|
|
167
170
|
url?: string;
|
|
168
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* Serve the GraphiQL IDE (Ruru) and its static assets. Defaults to `true` in
|
|
173
|
+
* development and `false` in production.
|
|
174
|
+
*/
|
|
169
175
|
graphiql?: boolean;
|
|
170
176
|
}
|
|
171
177
|
/**
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -49,6 +49,7 @@ const module$1 = defineNuxtModule({
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
validateConfig(options);
|
|
52
|
+
const graphiqlEnabled = options.graphiql ?? nuxt.options.dev;
|
|
52
53
|
const { resolve } = createResolver(import.meta.url);
|
|
53
54
|
const require = createRequire(import.meta.url);
|
|
54
55
|
nuxt.hook("nitro:config", (config) => {
|
|
@@ -179,7 +180,7 @@ export default {
|
|
|
179
180
|
config.runtimeConfig.grafserv = {
|
|
180
181
|
type: "postgraphile",
|
|
181
182
|
url: options.url || "/graphql/",
|
|
182
|
-
graphiql:
|
|
183
|
+
graphiql: graphiqlEnabled
|
|
183
184
|
};
|
|
184
185
|
} else if (options.type === "schema") {
|
|
185
186
|
logger.info("Using schema configuration");
|
|
@@ -208,7 +209,7 @@ export default {
|
|
|
208
209
|
schema: runtimeSchema,
|
|
209
210
|
resolversPath: resolverPath,
|
|
210
211
|
url: options.url || "/graphql/",
|
|
211
|
-
graphiql:
|
|
212
|
+
graphiql: graphiqlEnabled
|
|
212
213
|
};
|
|
213
214
|
config.virtual = config.virtual || {};
|
|
214
215
|
if (resolverPath) {
|
|
@@ -245,7 +246,7 @@ export default {
|
|
|
245
246
|
addServerPlugin(resolve("./runtime/startup-check"));
|
|
246
247
|
}
|
|
247
248
|
addServerHandler({ route: options.url || "/graphql/", handler: resolve("./runtime/handler") });
|
|
248
|
-
if (
|
|
249
|
+
if (graphiqlEnabled) {
|
|
249
250
|
addServerHandler({ route: "/ruru-static/**", handler: resolve("./runtime/ruru-static") });
|
|
250
251
|
}
|
|
251
252
|
if (nuxt.options.dev) {
|
package/dist/runtime/handler.js
CHANGED
|
@@ -2,7 +2,7 @@ import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
|
2
2
|
import { loadTypedefs } from "@graphql-tools/load";
|
|
3
3
|
import { grafserv } from "grafserv/h3/v1";
|
|
4
4
|
import { makeGrafastSchema } from "grafast";
|
|
5
|
-
import { defineEventHandler } from "h3";
|
|
5
|
+
import { defineEventHandler, setResponseStatus } from "h3";
|
|
6
6
|
import { useRuntimeConfig } from "nitropack/runtime";
|
|
7
7
|
let grafservInstance = null;
|
|
8
8
|
let cachedSchema = null;
|
|
@@ -94,13 +94,22 @@ export async function clearGrafservCache() {
|
|
|
94
94
|
export default defineEventHandler(async (event) => {
|
|
95
95
|
const config = useRuntimeConfig();
|
|
96
96
|
const options = config.grafserv;
|
|
97
|
+
const graphiqlEnabled = options.graphiql ?? false;
|
|
97
98
|
try {
|
|
98
99
|
const serv = await getGrafservInstance(options);
|
|
100
|
+
if (!graphiqlEnabled && event.method === "GET") {
|
|
101
|
+
setResponseStatus(event, 404);
|
|
102
|
+
return "GraphiQL is disabled";
|
|
103
|
+
}
|
|
99
104
|
const graphqlResult = await serv.handleGraphQLEvent(event);
|
|
100
105
|
if (graphqlResult !== null) {
|
|
101
106
|
return graphqlResult;
|
|
102
107
|
}
|
|
103
|
-
|
|
108
|
+
if (graphiqlEnabled) {
|
|
109
|
+
return serv.handleGraphiqlEvent(event);
|
|
110
|
+
}
|
|
111
|
+
setResponseStatus(event, 404);
|
|
112
|
+
return "GraphiQL is disabled";
|
|
104
113
|
} catch (error) {
|
|
105
114
|
console.error("[@stonecrop/nuxt-grafserv] Error in GraphQL handler:", error);
|
|
106
115
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/nuxt-grafserv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Pluggable Grafserv GraphQL server as Nuxt Module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -44,31 +44,31 @@
|
|
|
44
44
|
"grafserv": "^1.0.0",
|
|
45
45
|
"graphql": "^16.14.0",
|
|
46
46
|
"postgraphile": "^5.0.3",
|
|
47
|
-
"@stonecrop/graphql-middleware": "0.
|
|
47
|
+
"@stonecrop/graphql-middleware": "0.14.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@eslint/js": "^10.0.1",
|
|
51
51
|
"@nuxt/devtools": "^3.2.4",
|
|
52
|
-
"@nuxt/eslint-config": "^1.
|
|
52
|
+
"@nuxt/eslint-config": "^1.16.0",
|
|
53
53
|
"@nuxt/kit": "^4.4.4",
|
|
54
54
|
"@nuxt/module-builder": "^1.0.2",
|
|
55
|
-
"@nuxt/schema": "^4.4.
|
|
55
|
+
"@nuxt/schema": "^4.4.8",
|
|
56
56
|
"@nuxt/test-utils": "^4.0.3",
|
|
57
57
|
"@vitest/coverage-istanbul": "^4.1.5",
|
|
58
58
|
"@types/node": "^24.12.4",
|
|
59
|
-
"h3": "^1.15.
|
|
59
|
+
"h3": "^1.15.11",
|
|
60
60
|
"nitropack": "^2.13.1",
|
|
61
61
|
"changelogen": "^0.6.2",
|
|
62
|
-
"eslint": "^10.
|
|
62
|
+
"eslint": "^10.6.0",
|
|
63
63
|
"jsdom": "^29.1.1",
|
|
64
|
-
"nuxt": "^4.4.
|
|
64
|
+
"nuxt": "^4.4.8",
|
|
65
65
|
"postgraphile": "^5.0.3",
|
|
66
66
|
"typescript": "^6.0.3",
|
|
67
67
|
"vite": "^7.3.2",
|
|
68
68
|
"vitest": "^4.1.5",
|
|
69
69
|
"vue": "^3.5.33",
|
|
70
70
|
"vue-router": "^5.0.6",
|
|
71
|
-
"vue-tsc": "^3.
|
|
71
|
+
"vue-tsc": "^3.3.6"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@stonecrop/casl-middleware": "*",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"build": "rushx dev:prepare && rushx prepack",
|
|
92
92
|
"build:module": "rushx dev:prepare && rushx prepack",
|
|
93
93
|
"docs": "echo 'Nuxt modules use custom build system - skipping API docs generation'",
|
|
94
|
-
"dev": "nuxi dev playground",
|
|
94
|
+
"dev": "node playground/scripts/bootstrap.mjs && nuxi dev playground --host",
|
|
95
95
|
"dev:build": "nuxi build playground",
|
|
96
96
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
97
97
|
"lint": "eslint .",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GraphQL operations handler
|
|
3
|
-
* Handles POST requests with GraphQL queries, mutations, and subscriptions
|
|
4
|
-
*/
|
|
5
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike> | import("grafserv").JSONValue | undefined>>;
|
|
6
|
-
export default _default;
|
package/dist/runtime/graphql.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
2
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
|
-
import { getGrafservInstance } from "./handler.js";
|
|
4
|
-
export default defineEventHandler(async (event) => {
|
|
5
|
-
const config = useRuntimeConfig();
|
|
6
|
-
const options = config.grafserv;
|
|
7
|
-
const serv = await getGrafservInstance(options);
|
|
8
|
-
return serv.handleGraphQLEvent(event);
|
|
9
|
-
});
|
package/dist/runtime/ruru.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ruru/GraphiQL UI handler
|
|
3
|
-
* Serves the GraphQL IDE interface for exploring and testing the API
|
|
4
|
-
*/
|
|
5
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike> | import("grafserv").JSONValue | undefined>>;
|
|
6
|
-
export default _default;
|
package/dist/runtime/ruru.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
2
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
|
-
import { getGrafservInstance } from "./handler.js";
|
|
4
|
-
export default defineEventHandler(async (event) => {
|
|
5
|
-
const config = useRuntimeConfig();
|
|
6
|
-
const options = config.grafserv;
|
|
7
|
-
const serv = await getGrafservInstance(options);
|
|
8
|
-
return serv.handleGraphiqlEvent(event);
|
|
9
|
-
});
|