@stonecrop/nuxt-grafserv 0.16.6 → 0.17.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/dist/module.d.mts +41 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -4
- package/dist/runtime/handler.d.ts +2 -2
- package/dist/types.d.mts +1 -1
- package/package.json +3 -3
package/dist/module.d.mts
CHANGED
|
@@ -181,8 +181,48 @@ interface SchemaConfig {
|
|
|
181
181
|
* @see SchemaConfig for custom schemas with resolvers
|
|
182
182
|
*/
|
|
183
183
|
type ModuleOptions = PostGraphileConfig | SchemaConfig;
|
|
184
|
+
/**
|
|
185
|
+
* PostGraphile-mode runtime config, as the module writes it into Nitro.
|
|
186
|
+
*
|
|
187
|
+
* Build-time-only keys (`preset`, `fieldCasing`, `schemas`, `explain`, `debug`) are deliberately
|
|
188
|
+
* absent: they are consumed while building the `#internal/grafserv/pgl` virtual module and have no
|
|
189
|
+
* meaning at request time.
|
|
190
|
+
*/
|
|
191
|
+
interface PostGraphileRuntimeConfig {
|
|
192
|
+
type: 'postgraphile';
|
|
193
|
+
/** Always concrete — the module resolves `options.url ?? '/graphql/'` at build time. */
|
|
194
|
+
url: string;
|
|
195
|
+
/** Always concrete — the module resolves `options.graphiql ?? nuxt.options.dev` at build time. */
|
|
196
|
+
graphiql: boolean;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Schema-mode runtime config, as the module writes it into Nitro.
|
|
200
|
+
*
|
|
201
|
+
* Note `resolversPath` rather than `resolvers`: the module resolves the authored path against
|
|
202
|
+
* `rootDir` and stores the absolute result, so the handler never re-resolves it.
|
|
203
|
+
*/
|
|
204
|
+
interface SchemaRuntimeConfig {
|
|
205
|
+
type: 'schema';
|
|
206
|
+
/** File path(s) already resolved to absolute, or the provider function passed through. */
|
|
207
|
+
schema: SchemaConfig['schema'];
|
|
208
|
+
/** Absolute path to the resolvers module, or `undefined` when none was configured. */
|
|
209
|
+
resolversPath?: string;
|
|
210
|
+
/** Always concrete — the module resolves `options.url ?? '/graphql/'` at build time. */
|
|
211
|
+
url: string;
|
|
212
|
+
/** Always concrete — the module resolves `options.graphiql ?? nuxt.options.dev` at build time. */
|
|
213
|
+
graphiql: boolean;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* What `runtimeConfig.grafserv` actually holds at request time.
|
|
217
|
+
*
|
|
218
|
+
* This is **not** `ModuleOptions`. The module resolves authored options during `nitro:config` and
|
|
219
|
+
* writes this narrower, fully-resolved shape instead. Treating the two as interchangeable is what
|
|
220
|
+
* previously forced a `@ts-expect-error` in the runtime handler for `resolversPath`, and left the
|
|
221
|
+
* unit tests describing the runtime config with a type that has no `resolversPath` at all.
|
|
222
|
+
*/
|
|
223
|
+
type GrafservRuntimeConfig = PostGraphileRuntimeConfig | SchemaRuntimeConfig;
|
|
184
224
|
|
|
185
225
|
declare const module$1: NuxtModule<ModuleOptions>;
|
|
186
226
|
|
|
187
227
|
export { module$1 as default };
|
|
188
|
-
export type { ModuleOptions, PostGraphileConfig, SchemaConfig, SchemaProvider };
|
|
228
|
+
export type { GrafservRuntimeConfig, ModuleOptions, PostGraphileConfig, PostGraphileRuntimeConfig, SchemaConfig, SchemaProvider, SchemaRuntimeConfig };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -176,12 +176,13 @@ export default {
|
|
|
176
176
|
].join("\n");
|
|
177
177
|
}
|
|
178
178
|
config.virtual["#internal/grafserv/resolvers"] = "export default null";
|
|
179
|
-
|
|
180
|
-
config.runtimeConfig.grafserv = {
|
|
179
|
+
const pgRuntimeConfig = {
|
|
181
180
|
type: "postgraphile",
|
|
182
181
|
url: options.url || "/graphql/",
|
|
183
182
|
graphiql: graphiqlEnabled
|
|
184
183
|
};
|
|
184
|
+
config.runtimeConfig = config.runtimeConfig || {};
|
|
185
|
+
config.runtimeConfig.grafserv = pgRuntimeConfig;
|
|
185
186
|
} else if (options.type === "schema") {
|
|
186
187
|
logger.info("Using schema configuration");
|
|
187
188
|
const resolverPath = options.resolvers ? resolveForVirtualModule(options.resolvers) : void 0;
|
|
@@ -203,14 +204,15 @@ export default {
|
|
|
203
204
|
} else {
|
|
204
205
|
runtimeSchema = options.schema;
|
|
205
206
|
}
|
|
206
|
-
|
|
207
|
-
config.runtimeConfig.grafserv = {
|
|
207
|
+
const schemaRuntimeConfig = {
|
|
208
208
|
type: "schema",
|
|
209
209
|
schema: runtimeSchema,
|
|
210
210
|
resolversPath: resolverPath,
|
|
211
211
|
url: options.url || "/graphql/",
|
|
212
212
|
graphiql: graphiqlEnabled
|
|
213
213
|
};
|
|
214
|
+
config.runtimeConfig = config.runtimeConfig || {};
|
|
215
|
+
config.runtimeConfig.grafserv = schemaRuntimeConfig;
|
|
214
216
|
config.virtual = config.virtual || {};
|
|
215
217
|
if (resolverPath) {
|
|
216
218
|
config.virtual["#internal/grafserv/resolvers"] = `export { default } from '${resolverPath}'`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { grafserv } from 'grafserv/h3/v1';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GrafservRuntimeConfig } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get or create the grafserv instance
|
|
5
5
|
* Exported for use by separate handler files
|
|
@@ -8,7 +8,7 @@ import type { ModuleOptions } from '../types.js';
|
|
|
8
8
|
* execution context (withPgClient, pgSettings, plugin middleware, etc.).
|
|
9
9
|
* For schema mode: builds a schema from files/function and wraps with grafserv.
|
|
10
10
|
*/
|
|
11
|
-
export declare function getGrafservInstance(options:
|
|
11
|
+
export declare function getGrafservInstance(options: GrafservRuntimeConfig): Promise<ReturnType<typeof grafserv>>;
|
|
12
12
|
/**
|
|
13
13
|
* Clear the cached instances (useful for development hot reload)
|
|
14
14
|
*
|
package/dist/types.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default } from './module.mjs'
|
|
2
2
|
|
|
3
|
-
export { type ModuleOptions, type PostGraphileConfig, type SchemaConfig, type SchemaProvider } from './module.mjs'
|
|
3
|
+
export { type GrafservRuntimeConfig, type ModuleOptions, type PostGraphileConfig, type PostGraphileRuntimeConfig, type SchemaConfig, type SchemaProvider, type SchemaRuntimeConfig } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/nuxt-grafserv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Pluggable Grafserv GraphQL server as Nuxt Module",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/agritheory/stonecrop/issues"
|
|
@@ -44,7 +44,7 @@
|
|
|
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.17.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@eslint/js": "^10.0.1",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"test:ci": "vitest run --run",
|
|
100
100
|
"test:coverage": "vitest run --coverage.enabled --coverage.provider=istanbul",
|
|
101
101
|
"test:e2e": "vitest run test/e2e",
|
|
102
|
-
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
102
|
+
"test:types": "vue-tsc --noEmit -p tsconfig.src.json && vue-tsc --noEmit -p tsconfig.test.json && cd playground && vue-tsc --noEmit",
|
|
103
103
|
"test:watch": "vitest watch"
|
|
104
104
|
}
|
|
105
105
|
}
|