@lewebsimple/nuxt-graphql 0.5.3 → 0.5.4
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.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -19,15 +19,16 @@ const reset = "\x1B[0m";
|
|
|
19
19
|
|
|
20
20
|
function renderContextTemplate({ contextModules }) {
|
|
21
21
|
const imports = contextModules.map((module, index) => `import context${index} from ${JSON.stringify(module)};`);
|
|
22
|
-
const types = contextModules.map((_, index) => `Awaited<ReturnType<typeof context${index}>>`);
|
|
22
|
+
const types = ["{}", ...contextModules.map((_, index) => `Awaited<ReturnType<typeof context${index}>>`)];
|
|
23
23
|
return [
|
|
24
24
|
`import type { H3Event } from "h3";`,
|
|
25
25
|
...imports,
|
|
26
26
|
"",
|
|
27
|
-
`export type GraphQLContext = ${types.join("
|
|
27
|
+
`export type GraphQLContext = ${types.join(" & ")};`,
|
|
28
28
|
"",
|
|
29
29
|
"export async function createContext(event: H3Event): Promise<GraphQLContext> {",
|
|
30
30
|
" const parts = await Promise.all([",
|
|
31
|
+
" () => ({}),",
|
|
31
32
|
...contextModules.map((_, index) => ` context${index}(event),`),
|
|
32
33
|
" ]);",
|
|
33
34
|
" return Object.assign({}, ...parts) as GraphQLContext;",
|
|
@@ -384,7 +385,6 @@ const module$1 = defineNuxtModule({
|
|
|
384
385
|
nuxt.options.alias ||= {};
|
|
385
386
|
nuxt.options.alias["#graphql"] ||= resolveBuild("graphql");
|
|
386
387
|
const contextModules = [
|
|
387
|
-
resolveModule("./runtime/server/lib/default-context"),
|
|
388
388
|
...await Promise.all((options.yoga?.context || []).map((path) => resolveRootPath(path, true)))
|
|
389
389
|
];
|
|
390
390
|
addTemplate({ filename: "graphql/context.ts", getContents: () => renderContextTemplate({ contextModules }), write: true });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { GraphQLContext } from "#graphql/context";
|
|
1
2
|
/**
|
|
2
3
|
* Get or create the singleton GraphQL Yoga instance.
|
|
3
4
|
*
|
|
4
5
|
* @returns GraphQL Yoga server instance.
|
|
5
6
|
*/
|
|
6
|
-
export declare function getYogaInstance(): import("graphql-yoga").YogaServerInstance<
|
|
7
|
+
export declare function getYogaInstance(): import("graphql-yoga").YogaServerInstance<GraphQLContext, {}>;
|
package/package.json
CHANGED