@nexusts/graphql 0.7.0 → 0.7.2
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 +4 -2
- package/dist/decorators/arg.d.ts +24 -0
- package/dist/decorators/index.d.ts +6 -0
- package/dist/decorators/query.d.ts +26 -0
- package/dist/decorators/resolver.d.ts +30 -0
- package/dist/graphql.module.d.ts +45 -0
- package/dist/graphql.service.d.ts +85 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2 -18
- package/dist/index.js.map +3 -3
- package/dist/types.d.ts +137 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ This module is part of the NexusTS monorepo. Each module is published as its own
|
|
|
15
15
|
Most apps start with just the core:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
bun add @nexusts/core
|
|
18
|
+
bun add @nexusts/core
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Then add this module only if you need it:
|
|
@@ -30,7 +30,9 @@ bun add @nexusts/graphql
|
|
|
30
30
|
bun add graphql
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
- **`graphql`** ^17.0.0 — Required for building / executing GraphQL schemas.
|
|
34
|
+
|
|
35
|
+
Without them the module loads but its public methods throw a clear error pointing to this install command on first call.
|
|
34
36
|
|
|
35
37
|
## Usage
|
|
36
38
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@Arg(name, type?)` parameter decorator.
|
|
3
|
+
*
|
|
4
|
+
* Declares a method parameter as a GraphQL field argument. Used on
|
|
5
|
+
* resolver methods marked with `@Query`/`@Mutation`/`@Subscription`.
|
|
6
|
+
*
|
|
7
|
+
* @Mutation()
|
|
8
|
+
* updateProfile(
|
|
9
|
+
* @Arg("name") name: string,
|
|
10
|
+
* @Arg("email", "String!") email: string,
|
|
11
|
+
* ) { ... }
|
|
12
|
+
*
|
|
13
|
+
* The optional `type` argument is the SDL type (e.g. `"String!"`,
|
|
14
|
+
* `"Int"`, `"[User!]!"`). When omitted, the framework uses `"String"`
|
|
15
|
+
* as a safe default — explicit is better than implicit.
|
|
16
|
+
*/
|
|
17
|
+
import "reflect-metadata";
|
|
18
|
+
export declare function Arg(name: string, type?: string): ParameterDecorator;
|
|
19
|
+
/** Read `@Arg` metadata for a specific method. */
|
|
20
|
+
export declare function getMethodArgs(target: object, propertyKey: string | symbol): Array<{
|
|
21
|
+
name: string;
|
|
22
|
+
type: string;
|
|
23
|
+
index: number;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@Query(name?)` / `@Mutation(name?)` / `@Subscription(name?)`
|
|
3
|
+
*
|
|
4
|
+
* Method decorators that mark a resolver method as a GraphQL operation.
|
|
5
|
+
* The optional `name` argument overrides the field name in the schema
|
|
6
|
+
* (defaults to the method name).
|
|
7
|
+
*
|
|
8
|
+
* @Resolver("User")
|
|
9
|
+
* class UserResolver {
|
|
10
|
+
* @Query("currentUser")
|
|
11
|
+
* me() { return ctx.state.user; }
|
|
12
|
+
*
|
|
13
|
+
* @Mutation()
|
|
14
|
+
* updateProfile(@Arg("name") name: string) { ... }
|
|
15
|
+
*
|
|
16
|
+
* @Subscription()
|
|
17
|
+
* events() { return pubsub.asyncIterator("EVENTS"); }
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
import "reflect-metadata";
|
|
21
|
+
import type { ResolverClassRecord } from "../types.js";
|
|
22
|
+
export declare const Query: (name?: string) => (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
23
|
+
export declare const Mutation: (name?: string) => (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
24
|
+
export declare const Subscription: (name?: string) => (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
25
|
+
/** Public helper for the scanner. */
|
|
26
|
+
export type AnyField = ResolverClassRecord["fields"][number];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Resolver(typeName?) decorator.
|
|
3
|
+
*
|
|
4
|
+
* Marks a class as a GraphQL resolver. The optional `typeName` argument
|
|
5
|
+
* declares the GraphQL type this class is responsible for. If
|
|
6
|
+
* omitted, the type name defaults to the class name (e.g.
|
|
7
|
+
* `UserResolver` → type `User`).
|
|
8
|
+
*
|
|
9
|
+
* The framework's GraphQL scanner picks up every class with this
|
|
10
|
+
* decorator and reads the field methods off it (decorators from
|
|
11
|
+
* `./query.js`, `./mutation.js`, `./subscription.js`).
|
|
12
|
+
*
|
|
13
|
+
* @Resolver("User")
|
|
14
|
+
* class UserResolver {
|
|
15
|
+
* @Query() me() { ... }
|
|
16
|
+
* @Mutation() signup(@Arg("email") e: string) { ... }
|
|
17
|
+
* @Subscription() events() { ... }
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
import "reflect-metadata";
|
|
21
|
+
import type { ResolverClassRecord } from "../types.js";
|
|
22
|
+
export declare function Resolver(typeName?: string): ClassDecorator;
|
|
23
|
+
/** Read the type-name this resolver is for. */
|
|
24
|
+
export declare function getResolverTypeName(target: object): string | undefined;
|
|
25
|
+
/** Append a field method to the resolver class's metadata. */
|
|
26
|
+
export declare function pushResolverField(target: object, field: ResolverClassRecord["fields"][number]): void;
|
|
27
|
+
/** Read the field metadata for a resolver class. */
|
|
28
|
+
export declare function getResolverFields(target: object): ResolverClassRecord["fields"];
|
|
29
|
+
/** True if `target` was decorated with `@Resolver`. */
|
|
30
|
+
export declare function isResolverClass(target: object): boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GraphQLModule` — drop-in GraphQL endpoint.
|
|
3
|
+
*
|
|
4
|
+
* @Module({
|
|
5
|
+
* imports: [
|
|
6
|
+
* GraphQLModule.forRoot({
|
|
7
|
+
* typeDefs: `
|
|
8
|
+
* type Query { hello: String! }
|
|
9
|
+
* `,
|
|
10
|
+
* resolvers: {
|
|
11
|
+
* Query: {
|
|
12
|
+
* hello: () => "world",
|
|
13
|
+
* },
|
|
14
|
+
* },
|
|
15
|
+
* }),
|
|
16
|
+
* ],
|
|
17
|
+
* })
|
|
18
|
+
* export class AppModule {}
|
|
19
|
+
*
|
|
20
|
+
* After boot, the framework exposes:
|
|
21
|
+
*
|
|
22
|
+
* POST /graphql — queries + mutations
|
|
23
|
+
* GET /graphql — GraphiQL UI (or a query, if `?query=...` is set)
|
|
24
|
+
* GET /graphql/schema — the schema as SDL (debug)
|
|
25
|
+
*
|
|
26
|
+
* Resolvers can also be declared via the `@Resolver` + `@Query` /
|
|
27
|
+
* `@Mutation` / `@Subscription` decorators — see the user guide.
|
|
28
|
+
*/
|
|
29
|
+
import "reflect-metadata";
|
|
30
|
+
import { GraphQLService } from "./graphql.service.js";
|
|
31
|
+
import type { GraphQLConfig } from "./types.js";
|
|
32
|
+
export declare class GraphQLModule {
|
|
33
|
+
static forRoot(config: GraphQLConfig): {
|
|
34
|
+
new (): {};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Manually mount the GraphQL endpoint onto a Hono-compatible app.
|
|
38
|
+
* Used by `main.ts` setups that don't go through `@Module`.
|
|
39
|
+
*/
|
|
40
|
+
static mount(app: {
|
|
41
|
+
post: (path: string, ...h: any[]) => any;
|
|
42
|
+
get: (path: string, ...h: any[]) => any;
|
|
43
|
+
use: (path: string, ...h: any[]) => any;
|
|
44
|
+
}, svc: GraphQLService): Promise<void>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GraphQLService` — owns the parsed schema, resolver map, and an
|
|
3
|
+
* end-to-end executor.
|
|
4
|
+
*
|
|
5
|
+
* Most users won't instantiate this directly — they use
|
|
6
|
+
* `GraphQLModule.forRoot({ typeDefs, resolvers, ... })` which puts
|
|
7
|
+
* a singleton service into the DI container. The service is also
|
|
8
|
+
* exported for advanced users (programmatic queries, schema
|
|
9
|
+
* introspection, custom executors).
|
|
10
|
+
*
|
|
11
|
+
* The actual `parse` / `validate` / `execute` calls go to
|
|
12
|
+
* `graphql` (a peer-dep). If the user hasn't installed it, we
|
|
13
|
+
* throw a clear error from the first attempt.
|
|
14
|
+
*/
|
|
15
|
+
import "reflect-metadata";
|
|
16
|
+
import type { GraphQLConfig, GraphQLContext, GraphQLExecutionResult, ResolverMap } from "./types.js";
|
|
17
|
+
interface GraphQLJs {
|
|
18
|
+
parse: (s: string) => unknown;
|
|
19
|
+
buildSchema: (sdl: string) => unknown;
|
|
20
|
+
validate: (schema: unknown, doc: unknown, rules?: unknown) => unknown[];
|
|
21
|
+
execute: (...args: any[]) => Promise<GraphQLExecutionResult> | GraphQLExecutionResult;
|
|
22
|
+
specifiedRules?: unknown;
|
|
23
|
+
getOperationAST?: (doc: unknown, operationName?: string) => unknown;
|
|
24
|
+
GraphQLSchema: unknown;
|
|
25
|
+
GraphQLObjectType: unknown;
|
|
26
|
+
GraphQLString: unknown;
|
|
27
|
+
GraphQLNonNull: unknown;
|
|
28
|
+
GraphQLList: unknown;
|
|
29
|
+
GraphQLInt: unknown;
|
|
30
|
+
GraphQLFloat: unknown;
|
|
31
|
+
GraphQLBoolean: unknown;
|
|
32
|
+
GraphQLID: unknown;
|
|
33
|
+
GraphQLError: unknown;
|
|
34
|
+
GraphQLScalarType: unknown;
|
|
35
|
+
parseType: (s: string) => unknown;
|
|
36
|
+
GraphQLSchemaConfig: unknown;
|
|
37
|
+
}
|
|
38
|
+
/** Lazy-load the `graphql` package. Throws a clear error if missing. */
|
|
39
|
+
export declare function loadGraphQLJs(): Promise<GraphQLJs>;
|
|
40
|
+
export declare class GraphQLService {
|
|
41
|
+
/** The raw config the module was booted with. */
|
|
42
|
+
readonly config: GraphQLConfig;
|
|
43
|
+
/** Optional DI handle. */
|
|
44
|
+
static readonly TOKEN: unique symbol;
|
|
45
|
+
constructor(config?: GraphQLConfig);
|
|
46
|
+
private _schema;
|
|
47
|
+
private _resolvers;
|
|
48
|
+
private _bootstrapPromise;
|
|
49
|
+
/**
|
|
50
|
+
* Register a resolver map (or add to the existing one). Safe to
|
|
51
|
+
* call multiple times — the maps are merged.
|
|
52
|
+
*/
|
|
53
|
+
addResolvers(map: ResolverMap): void;
|
|
54
|
+
private _buildSchema;
|
|
55
|
+
/**
|
|
56
|
+
* Build (or rebuild) the underlying GraphQL schema. Idempotent.
|
|
57
|
+
* Returns the `graphql` schema instance.
|
|
58
|
+
*/
|
|
59
|
+
ensureSchema(): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* Validate + execute a GraphQL document. Returns the raw
|
|
62
|
+
* `execute()` result envelope (data, errors, extensions).
|
|
63
|
+
*/
|
|
64
|
+
execute(source: string, variableValues?: Record<string, unknown>, operationName?: string, contextValue?: GraphQLContext): Promise<GraphQLExecutionResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Produce a `GraphQLContext` from an inbound Hono request.
|
|
67
|
+
* Calls the user's `context()` factory if provided.
|
|
68
|
+
*/
|
|
69
|
+
buildContext(c: any): Promise<GraphQLContext>;
|
|
70
|
+
/**
|
|
71
|
+
* Read the parsed SDL back as a string. Useful for the
|
|
72
|
+
* `/graphql/schema` debug endpoint and for tests.
|
|
73
|
+
*/
|
|
74
|
+
getSchemaSDL(): string;
|
|
75
|
+
private normaliseTypeDefs;
|
|
76
|
+
/**
|
|
77
|
+
* Decorator-discovered types/methods get added to the SDL so the
|
|
78
|
+
* schema actually has a place to put them. Each `@Resolver("X")`
|
|
79
|
+
* with `@Query()` / `@Mutation()` / `@Subscription()` methods
|
|
80
|
+
* contributes a `type X { ... }` or `extend type Query { ... }`
|
|
81
|
+
* snippet.
|
|
82
|
+
*/
|
|
83
|
+
private mergeSDLWithDecorators;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for `nexusjs/graphql`.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export { GraphQLService, loadGraphQLJs } from "./graphql.service.js";
|
|
6
|
+
export { GraphQLModule } from "./graphql.module.js";
|
|
7
|
+
export { Resolver, Query, Mutation, Subscription, Arg, isResolverClass, getResolverTypeName, getResolverFields, getMethodArgs, } from "./decorators/index.js";
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
2
|
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -162,7 +146,7 @@ function wrapSchemaWithResolvers(schema, resolvers) {
|
|
|
162
146
|
}
|
|
163
147
|
// packages/graphql/src/graphql.module.ts
|
|
164
148
|
import"reflect-metadata";
|
|
165
|
-
import { Module } from "@nexusts/core
|
|
149
|
+
import { Module } from "@nexusts/core";
|
|
166
150
|
class GraphQLModule {
|
|
167
151
|
static forRoot(config) {
|
|
168
152
|
const factory = () => new GraphQLService(config);
|
|
@@ -422,5 +406,5 @@ export {
|
|
|
422
406
|
Arg
|
|
423
407
|
};
|
|
424
408
|
|
|
425
|
-
//# debugId=
|
|
409
|
+
//# debugId=6421516686033CD864756E2164756E21
|
|
426
410
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"sources": ["../src/graphql.service.ts", "../src/graphql.module.ts", "../src/decorators/resolver.ts", "../src/decorators/query.ts", "../src/decorators/arg.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * `GraphQLService` — owns the parsed schema, resolver map, and an\n * end-to-end executor.\n *\n * Most users won't instantiate this directly — they use\n * `GraphQLModule.forRoot({ typeDefs, resolvers, ... })` which puts\n * a singleton service into the DI container. The service is also\n * exported for advanced users (programmatic queries, schema\n * introspection, custom executors).\n *\n * The actual `parse` / `validate` / `execute` calls go to\n * `graphql` (a peer-dep). If the user hasn't installed it, we\n * throw a clear error from the first attempt.\n */\nimport \"reflect-metadata\";\nimport type {\n\tGraphQLConfig,\n\tGraphQLContext,\n\tGraphQLExecutionResult,\n\tFieldResolver,\n\tResolverMap,\n} from \"./types.js\";\n\ninterface GraphQLJs {\n\tparse: (s: string) => unknown;\n\tbuildSchema: (sdl: string) => unknown;\n\tvalidate: (schema: unknown, doc: unknown, rules?: unknown) => unknown[];\n\t// graphql 16 takes positional args; graphql 17 takes a single\n\t// object. We always call it with the 16-style positional args\n\t// (so we wrap a `buildSchema` schema, not the resolver-builder\n\t// schema), but the type reflects both possibilities.\n\texecute: (...args: any[]) => Promise<GraphQLExecutionResult> | GraphQLExecutionResult;\n\tspecifiedRules?: unknown;\n\tgetOperationAST?: (doc: unknown, operationName?: string) => unknown;\n\tGraphQLSchema: unknown;\n\tGraphQLObjectType: unknown;\n\tGraphQLString: unknown;\n\tGraphQLNonNull: unknown;\n\tGraphQLList: unknown;\n\tGraphQLInt: unknown;\n\tGraphQLFloat: unknown;\n\tGraphQLBoolean: unknown;\n\tGraphQLID: unknown;\n\tGraphQLError: unknown;\n\tGraphQLScalarType: unknown;\n\tparseType: (s: string) => unknown;\n\tGraphQLSchemaConfig: unknown;\n}\n\nlet _graphql: GraphQLJs | null = null;\nlet _loadAttempted = false;\n\n/** Lazy-load the `graphql` package. Throws a clear error if missing. */\nexport async function loadGraphQLJs(): Promise<GraphQLJs> {\n\tif (_graphql) return _graphql;\n\tif (_loadAttempted) {\n\t\tthrow new Error(\n\t\t\t\"[nexusjs/graphql] The optional `graphql` package failed to load. \" +\n\t\t\t\t\"Install it with `bun add graphql` to use the GraphQL module.\",\n\t\t);\n\t}\n\t_loadAttempted = true;\n\ttry {\n\t\tconst mod = (await import(\"graphql\")) as unknown as GraphQLJs;\n\t\t_graphql = mod;\n\t\treturn mod;\n\t} catch (err) {\n\t\tthrow new Error(\n\t\t\t\"[nexusjs/graphql] The `graphql` package is required for execution. \" +\n\t\t\t\t\"Install it with `bun add graphql`. \" +\n\t\t\t\t\"Original error: \" + (err as Error).message,\n\t\t);\n\t}\n}\n\nexport class GraphQLService {\n\t/** The raw config the module was booted with. */\n\treadonly config: GraphQLConfig;\n\t/** Optional DI handle. */\n\tstatic readonly TOKEN = Symbol.for(\"nexus:GraphQL\");\n\n\tconstructor(config: GraphQLConfig = {}) {\n\t\tthis.config = {\n\t\t\tplayground: \"graphiql\",\n\t\t\tendpoint: { path: \"/graphql\", enableGet: true },\n\t\t\texposeSchemaSDL: true,\n\t\t\tintrospection: true,\n\t\t\t...config,\n\t\t};\n\t}\n\n\tprivate _schema: any = null;\n\tprivate _resolvers: ResolverMap = {};\n\tprivate _bootstrapPromise: Promise<void> | null = null;\n\n\t/**\n\t * Register a resolver map (or add to the existing one). Safe to\n\t * call multiple times — the maps are merged.\n\t */\n\taddResolvers(map: ResolverMap): void {\n\t\tfor (const [typeName, fields] of Object.entries(map)) {\n\t\t\tthis._resolvers[typeName] = {\n\t\t\t\t...this._resolvers[typeName],\n\t\t\t\t...fields,\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate async _buildSchema(sdl: string[]): Promise<any> {\n\t\tconst g = await loadGraphQLJs();\n\t\tconst merged = this.mergeSDLWithDecorators(sdl);\n\t\t// graphql-js's `buildSchema` produces a `GraphQLSchema` whose\n\t\t// fields' `resolve` is `undefined` by default — graphql-js's\n\t\t// execution layer looks up fields on the parent object in\n\t\t// that case. To wire our `ResolverMap`, we set each field's\n\t\t// `resolve` directly. This works for graphql 16 and 17.\n\t\tconst schema = (g.buildSchema as Function)(merged);\n\t\tconst final: ResolverMap = { ...this._resolvers, ...this.config.resolvers };\n\t\twrapSchemaWithResolvers(schema, final);\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Build (or rebuild) the underlying GraphQL schema. Idempotent.\n\t * Returns the `graphql` schema instance.\n\t */\n\tasync ensureSchema(): Promise<any> {\n\t\tif (this._schema) return this._schema;\n\t\tif (this._bootstrapPromise) return this._bootstrapPromise.then(() => this._schema);\n\t\tthis._bootstrapPromise = (async () => {\n\t\t\tconst sdl = this.normaliseTypeDefs(this.config.typeDefs);\n\t\t\tif (sdl.length === 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"[nexusjs/graphql] No typeDefs configured. \" +\n\t\t\t\t\t\t\"Pass `typeDefs: '...' to GraphQLModule.forRoot()` or \" +\n\t\t\t\t\t\t\"use `@Resolver` + `@Query` / `@Mutation` decorators.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis._schema = await this._buildSchema(sdl);\n\t\t})();\n\t\tawait this._bootstrapPromise;\n\t\treturn this._schema;\n\t}\n\n\t/**\n\t * Validate + execute a GraphQL document. Returns the raw\n\t * `execute()` result envelope (data, errors, extensions).\n\t */\n\tasync execute(\n\t\tsource: string,\n\t\tvariableValues: Record<string, unknown> = {},\n\t\toperationName?: string,\n\t\tcontextValue?: GraphQLContext,\n\t): Promise<GraphQLExecutionResult> {\n\t\tconst g = await loadGraphQLJs();\n\t\tconst schema = await this.ensureSchema();\n\t\tconst document = (g.parse as Function)(source);\n\t\tconst errors = (g.validate as Function)(schema, document, g.specifiedRules) as unknown[];\n\t\tif (errors.length > 0) {\n\t\t\treturn {\n\t\t\t\terrors: (errors as any[]).map((e: any) => ({\n\t\t\t\t\tmessage: e.message,\n\t\t\t\t\tlocations: e.locations,\n\t\t\t\t})),\n\t\t\t};\n\t\t}\n\t\t// If the user didn't pass a context and the service has a\n\t\t// `context()` factory, build a synthetic context (with a\n\t\t// stub Hono ctx) so resolvers that depend on `ctx.state` work\n\t\t// in `execute()` calls outside of an HTTP request.\n\t\tlet ctx = contextValue;\n\t\tif (!ctx && this.config.context) {\n\t\t\tconst fakeHono = { req: { url: \"\", method: \"EXECUTE\", header: () => \"\" } };\n\t\t\tctx = {\n\t\t\t\thono: fakeHono as any,\n\t\t\t\tstate: await this.config.context(fakeHono as any),\n\t\t\t};\n\t\t}\n\t\tconst rootValue = undefined;\n\t\treturn await (g.execute as any)({\n\t\t\tschema,\n\t\t\tdocument,\n\t\t\trootValue,\n\t\t\tcontextValue: ctx,\n\t\t\tvariableValues,\n\t\t\toperationName,\n\t\t});\n\t}\n\n\t/**\n\t * Produce a `GraphQLContext` from an inbound Hono request.\n\t * Calls the user's `context()` factory if provided.\n\t */\n\tasync buildContext(c: any): Promise<GraphQLContext> {\n\t\tconst state = this.config.context\n\t\t\t? await this.config.context(c)\n\t\t\t: {};\n\t\treturn { hono: c, state };\n\t}\n\n\t/**\n\t * Read the parsed SDL back as a string. Useful for the\n\t * `/graphql/schema` debug endpoint and for tests.\n\t */\n\tgetSchemaSDL(): string {\n\t\treturn this.normaliseTypeDefs(this.config.typeDefs).join(\"\\n\");\n\t}\n\n\tprivate normaliseTypeDefs(td?: string | string[]): string[] {\n\t\tif (!td) return [];\n\t\treturn Array.isArray(td) ? td : [td];\n\t}\n\n\t/**\n\t * Decorator-discovered types/methods get added to the SDL so the\n\t * schema actually has a place to put them. Each `@Resolver(\"X\")`\n\t * with `@Query()` / `@Mutation()` / `@Subscription()` methods\n\t * contributes a `type X { ... }` or `extend type Query { ... }`\n\t * snippet.\n\t */\n\tprivate mergeSDLWithDecorators(sdl: string[]): string {\n\t\t// The framework's scanner injects decorator-discovered\n\t\t// resolvers into `this._resolvers` before the schema is\n\t\t// built. To keep things simple, the schema is built from\n\t\t// the user-supplied SDL only; the resolver map is attached\n\t\t// afterwards. We still allow simple `type X { ... }` SDL\n\t\t// shapes — the scanner's job is to fill the resolvers.\n\t\t//\n\t\t// (We could synthesise SDL from the resolver metadata for a\n\t\t// pure-code-first experience, but that requires guessing\n\t\t// types. Defer to v2.)\n\t\treturn sdl.join(\"\\n\");\n\t}\n}\n\n/**\n * Wrap a parsed schema with the user's resolver map. graphql-js's\n * `buildSchema` produces a schema with default resolvers (which look\n * up fields on the `rootValue`). For our use case, we want field-level\n * resolvers that pull from the registered `ResolverMap`.\n */\nfunction wrapSchemaWithResolvers(schema: any, resolvers: ResolverMap): any {\n\t// graphql-js schemas are immutable. We replace the resolver map\n\t// via a tiny proxy: when a field is queried, graphql-js's default\n\t// resolver calls our `defaultFieldResolver` (which simply looks\n\t// up the value in the parent). To wire our resolvers, we set\n\t// each field's `resolve` to the entry from the resolver map.\n\tconst typeMap = schema.getTypeMap?.() ?? {};\n\tfor (const [typeName, fields] of Object.entries(resolvers)) {\n\t\tconst type = typeMap[typeName];\n\t\tif (!type || typeof type.getFields !== \"function\") continue;\n\t\tconst fieldMap = type.getFields();\n\t\tfor (const [fieldName, resolver] of Object.entries(fields)) {\n\t\t\tconst field = fieldMap[fieldName];\n\t\t\tif (!field) continue;\n\t\t\tconst fn: FieldResolver =\n\t\t\t\ttypeof resolver === \"function\"\n\t\t\t\t\t? (resolver as FieldResolver)\n\t\t\t\t\t: ((resolver as { resolve: FieldResolver }).resolve as FieldResolver);\n\t\t\tfield.resolve = function (parent: any, args: any, ctx: any, info: any) {\n\t\t\t\treturn fn(parent, args, ctx, info);\n\t\t\t};\n\t\t}\n\t}\n\treturn schema;\n}\n",
|
|
6
|
-
"/**\n * `GraphQLModule` — drop-in GraphQL endpoint.\n *\n * @Module({\n * imports: [\n * GraphQLModule.forRoot({\n * typeDefs: `\n * type Query { hello: String! }\n * `,\n * resolvers: {\n * Query: {\n * hello: () => \"world\",\n * },\n * },\n * }),\n * ],\n * })\n * export class AppModule {}\n *\n * After boot, the framework exposes:\n *\n * POST /graphql — queries + mutations\n * GET /graphql — GraphiQL UI (or a query, if `?query=...` is set)\n * GET /graphql/schema — the schema as SDL (debug)\n *\n * Resolvers can also be declared via the `@Resolver` + `@Query` /\n * `@Mutation` / `@Subscription` decorators — see the user guide.\n */\nimport \"reflect-metadata\";\nimport type { Context } from \"hono\";\nimport { Module } from \"@nexusts/core
|
|
6
|
+
"/**\n * `GraphQLModule` — drop-in GraphQL endpoint.\n *\n * @Module({\n * imports: [\n * GraphQLModule.forRoot({\n * typeDefs: `\n * type Query { hello: String! }\n * `,\n * resolvers: {\n * Query: {\n * hello: () => \"world\",\n * },\n * },\n * }),\n * ],\n * })\n * export class AppModule {}\n *\n * After boot, the framework exposes:\n *\n * POST /graphql — queries + mutations\n * GET /graphql — GraphiQL UI (or a query, if `?query=...` is set)\n * GET /graphql/schema — the schema as SDL (debug)\n *\n * Resolvers can also be declared via the `@Resolver` + `@Query` /\n * `@Mutation` / `@Subscription` decorators — see the user guide.\n */\nimport \"reflect-metadata\";\nimport type { Context } from \"hono\";\nimport { Module } from \"@nexusts/core\";\nimport { GraphQLService } from \"./graphql.service.js\";\nimport type { GraphQLConfig } from \"./types.js\";\n\n@Module({\n\tproviders: [\n\t\tGraphQLService,\n\t\t{ provide: GraphQLService.TOKEN, useExisting: GraphQLService },\n\t],\n\texports: [GraphQLService, GraphQLService.TOKEN],\n})\nexport class GraphQLModule {\n\tstatic forRoot(config: GraphQLConfig) {\n\t\tconst factory = () => new GraphQLService(config);\n\t\t@Module({\n\t\t\tproviders: [\n\t\t\t\t{\n\t\t\t\t\tprovide: GraphQLService.TOKEN,\n\t\t\t\t\tuseFactory: factory,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tprovide: GraphQLService,\n\t\t\t\t\tuseFactory: factory,\n\t\t\t\t},\n\t\t\t\t{ provide: \"GRAPHQL_CONFIG\", useValue: config },\n\t\t\t],\n\t\t\texports: [GraphQLService, GraphQLService.TOKEN],\n\t\t})\n\t\tclass ConfiguredGraphQLModule {}\n\t\tObject.defineProperty(ConfiguredGraphQLModule, \"name\", {\n\t\t\tvalue: \"ConfiguredGraphQLModule\",\n\t\t});\n\t\treturn ConfiguredGraphQLModule;\n\t}\n\n\t/**\n\t * Manually mount the GraphQL endpoint onto a Hono-compatible app.\n\t * Used by `main.ts` setups that don't go through `@Module`.\n\t */\n\tstatic async mount(\n\t\tapp: {\n\t\t\tpost: (path: string, ...h: any[]) => any;\n\t\t\tget: (path: string, ...h: any[]) => any;\n\t\t\tuse: (path: string, ...h: any[]) => any;\n\t\t},\n\t\tsvc: GraphQLService,\n\t): Promise<void> {\n\t\tconst path = svc.config.endpoint?.path ?? \"/graphql\";\n\t\tconst enableGet = svc.config.endpoint?.enableGet ?? true;\n\t\tconst exposeSDL = svc.config.exposeSchemaSDL ?? true;\n\t\tconst playground = svc.config.playground ?? \"graphiql\";\n\n\t\t// POST /graphql — queries + mutations.\n\t\tapp.post(path, async (c: Context) => {\n\t\t\tconst body = await readRequestBody(c);\n\t\t\tconst ctx = await svc.buildContext(c);\n\t\t\tconst result = await svc.execute(\n\t\t\t\tbody.query,\n\t\t\t\tparseJSONField(body.variables) ?? {},\n\t\t\t\tbody.operationName || undefined,\n\t\t\t\tctx,\n\t\t\t);\n\t\t\treturn c.json(result, statusFor(result) as any);\n\t\t});\n\n\t\t// GET /graphql — playground / pre-baked query (?query=...&variables=...).\n\t\tif (enableGet) {\n\t\t\tapp.get(path, async (c: Context) => {\n\t\t\t\tconst query = c.req.query(\"query\");\n\t\t\t\tif (!query) {\n\t\t\t\t\tif (playground === \"none\") {\n\t\t\t\t\t\treturn c.text(\"GraphQL endpoint. Pass ?query=... for a pre-baked query.\", 200);\n\t\t\t\t\t}\n\t\t\t\t\treturn c.html(graphiqlHtml({ endpoint: path }), 200, {\n\t\t\t\t\t\t\"Content-Type\": \"text/html; charset=utf-8\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst ctx = await svc.buildContext(c);\n\t\t\t\tconst result = await svc.execute(\n\t\t\t\t\tquery,\n\t\t\t\t\tparseJSONField(c.req.query(\"variables\") ?? \"\") ?? {},\n\t\t\t\t\tc.req.query(\"operationName\") ?? undefined,\n\t\t\t\t\tctx,\n\t\t\t\t);\n\t\t\t\treturn c.json(result, statusFor(result) as any);\n\t\t\t});\n\t\t}\n\n\t\t// GET /graphql/schema — debug: print the raw SDL.\n\t\tif (exposeSDL) {\n\t\t\tapp.get(`${path}/schema`, (c: Context) => {\n\t\t\t\treturn c.text(svc.getSchemaSDL(), 200, {\n\t\t\t\t\t\"Content-Type\": \"text/plain; charset=utf-8\",\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\t// Force schema bootstrap so the first request isn't slow.\n\t\tawait svc.ensureSchema();\n\t}\n}\n\n/** Read a GraphQL request body. Accepts JSON or form-urlencoded. */\nasync function readRequestBody(\n\tc: Context,\n): Promise<{ query: string; variables: string; operationName: string }> {\n\tconst ct = c.req.header(\"content-type\") ?? \"\";\n\tif (ct.includes(\"application/json\")) {\n\t\ttry {\n\t\t\tconst j = await c.req.json() as Record<string, unknown>;\n\t\t\treturn {\n\t\t\t\tquery: String(j.query ?? \"\"),\n\t\t\t\tvariables: j.variables ? JSON.stringify(j.variables) : \"\",\n\t\t\t\toperationName: j.operationName ? String(j.operationName) : \"\",\n\t\t\t};\n\t\t} catch {\n\t\t\treturn { query: \"\", variables: \"\", operationName: \"\" };\n\t\t}\n\t}\n\tif (ct.includes(\"application/x-www-form-urlencoded\")) {\n\t\tconst text = await c.req.text();\n\t\tconst params = new URLSearchParams(text);\n\t\treturn {\n\t\t\tquery: params.get(\"query\") ?? \"\",\n\t\t\tvariables: params.get(\"variables\") ?? \"\",\n\t\t\toperationName: params.get(\"operationName\") ?? \"\",\n\t\t};\n\t}\n\t// Default: assume form-urlencoded.\n\tconst text = await c.req.text();\n\tconst params = new URLSearchParams(text);\n\treturn {\n\t\tquery: params.get(\"query\") ?? \"\",\n\t\tvariables: params.get(\"variables\") ?? \"\",\n\t\toperationName: params.get(\"operationName\") ?? \"\",\n\t};\n}\n\nfunction parseJSONField(raw: string): Record<string, unknown> | undefined {\n\tif (!raw) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (parsed && typeof parsed === \"object\") {\n\t\t\treturn parsed as Record<string, unknown>;\n\t\t}\n\t} catch {\n\t\t/* fall through */\n\t}\n\treturn undefined;\n}\n\nfunction statusFor(result: { errors?: unknown[]; data?: unknown }): number {\n\tif (result.errors && (result.errors as unknown[]).length > 0 && !result.data) return 400;\n\treturn 200;\n}\n\n/** Minimal GraphiQL HTML — single-page, no CDN, no external assets. */\nfunction graphiqlHtml(opts: { endpoint: string }): string {\n\treturn `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <title>GraphiQL</title>\n <style>\n body { font-family: system-ui, sans-serif; margin: 0; padding: 1em; }\n pre { background: #f5f5f5; padding: 0.6em; border-radius: 4px; overflow: auto; }\n .row { display: flex; gap: 1em; }\n textarea { width: 100%; min-height: 8em; font-family: ui-monospace, monospace; }\n button { padding: 0.4em 0.8em; }\n </style>\n</head>\n<body>\n <h2>GraphiQL (lightweight)</h2>\n <p>POST <code>${opts.endpoint}</code> · this is a no-deps playground built into\n <code>@nexusts/graphql</code>. For the full GraphiQL\n experience, see <code>graphiql</code> on npm.</p>\n <div class=\"row\">\n <textarea id=\"q\" placeholder=\"query { hello }\">{ hello }</textarea>\n </div>\n <p><button id=\"run\">Run</button> <span id=\"status\"></span></p>\n <pre id=\"out\"></pre>\n <script>\n const $q = document.getElementById(\"q\");\n const $out = document.getElementById(\"out\");\n const $status = document.getElementById(\"status\");\n document.getElementById(\"run\").onclick = async () => {\n $status.textContent = \"running…\";\n $out.textContent = \"\";\n const res = await fetch(${JSON.stringify(opts.endpoint)}, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ query: $q.value }),\n });\n const j = await res.json();\n $status.textContent = res.status + \" \" + res.statusText;\n $out.textContent = JSON.stringify(j, null, 2);\n };\n </script>\n</body>\n</html>`;\n}\n",
|
|
7
7
|
"/**\n * @Resolver(typeName?) decorator.\n *\n * Marks a class as a GraphQL resolver. The optional `typeName` argument\n * declares the GraphQL type this class is responsible for. If\n * omitted, the type name defaults to the class name (e.g.\n * `UserResolver` → type `User`).\n *\n * The framework's GraphQL scanner picks up every class with this\n * decorator and reads the field methods off it (decorators from\n * `./query.js`, `./mutation.js`, `./subscription.js`).\n *\n * @Resolver(\"User\")\n * class UserResolver {\n * @Query() me() { ... }\n * @Mutation() signup(@Arg(\"email\") e: string) { ... }\n * @Subscription() events() { ... }\n * }\n */\nimport \"reflect-metadata\";\nimport type { ResolverClassRecord } from \"../types.js\";\n\nconst RESOLVER_KEY = Symbol.for(\"nexus:GraphQL:Resolver\");\nconst FIELDS_KEY = Symbol.for(\"nexus:GraphQL:Fields\");\nconst TYPENAME_KEY = Symbol.for(\"nexus:GraphQL:TypeName\");\n\nexport function Resolver(typeName?: string): ClassDecorator {\n\treturn (target: Function) => {\n\t\tconst ctor = target as unknown as new (...args: any[]) => any;\n\t\tconst inferred = typeName ?? ctor.name.replace(/Resolver$/, \"\");\n\t\tReflect.defineMetadata(RESOLVER_KEY, true, ctor);\n\t\tReflect.defineMetadata(TYPENAME_KEY, inferred, ctor);\n\t\tif (!Reflect.hasMetadata(FIELDS_KEY, ctor)) {\n\t\t\tReflect.defineMetadata(FIELDS_KEY, [], ctor);\n\t\t}\n\t};\n}\n\n/** Read the type-name this resolver is for. */\nexport function getResolverTypeName(target: object): string | undefined {\n\tconst t = (target as { prototype?: object }).prototype ?? target;\n\tconst fromMeta = Reflect.getMetadata(TYPENAME_KEY, t);\n\tif (fromMeta) return fromMeta as string;\n\t// Fallback: derive from the class name (drop \"Resolver\" suffix).\n\tconst ctor = (t as { constructor?: { name: string } }).constructor;\n\treturn ctor?.name.replace(/Resolver$/, \"\");\n}\n\n/** Append a field method to the resolver class's metadata. */\nexport function pushResolverField(\n\ttarget: object,\n\tfield: ResolverClassRecord[\"fields\"][number],\n): void {\n\tconst t = (target as { prototype?: object }).prototype ?? target;\n\tconst list = (Reflect.getMetadata(FIELDS_KEY, t) as ResolverClassRecord[\"fields\"]) ?? [];\n\tlist.push(field);\n\tReflect.defineMetadata(FIELDS_KEY, list, t);\n}\n\n/** Read the field metadata for a resolver class. */\nexport function getResolverFields(target: object): ResolverClassRecord[\"fields\"] {\n\tconst t = (target as { prototype?: object }).prototype ?? target;\n\treturn (Reflect.getMetadata(FIELDS_KEY, t) as ResolverClassRecord[\"fields\"]) ?? [];\n}\n\n/** True if `target` was decorated with `@Resolver`. */\nexport function isResolverClass(target: object): boolean {\n\tconst t = (target as { prototype?: object }).prototype ?? target;\n\treturn Reflect.getMetadata(RESOLVER_KEY, t) === true;\n}\n",
|
|
8
8
|
"/**\n * `@Query(name?)` / `@Mutation(name?)` / `@Subscription(name?)`\n *\n * Method decorators that mark a resolver method as a GraphQL operation.\n * The optional `name` argument overrides the field name in the schema\n * (defaults to the method name).\n *\n * @Resolver(\"User\")\n * class UserResolver {\n * @Query(\"currentUser\")\n * me() { return ctx.state.user; }\n *\n * @Mutation()\n * updateProfile(@Arg(\"name\") name: string) { ... }\n *\n * @Subscription()\n * events() { return pubsub.asyncIterator(\"EVENTS\"); }\n * }\n */\nimport \"reflect-metadata\";\nimport { pushResolverField, getResolverTypeName } from \"./resolver.js\";\nimport type { ResolverClassRecord } from \"../types.js\";\n\ntype OperationKind = \"query\" | \"mutation\" | \"subscription\";\n\n/**\n * Common implementation. `decorator` is a factory the user calls as\n * `@Query(...)` / `@Mutation(...)` etc. We can't share one decorator\n * across kinds because we want per-kind runtime behavior to be\n * identical — only the discriminator string differs.\n */\nfunction makeOperationDecorator(kind: OperationKind) {\n\treturn function (name?: string) {\n\t\treturn (\n\t\t\ttarget: object,\n\t\t\tpropertyKey: string | symbol,\n\t\t\tdescriptor: TypedPropertyDescriptor<any>,\n\t\t): void => {\n\t\t\tconst meta = parseMethodType(descriptor.value);\n\t\t\tpushResolverField(target, {\n\t\t\t\tpropertyKey: String(propertyKey),\n\t\t\t\tkind,\n\t\t\t\tname: name ?? String(propertyKey),\n\t\t\t\treturnTypeName: meta.returnTypeName,\n\t\t\t\targs: meta.args,\n\t\t\t});\n\t\t};\n\t};\n}\n\n/** Reflect on a method's parameter list to extract `@Arg` names. */\nfunction parseMethodType(fn: Function): {\n\treturnTypeName: string;\n\targs: Array<{ name: string; type: string; defaultValue?: unknown }>;\n} {\n\t// We can't read parameter names at runtime in vanilla JS without\n\t// extra tooling (the TypeScript metadata API exposes types but\n\t// not parameter names). Convention: methods accept a single\n\t// `args` object whose keys are the GraphQL field arguments.\n\t//\n\t// For finer control, the user can call `@Arg(\"name\")` on\n\t// individual parameters (see `./arg.js`). The names are then\n\t// gathered by `@Arg` and merged at scan time.\n\tconst fnName = fn.name || \"unknown\";\n\treturn {\n\t\treturnTypeName: \"JSON\", // SDL \"JSON\" scalar until a more specific\n\t\t\t\t\t\t\t\t// type system is wired in.\n\t\targs: [],\n\t};\n}\n\nexport const Query = makeOperationDecorator(\"query\");\nexport const Mutation = makeOperationDecorator(\"mutation\");\nexport const Subscription = makeOperationDecorator(\"subscription\");\n\n/** Public helper for the scanner. */\nexport type AnyField = ResolverClassRecord[\"fields\"][number];\n",
|
|
9
9
|
"/**\n * `@Arg(name, type?)` parameter decorator.\n *\n * Declares a method parameter as a GraphQL field argument. Used on\n * resolver methods marked with `@Query`/`@Mutation`/`@Subscription`.\n *\n * @Mutation()\n * updateProfile(\n * @Arg(\"name\") name: string,\n * @Arg(\"email\", \"String!\") email: string,\n * ) { ... }\n *\n * The optional `type` argument is the SDL type (e.g. `\"String!\"`,\n * `\"Int\"`, `\"[User!]!\"`). When omitted, the framework uses `\"String\"`\n * as a safe default — explicit is better than implicit.\n */\nimport \"reflect-metadata\";\nimport { pushResolverField, getResolverTypeName } from \"./resolver.js\";\n\nconst ARGS_KEY = Symbol.for(\"nexus:GraphQL:MethodArgs\");\n\nexport function Arg(name: string, type: string = \"String\"): ParameterDecorator {\n\treturn (\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol | undefined,\n\t\tparameterIndex: number,\n\t) => {\n\t\tif (propertyKey === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"@Arg() can only decorate method parameters, not constructor parameters.\",\n\t\t\t);\n\t\t}\n\t\tconst list = (Reflect.getMetadata(ARGS_KEY, target, propertyKey) as\n\t\t\t| Array<{ name: string; type: string; index: number }>\n\t\t\t| undefined) ?? [];\n\t\tlist.push({ name, type, index: parameterIndex });\n\t\tReflect.defineMetadata(ARGS_KEY, list, target, propertyKey);\n\t};\n}\n\n/** Read `@Arg` metadata for a specific method. */\nexport function getMethodArgs(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): Array<{ name: string; type: string; index: number }> {\n\treturn (Reflect.getMetadata(ARGS_KEY, target, propertyKey) as\n\t\t| Array<{ name: string; type: string; index: number }>\n\t\t| undefined) ?? [];\n}\n"
|
|
10
10
|
],
|
|
11
|
-
"mappings": "
|
|
12
|
-
"debugId": "
|
|
11
|
+
"mappings": ";;;;;;;;;;;;;AAcA;AAmCA,IAAI,WAA6B;AACjC,IAAI,iBAAiB;AAGrB,eAAsB,aAAa,GAAuB;AAAA,EACzD,IAAI;AAAA,IAAU,OAAO;AAAA,EACrB,IAAI,gBAAgB;AAAA,IACnB,MAAM,IAAI,MACT,sEACC,8DACF;AAAA,EACD;AAAA,EACA,iBAAiB;AAAA,EACjB,IAAI;AAAA,IACH,MAAM,MAAO,MAAa;AAAA,IAC1B,WAAW;AAAA,IACX,OAAO;AAAA,IACN,OAAO,K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;AAAA,QACzB,aAAa,OAAO,WAAW;AAAA,QAC/B;AAAA,QACA,MAAM,QAAQ,OAAO,WAAW;AAAA,QAChC,gBAAgB,KAAK;AAAA,QACrB,MAAM,KAAK;AAAA,MACZ,CAAC;AAAA;AAAA;AAAA;AAMJ,SAAS,eAAe,CAAC,IAGvB;AAAA,EASD,MAAM,SAAS,GAAG,QAAQ;AAAA,EAC1B,OAAO;AAAA,IACN,gBAAgB;AAAA,IAEhB,MAAM,CAAC;AAAA,EACR;AAAA;AAGM,IAAM,QAAQ,uBAAuB,OAAO;AAC5C,IAAM,WAAW,uBAAuB,UAAU;AAClD,IAAM,eAAe,uBAAuB,cAAc;;ACzDjE;AAGA,IAAM,WAAW,OAAO,IAAI,0BAA0B;AAE/C,SAAS,GAAG,CAAC,MAAc,OAAe,UAA8B;AAAA,EAC9E,OAAO,CACN,QACA,aACA,mBACI;AAAA,IACJ,IAAI,gBAAgB,WAAW;AAAA,MAC9B,MAAM,IAAI,MACT,yEACD;AAAA,IACD;AAAA,IACA,MAAM,OAAQ,QAAQ,YAAY,UAAU,QAAQ,WAAW,KAE9C,CAAC;AAAA,IAClB,KAAK,KAAK,EAAE,MAAM,MAAM,OAAO,eAAe,CAAC;AAAA,IAC/C,QAAQ,eAAe,UAAU,MAAM,QAAQ,WAAW;AAAA;AAAA;AAKrD,SAAS,aAAa,CAC5B,QACA,aACuD;AAAA,EACvD,OAAQ,QAAQ,YAAY,UAAU,QAAQ,WAAW,KAExC,CAAC;AAAA;",
|
|
12
|
+
"debugId": "6421516686033CD864756E2164756E21",
|
|
13
13
|
"names": []
|
|
14
14
|
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nexusjs/graphql` — code-first GraphQL via Bun-native executor.
|
|
3
|
+
*
|
|
4
|
+
* Public types and interfaces. The framework exposes a minimal but
|
|
5
|
+
* complete GraphQL surface (queries, mutations, subscriptions,
|
|
6
|
+
* SDL-first or code-first via class decorators, and a Hono-native
|
|
7
|
+
* `/graphql` endpoint with introspection).
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from "hono";
|
|
10
|
+
/** Anything that can be passed as a resolver argument. */
|
|
11
|
+
export type ResolverArgValue = string | number | boolean | null | undefined | object | bigint | symbol;
|
|
12
|
+
/**
|
|
13
|
+
* Standard resolver signature. Mirrors graphql-js's 4-tuple form
|
|
14
|
+
* with the same names: `(parent, args, context, info)`.
|
|
15
|
+
*
|
|
16
|
+
* The `TArgs` generic defaults to `Record<string, any>` so a resolver
|
|
17
|
+
* can type its arguments explicitly. Without the generic, TS would
|
|
18
|
+
* narrow the runtime's `args: Record<string, any>` against the
|
|
19
|
+
* function's declared `{ name: string }` and complain.
|
|
20
|
+
*/
|
|
21
|
+
export type ResolverFn<TResult = unknown, TArgs = Record<string, any>, TParent = any> = (parent: TParent, args: TArgs, context: GraphQLContext, info: GraphQLResolveInfo) => TResult | Promise<TResult>;
|
|
22
|
+
/** What a controller method decorated with `@Query`/`@Mutation` actually is. */
|
|
23
|
+
export type FieldResolver<TResult = unknown, TArgs = Record<string, any>, TParent = any> = ResolverFn<TResult, TArgs, TParent>;
|
|
24
|
+
/** The full GraphQL execution context exposed to resolvers. */
|
|
25
|
+
export interface GraphQLContext {
|
|
26
|
+
/** The Hono context for the inbound request. */
|
|
27
|
+
hono: Context;
|
|
28
|
+
/** Application-provided per-request data (auth user, db tx, ...). */
|
|
29
|
+
state: Record<string, any>;
|
|
30
|
+
}
|
|
31
|
+
/** A tiny stand-in for graphql-js's `GraphQLResolveInfo` — covers
|
|
32
|
+
* the field name and the parent type name, which is all a
|
|
33
|
+
* resolver typically needs. */
|
|
34
|
+
export interface GraphQLResolveInfo {
|
|
35
|
+
fieldName: string;
|
|
36
|
+
fieldNodes: ReadonlyArray<{
|
|
37
|
+
kind: string;
|
|
38
|
+
name: {
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
parentType: {
|
|
43
|
+
name: string;
|
|
44
|
+
toString(): string;
|
|
45
|
+
};
|
|
46
|
+
path: {
|
|
47
|
+
key: string | number;
|
|
48
|
+
typename: string | null | undefined;
|
|
49
|
+
}[];
|
|
50
|
+
returnType: {
|
|
51
|
+
toString(): string;
|
|
52
|
+
};
|
|
53
|
+
schema: unknown;
|
|
54
|
+
operation: {
|
|
55
|
+
kind: "query" | "mutation" | "subscription";
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Where to mount the GraphQL endpoint. Default: POST /graphql. */
|
|
59
|
+
export interface GraphQLEndpoint {
|
|
60
|
+
/** Single endpoint that handles queries + mutations. */
|
|
61
|
+
path: string;
|
|
62
|
+
/** Optional GET endpoint for SSE-based subscriptions. */
|
|
63
|
+
subscriptionsPath?: string;
|
|
64
|
+
/** Enable GET (in addition to POST) for the main endpoint.
|
|
65
|
+
* Browsers send GET for persisted queries / static queries. */
|
|
66
|
+
enableGet?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** Optional playground / explorer UI mounted at the same path. */
|
|
69
|
+
export type PlaygroundUI = "graphiql" | "graphql-playground" | "none";
|
|
70
|
+
/** Top-level config for the GraphQL module. */
|
|
71
|
+
export interface GraphQLConfig {
|
|
72
|
+
/** SDL typeDefs. Either this OR the decorator-driven code-first
|
|
73
|
+
* approach is required. Both can coexist in the same schema. */
|
|
74
|
+
typeDefs?: string | string[];
|
|
75
|
+
/** Resolver map (optional). When omitted, the framework builds
|
|
76
|
+
* the resolver map from `@Query`/`@Mutation`/`@Subscription`
|
|
77
|
+
* decorators on registered controllers. */
|
|
78
|
+
resolvers?: ResolverMap;
|
|
79
|
+
/** Endpoint config. */
|
|
80
|
+
endpoint?: GraphQLEndpoint;
|
|
81
|
+
/** UI config. Default: "graphiql". Set to "none" to disable. */
|
|
82
|
+
playground?: PlaygroundUI;
|
|
83
|
+
/** Context factory — called once per request. Use this to inject
|
|
84
|
+
* the auth user, db transaction, request scope, etc. */
|
|
85
|
+
context?: (c: Context) => Record<string, any> | Promise<Record<string, any>>;
|
|
86
|
+
/** Whether to expose the full schema as SDL at GET /graphql/schema. */
|
|
87
|
+
exposeSchemaSDL?: boolean;
|
|
88
|
+
/** Enable introspection at runtime (disable in production). */
|
|
89
|
+
introspection?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** The shape of a hand-written resolver map. */
|
|
92
|
+
export interface ResolverMap {
|
|
93
|
+
[TypeName: string]: {
|
|
94
|
+
[fieldName: string]: FieldResolver | {
|
|
95
|
+
resolve: FieldResolver;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** A registered resolver class — collected by the scanner. */
|
|
100
|
+
export interface ResolverClassRecord {
|
|
101
|
+
/** The class constructor. */
|
|
102
|
+
target: new (...args: any[]) => any;
|
|
103
|
+
/** Symbol-keyed metadata. */
|
|
104
|
+
__resolverTypeName: string;
|
|
105
|
+
/** All field methods with their operation kind. */
|
|
106
|
+
fields: Array<{
|
|
107
|
+
propertyKey: string;
|
|
108
|
+
kind: "query" | "mutation" | "subscription";
|
|
109
|
+
name: string;
|
|
110
|
+
returnTypeName: string;
|
|
111
|
+
args: Array<{
|
|
112
|
+
name: string;
|
|
113
|
+
type: string;
|
|
114
|
+
defaultValue?: unknown;
|
|
115
|
+
}>;
|
|
116
|
+
description?: string;
|
|
117
|
+
deprecationReason?: string;
|
|
118
|
+
}>;
|
|
119
|
+
}
|
|
120
|
+
/** Execution result envelope. */
|
|
121
|
+
export interface GraphQLExecutionResult {
|
|
122
|
+
data?: Record<string, any> | null;
|
|
123
|
+
errors?: Array<{
|
|
124
|
+
message: string;
|
|
125
|
+
path?: (string | number)[];
|
|
126
|
+
locations?: {
|
|
127
|
+
line: number;
|
|
128
|
+
column: number;
|
|
129
|
+
}[];
|
|
130
|
+
}>;
|
|
131
|
+
extensions?: Record<string, any>;
|
|
132
|
+
}
|
|
133
|
+
/** Lifecycle hook for resolver classes. */
|
|
134
|
+
export interface ResolverLifecycle {
|
|
135
|
+
/** Called once when the schema is built. */
|
|
136
|
+
onSchemaInit?(): void | Promise<void>;
|
|
137
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexusts/graphql",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "SDL-first GraphQL endpoint with @Resolver decorators",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nexusts/core": "^0.7.
|
|
37
|
+
"@nexusts/core": "^0.7.2"
|
|
38
38
|
}
|
|
39
39
|
}
|