@effect-gql/core 0.1.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/LICENSE +7 -0
- package/dist/analyzer-extension.d.ts +105 -0
- package/dist/analyzer-extension.d.ts.map +1 -0
- package/dist/analyzer-extension.js +137 -0
- package/dist/analyzer-extension.js.map +1 -0
- package/dist/builder/execute.d.ts +26 -0
- package/dist/builder/execute.d.ts.map +1 -0
- package/dist/builder/execute.js +104 -0
- package/dist/builder/execute.js.map +1 -0
- package/dist/builder/field-builders.d.ts +30 -0
- package/dist/builder/field-builders.d.ts.map +1 -0
- package/dist/builder/field-builders.js +200 -0
- package/dist/builder/field-builders.js.map +1 -0
- package/dist/builder/index.d.ts +7 -0
- package/dist/builder/index.d.ts.map +1 -0
- package/dist/builder/index.js +31 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/pipe-api.d.ts +231 -0
- package/dist/builder/pipe-api.d.ts.map +1 -0
- package/dist/builder/pipe-api.js +151 -0
- package/dist/builder/pipe-api.js.map +1 -0
- package/dist/builder/schema-builder.d.ts +301 -0
- package/dist/builder/schema-builder.d.ts.map +1 -0
- package/dist/builder/schema-builder.js +566 -0
- package/dist/builder/schema-builder.js.map +1 -0
- package/dist/builder/type-registry.d.ts +80 -0
- package/dist/builder/type-registry.d.ts.map +1 -0
- package/dist/builder/type-registry.js +505 -0
- package/dist/builder/type-registry.js.map +1 -0
- package/dist/builder/types.d.ts +283 -0
- package/dist/builder/types.d.ts.map +1 -0
- package/dist/builder/types.js +3 -0
- package/dist/builder/types.js.map +1 -0
- package/dist/cli/generate-schema.d.ts +29 -0
- package/dist/cli/generate-schema.d.ts.map +1 -0
- package/dist/cli/generate-schema.js +233 -0
- package/dist/cli/generate-schema.js.map +1 -0
- package/dist/cli/index.d.ts +19 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +24 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/context.d.ts +18 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +11 -0
- package/dist/context.js.map +1 -0
- package/dist/error.d.ts +45 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +29 -0
- package/dist/error.js.map +1 -0
- package/dist/extensions.d.ts +130 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +78 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +169 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +237 -0
- package/dist/loader.js.map +1 -0
- package/dist/resolver-context.d.ts +154 -0
- package/dist/resolver-context.d.ts.map +1 -0
- package/dist/resolver-context.js +184 -0
- package/dist/resolver-context.js.map +1 -0
- package/dist/schema-mapping.d.ts +30 -0
- package/dist/schema-mapping.d.ts.map +1 -0
- package/dist/schema-mapping.js +280 -0
- package/dist/schema-mapping.js.map +1 -0
- package/dist/server/cache-control.d.ts +96 -0
- package/dist/server/cache-control.d.ts.map +1 -0
- package/dist/server/cache-control.js +308 -0
- package/dist/server/cache-control.js.map +1 -0
- package/dist/server/complexity.d.ts +165 -0
- package/dist/server/complexity.d.ts.map +1 -0
- package/dist/server/complexity.js +433 -0
- package/dist/server/complexity.js.map +1 -0
- package/dist/server/config.d.ts +66 -0
- package/dist/server/config.d.ts.map +1 -0
- package/dist/server/config.js +104 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/graphiql.d.ts +5 -0
- package/dist/server/graphiql.d.ts.map +1 -0
- package/dist/server/graphiql.js +43 -0
- package/dist/server/graphiql.js.map +1 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +48 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/router.d.ts +79 -0
- package/dist/server/router.d.ts.map +1 -0
- package/dist/server/router.js +232 -0
- package/dist/server/router.js.map +1 -0
- package/dist/server/schema-builder-extensions.d.ts +42 -0
- package/dist/server/schema-builder-extensions.d.ts.map +1 -0
- package/dist/server/schema-builder-extensions.js +48 -0
- package/dist/server/schema-builder-extensions.js.map +1 -0
- package/dist/server/sse-adapter.d.ts +64 -0
- package/dist/server/sse-adapter.d.ts.map +1 -0
- package/dist/server/sse-adapter.js +227 -0
- package/dist/server/sse-adapter.js.map +1 -0
- package/dist/server/sse-types.d.ts +192 -0
- package/dist/server/sse-types.d.ts.map +1 -0
- package/dist/server/sse-types.js +63 -0
- package/dist/server/sse-types.js.map +1 -0
- package/dist/server/ws-adapter.d.ts +39 -0
- package/dist/server/ws-adapter.d.ts.map +1 -0
- package/dist/server/ws-adapter.js +247 -0
- package/dist/server/ws-adapter.js.map +1 -0
- package/dist/server/ws-types.d.ts +169 -0
- package/dist/server/ws-types.d.ts.map +1 -0
- package/dist/server/ws-types.js +11 -0
- package/dist/server/ws-types.js.map +1 -0
- package/dist/server/ws-utils.d.ts +42 -0
- package/dist/server/ws-utils.d.ts.map +1 -0
- package/dist/server/ws-utils.js +99 -0
- package/dist/server/ws-utils.js.map +1 -0
- package/package.json +61 -0
- package/src/analyzer-extension.ts +254 -0
- package/src/builder/execute.ts +153 -0
- package/src/builder/field-builders.ts +322 -0
- package/src/builder/index.ts +48 -0
- package/src/builder/pipe-api.ts +312 -0
- package/src/builder/schema-builder.ts +970 -0
- package/src/builder/type-registry.ts +670 -0
- package/src/builder/types.ts +305 -0
- package/src/context.ts +23 -0
- package/src/error.ts +32 -0
- package/src/extensions.ts +240 -0
- package/src/index.ts +32 -0
- package/src/loader.ts +363 -0
- package/src/resolver-context.ts +253 -0
- package/src/schema-mapping.ts +307 -0
- package/src/server/cache-control.ts +590 -0
- package/src/server/complexity.ts +774 -0
- package/src/server/config.ts +174 -0
- package/src/server/graphiql.ts +38 -0
- package/src/server/index.ts +96 -0
- package/src/server/router.ts +432 -0
- package/src/server/schema-builder-extensions.ts +51 -0
- package/src/server/sse-adapter.ts +327 -0
- package/src/server/sse-types.ts +234 -0
- package/src/server/ws-adapter.ts +355 -0
- package/src/server/ws-types.ts +192 -0
- package/src/server/ws-utils.ts +136 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { FieldRegistration, TypeRegistration, InterfaceRegistration, EnumRegistration, UnionRegistration, InputTypeRegistration, DirectiveApplication, DirectiveRegistration, MiddlewareContext, MiddlewareRegistration, SubscriptionFieldRegistration, ObjectFieldRegistration, GraphQLEffectContext, TypeRegistries, CacheHint, CacheControlScope, } from "./types";
|
|
2
|
+
export { DirectiveLocation } from "graphql";
|
|
3
|
+
export { GraphQLSchemaBuilder } from "./schema-builder";
|
|
4
|
+
export { objectType, interfaceType, enumType, unionType, inputType, directive, middleware, extension, query, mutation, subscription, field, compose, } from "./pipe-api";
|
|
5
|
+
export { execute } from "./execute";
|
|
6
|
+
export { getSchemaName } from "./type-registry";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builder/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,cAAc,EACd,SAAS,EACT,iBAAiB,GAClB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAG3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAGvD,OAAO,EACL,UAAU,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,OAAO,GACR,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSchemaName = exports.execute = exports.compose = exports.field = exports.subscription = exports.mutation = exports.query = exports.extension = exports.middleware = exports.directive = exports.inputType = exports.unionType = exports.enumType = exports.interfaceType = exports.objectType = exports.GraphQLSchemaBuilder = exports.DirectiveLocation = void 0;
|
|
4
|
+
// Re-export DirectiveLocation for convenience
|
|
5
|
+
var graphql_1 = require("graphql");
|
|
6
|
+
Object.defineProperty(exports, "DirectiveLocation", { enumerable: true, get: function () { return graphql_1.DirectiveLocation; } });
|
|
7
|
+
// Re-export schema builder
|
|
8
|
+
var schema_builder_1 = require("./schema-builder");
|
|
9
|
+
Object.defineProperty(exports, "GraphQLSchemaBuilder", { enumerable: true, get: function () { return schema_builder_1.GraphQLSchemaBuilder; } });
|
|
10
|
+
// Re-export pipe-able API
|
|
11
|
+
var pipe_api_1 = require("./pipe-api");
|
|
12
|
+
Object.defineProperty(exports, "objectType", { enumerable: true, get: function () { return pipe_api_1.objectType; } });
|
|
13
|
+
Object.defineProperty(exports, "interfaceType", { enumerable: true, get: function () { return pipe_api_1.interfaceType; } });
|
|
14
|
+
Object.defineProperty(exports, "enumType", { enumerable: true, get: function () { return pipe_api_1.enumType; } });
|
|
15
|
+
Object.defineProperty(exports, "unionType", { enumerable: true, get: function () { return pipe_api_1.unionType; } });
|
|
16
|
+
Object.defineProperty(exports, "inputType", { enumerable: true, get: function () { return pipe_api_1.inputType; } });
|
|
17
|
+
Object.defineProperty(exports, "directive", { enumerable: true, get: function () { return pipe_api_1.directive; } });
|
|
18
|
+
Object.defineProperty(exports, "middleware", { enumerable: true, get: function () { return pipe_api_1.middleware; } });
|
|
19
|
+
Object.defineProperty(exports, "extension", { enumerable: true, get: function () { return pipe_api_1.extension; } });
|
|
20
|
+
Object.defineProperty(exports, "query", { enumerable: true, get: function () { return pipe_api_1.query; } });
|
|
21
|
+
Object.defineProperty(exports, "mutation", { enumerable: true, get: function () { return pipe_api_1.mutation; } });
|
|
22
|
+
Object.defineProperty(exports, "subscription", { enumerable: true, get: function () { return pipe_api_1.subscription; } });
|
|
23
|
+
Object.defineProperty(exports, "field", { enumerable: true, get: function () { return pipe_api_1.field; } });
|
|
24
|
+
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return pipe_api_1.compose; } });
|
|
25
|
+
// Re-export execute helper
|
|
26
|
+
var execute_1 = require("./execute");
|
|
27
|
+
Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return execute_1.execute; } });
|
|
28
|
+
// Re-export utilities that may be useful externally
|
|
29
|
+
var type_registry_1 = require("./type-registry");
|
|
30
|
+
Object.defineProperty(exports, "getSchemaName", { enumerable: true, get: function () { return type_registry_1.getSchemaName; } });
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builder/index.ts"],"names":[],"mappings":";;;AAoBA,8CAA8C;AAC9C,mCAA2C;AAAlC,4GAAA,iBAAiB,OAAA;AAE1B,2BAA2B;AAC3B,mDAAuD;AAA9C,sHAAA,oBAAoB,OAAA;AAE7B,0BAA0B;AAC1B,uCAcmB;AAbjB,sGAAA,UAAU,OAAA;AACV,yGAAA,aAAa,OAAA;AACb,oGAAA,QAAQ,OAAA;AACR,qGAAA,SAAS,OAAA;AACT,qGAAA,SAAS,OAAA;AACT,qGAAA,SAAS,OAAA;AACT,sGAAA,UAAU,OAAA;AACV,qGAAA,SAAS,OAAA;AACT,iGAAA,KAAK,OAAA;AACL,oGAAA,QAAQ,OAAA;AACR,wGAAA,YAAY,OAAA;AACZ,iGAAA,KAAK,OAAA;AACL,mGAAA,OAAO,OAAA;AAGT,2BAA2B;AAC3B,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAEhB,oDAAoD;AACpD,iDAA+C;AAAtC,8GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { Effect, Stream } from "effect";
|
|
2
|
+
import * as S from "effect/Schema";
|
|
3
|
+
import { DirectiveLocation, GraphQLResolveInfo, DocumentNode, ExecutionResult, GraphQLError } from "graphql";
|
|
4
|
+
import type { DirectiveApplication, MiddlewareContext, CacheHint } from "./types";
|
|
5
|
+
import type { ExecutionArgs } from "../extensions";
|
|
6
|
+
import { GraphQLSchemaBuilder } from "./schema-builder";
|
|
7
|
+
import type { FieldComplexity } from "../server/complexity";
|
|
8
|
+
/**
|
|
9
|
+
* Add an object type to the schema builder (pipe-able)
|
|
10
|
+
* Name is optional if schema is TaggedStruct, TaggedClass, or Schema.Class
|
|
11
|
+
*/
|
|
12
|
+
export declare const objectType: <A, R2 = never>(config: {
|
|
13
|
+
name?: string;
|
|
14
|
+
schema: S.Schema<A, any, any>;
|
|
15
|
+
implements?: readonly string[];
|
|
16
|
+
directives?: readonly DirectiveApplication[];
|
|
17
|
+
/**
|
|
18
|
+
* Default cache control hint for all fields returning this type.
|
|
19
|
+
* Can be overridden by field-level cacheControl.
|
|
20
|
+
*/
|
|
21
|
+
cacheControl?: CacheHint;
|
|
22
|
+
fields?: Record<string, {
|
|
23
|
+
type: S.Schema<any, any, any>;
|
|
24
|
+
args?: S.Schema<any, any, any>;
|
|
25
|
+
description?: string;
|
|
26
|
+
directives?: readonly DirectiveApplication[];
|
|
27
|
+
complexity?: FieldComplexity;
|
|
28
|
+
cacheControl?: CacheHint;
|
|
29
|
+
resolve: (parent: A, args: any) => Effect.Effect<any, any, any>;
|
|
30
|
+
}>;
|
|
31
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R | R2>;
|
|
32
|
+
/**
|
|
33
|
+
* Add an interface type to the schema builder (pipe-able)
|
|
34
|
+
* Name is optional if schema is TaggedStruct, TaggedClass, or Schema.Class
|
|
35
|
+
*/
|
|
36
|
+
export declare const interfaceType: (config: {
|
|
37
|
+
name?: string;
|
|
38
|
+
schema: S.Schema<any, any, any>;
|
|
39
|
+
resolveType?: (value: any) => string;
|
|
40
|
+
directives?: readonly DirectiveApplication[];
|
|
41
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R>;
|
|
42
|
+
/**
|
|
43
|
+
* Add an enum type to the schema builder (pipe-able)
|
|
44
|
+
*/
|
|
45
|
+
export declare const enumType: (config: {
|
|
46
|
+
name: string;
|
|
47
|
+
values: readonly string[];
|
|
48
|
+
description?: string;
|
|
49
|
+
directives?: readonly DirectiveApplication[];
|
|
50
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R>;
|
|
51
|
+
/**
|
|
52
|
+
* Add a union type to the schema builder (pipe-able)
|
|
53
|
+
*/
|
|
54
|
+
export declare const unionType: (config: {
|
|
55
|
+
name: string;
|
|
56
|
+
types: readonly string[];
|
|
57
|
+
resolveType?: (value: any) => string;
|
|
58
|
+
directives?: readonly DirectiveApplication[];
|
|
59
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R>;
|
|
60
|
+
/**
|
|
61
|
+
* Add an input type to the schema builder (pipe-able)
|
|
62
|
+
* Name is optional if schema is TaggedStruct, TaggedClass, or Schema.Class
|
|
63
|
+
*/
|
|
64
|
+
export declare const inputType: (config: {
|
|
65
|
+
name?: string;
|
|
66
|
+
schema: S.Schema<any, any, any>;
|
|
67
|
+
description?: string;
|
|
68
|
+
directives?: readonly DirectiveApplication[];
|
|
69
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R>;
|
|
70
|
+
/**
|
|
71
|
+
* Register a directive (pipe-able)
|
|
72
|
+
*
|
|
73
|
+
* @param config - Directive configuration
|
|
74
|
+
* @param config.name - The directive name (without @)
|
|
75
|
+
* @param config.description - Optional description
|
|
76
|
+
* @param config.locations - Array of DirectiveLocation values where this directive can be applied
|
|
77
|
+
* @param config.args - Optional Effect Schema for directive arguments
|
|
78
|
+
* @param config.apply - Optional function to transform resolver Effects (for executable directives)
|
|
79
|
+
*/
|
|
80
|
+
export declare const directive: <Args = void, R2 = never>(config: {
|
|
81
|
+
name: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
locations: readonly DirectiveLocation[];
|
|
84
|
+
args?: S.Schema<Args, any, any>;
|
|
85
|
+
apply?: (args: Args) => <A, E, R3>(effect: Effect.Effect<A, E, R3>) => Effect.Effect<A, E, R2 | R3>;
|
|
86
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R | R2>;
|
|
87
|
+
/**
|
|
88
|
+
* Register a middleware (pipe-able)
|
|
89
|
+
*
|
|
90
|
+
* Middleware wraps all resolvers (or those matching a pattern) and executes
|
|
91
|
+
* in an "onion" model - first registered middleware is the outermost layer.
|
|
92
|
+
*
|
|
93
|
+
* @param config.name - Middleware name (for debugging/logging)
|
|
94
|
+
* @param config.description - Optional description
|
|
95
|
+
* @param config.match - Optional predicate to filter which fields this applies to
|
|
96
|
+
* @param config.apply - Function that transforms the resolver Effect
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* GraphQLSchemaBuilder.empty.pipe(
|
|
101
|
+
* middleware({
|
|
102
|
+
* name: "logging",
|
|
103
|
+
* apply: (effect, ctx) => Effect.gen(function*() {
|
|
104
|
+
* yield* Effect.logInfo(`Resolving ${ctx.info.fieldName}`)
|
|
105
|
+
* return yield* effect
|
|
106
|
+
* })
|
|
107
|
+
* }),
|
|
108
|
+
* middleware({
|
|
109
|
+
* name: "adminOnly",
|
|
110
|
+
* match: (info) => info.fieldName.startsWith("admin"),
|
|
111
|
+
* apply: (effect) => Effect.gen(function*() {
|
|
112
|
+
* const auth = yield* AuthService
|
|
113
|
+
* yield* auth.requireAdmin()
|
|
114
|
+
* return yield* effect
|
|
115
|
+
* })
|
|
116
|
+
* })
|
|
117
|
+
* )
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare const middleware: <R2 = never>(config: {
|
|
121
|
+
name: string;
|
|
122
|
+
description?: string;
|
|
123
|
+
match?: (info: GraphQLResolveInfo) => boolean;
|
|
124
|
+
apply: <A, E, R3>(effect: Effect.Effect<A, E, R3>, context: MiddlewareContext) => Effect.Effect<A, E, R2 | R3>;
|
|
125
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R | R2>;
|
|
126
|
+
/**
|
|
127
|
+
* Register an extension (pipe-able)
|
|
128
|
+
*
|
|
129
|
+
* Extensions provide lifecycle hooks that run at each phase of request processing
|
|
130
|
+
* (parse, validate, execute) and can contribute data to the response's extensions field.
|
|
131
|
+
*
|
|
132
|
+
* @param config.name - Extension name (for debugging/logging)
|
|
133
|
+
* @param config.description - Optional description
|
|
134
|
+
* @param config.onParse - Called after query parsing
|
|
135
|
+
* @param config.onValidate - Called after validation
|
|
136
|
+
* @param config.onExecuteStart - Called before execution begins
|
|
137
|
+
* @param config.onExecuteEnd - Called after execution completes
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* GraphQLSchemaBuilder.empty.pipe(
|
|
142
|
+
* extension({
|
|
143
|
+
* name: "tracing",
|
|
144
|
+
* onExecuteStart: () => Effect.gen(function*() {
|
|
145
|
+
* const ext = yield* ExtensionsService
|
|
146
|
+
* yield* ext.set("tracing", { startTime: Date.now() })
|
|
147
|
+
* }),
|
|
148
|
+
* onExecuteEnd: () => Effect.gen(function*() {
|
|
149
|
+
* const ext = yield* ExtensionsService
|
|
150
|
+
* yield* ext.merge("tracing", { endTime: Date.now() })
|
|
151
|
+
* }),
|
|
152
|
+
* })
|
|
153
|
+
* )
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare const extension: <R2 = never>(config: {
|
|
157
|
+
name: string;
|
|
158
|
+
description?: string;
|
|
159
|
+
onParse?: (source: string, document: DocumentNode) => Effect.Effect<void, never, R2>;
|
|
160
|
+
onValidate?: (document: DocumentNode, errors: readonly GraphQLError[]) => Effect.Effect<void, never, R2>;
|
|
161
|
+
onExecuteStart?: (args: ExecutionArgs) => Effect.Effect<void, never, R2>;
|
|
162
|
+
onExecuteEnd?: (result: ExecutionResult) => Effect.Effect<void, never, R2>;
|
|
163
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R | R2>;
|
|
164
|
+
/**
|
|
165
|
+
* Add a query field to the schema builder (pipe-able)
|
|
166
|
+
*/
|
|
167
|
+
export declare const query: <A, E, R2, Args = void>(name: string, config: {
|
|
168
|
+
type: S.Schema<A, any, any>;
|
|
169
|
+
args?: S.Schema<Args, any, any>;
|
|
170
|
+
description?: string;
|
|
171
|
+
directives?: readonly DirectiveApplication[];
|
|
172
|
+
complexity?: FieldComplexity;
|
|
173
|
+
cacheControl?: CacheHint;
|
|
174
|
+
resolve: (args: Args) => Effect.Effect<A, E, R2>;
|
|
175
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R | R2>;
|
|
176
|
+
/**
|
|
177
|
+
* Add a mutation field to the schema builder (pipe-able)
|
|
178
|
+
*/
|
|
179
|
+
export declare const mutation: <A, E, R2, Args = void>(name: string, config: {
|
|
180
|
+
type: S.Schema<A, any, any>;
|
|
181
|
+
args?: S.Schema<Args, any, any>;
|
|
182
|
+
description?: string;
|
|
183
|
+
directives?: readonly DirectiveApplication[];
|
|
184
|
+
complexity?: FieldComplexity;
|
|
185
|
+
resolve: (args: Args) => Effect.Effect<A, E, R2>;
|
|
186
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R | R2>;
|
|
187
|
+
/**
|
|
188
|
+
* Add a subscription field to the schema builder (pipe-able)
|
|
189
|
+
*
|
|
190
|
+
* Subscriptions return a Stream that yields values over time.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* GraphQLSchemaBuilder.empty.pipe(
|
|
195
|
+
* subscription("userCreated", {
|
|
196
|
+
* type: User,
|
|
197
|
+
* subscribe: Effect.gen(function*() {
|
|
198
|
+
* const pubsub = yield* PubSubService
|
|
199
|
+
* return pubsub.subscribe("USER_CREATED")
|
|
200
|
+
* }),
|
|
201
|
+
* })
|
|
202
|
+
* )
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
export declare const subscription: <A, E, R2, Args = void>(name: string, config: {
|
|
206
|
+
type: S.Schema<A, any, any>;
|
|
207
|
+
args?: S.Schema<Args, any, any>;
|
|
208
|
+
description?: string;
|
|
209
|
+
directives?: readonly DirectiveApplication[];
|
|
210
|
+
complexity?: FieldComplexity;
|
|
211
|
+
cacheControl?: CacheHint;
|
|
212
|
+
subscribe: (args: Args) => Effect.Effect<Stream.Stream<A, E, R2>, E, R2>;
|
|
213
|
+
resolve?: (value: A, args: Args) => Effect.Effect<A, E, R2>;
|
|
214
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R | R2>;
|
|
215
|
+
/**
|
|
216
|
+
* Add a field to an existing object type (pipe-able)
|
|
217
|
+
*/
|
|
218
|
+
export declare const field: <Parent, A, E, R2, Args = void>(typeName: string, fieldName: string, config: {
|
|
219
|
+
type: S.Schema<A, any, any>;
|
|
220
|
+
args?: S.Schema<Args, any, any>;
|
|
221
|
+
description?: string;
|
|
222
|
+
directives?: readonly DirectiveApplication[];
|
|
223
|
+
complexity?: FieldComplexity;
|
|
224
|
+
cacheControl?: CacheHint;
|
|
225
|
+
resolve: (parent: Parent, args: Args) => Effect.Effect<A, E, R2>;
|
|
226
|
+
}) => <R>(builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<R | R2>;
|
|
227
|
+
/**
|
|
228
|
+
* Compose multiple schema operations (helper for arrays)
|
|
229
|
+
*/
|
|
230
|
+
export declare const compose: <R>(...operations: Array<(builder: GraphQLSchemaBuilder<any>) => GraphQLSchemaBuilder<any>>) => (builder: GraphQLSchemaBuilder<R>) => GraphQLSchemaBuilder<any>;
|
|
231
|
+
//# sourceMappingURL=pipe-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe-api.d.ts","sourceRoot":"","sources":["../../src/builder/pipe-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,CAAC,MAAM,eAAe,CAAA;AAClC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D;;;GAGG;AACH,eAAO,MAAM,UAAU,GACpB,CAAC,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAC7B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,UAAU,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAA;IAC5C;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CACb,MAAM,EACN;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;QAC7B,IAAI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oBAAoB,CAAC,CAAC,GAAG,EAAE,CAC9B,CAAA;AAEtC;;GAEG;AACH,eAAO,MAAM,KAAK,GACf,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,GAAG,IAAI,EAC5B,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,QAAQ;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAC3B,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAA;IAC5C,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;CACjE,MAEF,CAAC,EAAE,SAAS,oBAAoB,CAAC,CAAC,CAAC,KAAG,oBAAoB,CAAC,CAAC,GAAG,EAAE,CACtB,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,OAAO,GACjB,CAAC,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC,GAAG,CAAC,KAAK,oBAAoB,CAAC,GAAG,CAAC,CAAC,MAC1F,SAAS,oBAAoB,CAAC,CAAC,CAAC,KAAG,oBAAoB,CAAC,GAAG,CACd,CAAA"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compose = exports.field = exports.subscription = exports.mutation = exports.query = exports.extension = exports.middleware = exports.directive = exports.inputType = exports.unionType = exports.enumType = exports.interfaceType = exports.objectType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Add an object type to the schema builder (pipe-able)
|
|
6
|
+
* Name is optional if schema is TaggedStruct, TaggedClass, or Schema.Class
|
|
7
|
+
*/
|
|
8
|
+
const objectType = (config) => (builder) => builder.objectType(config);
|
|
9
|
+
exports.objectType = objectType;
|
|
10
|
+
/**
|
|
11
|
+
* Add an interface type to the schema builder (pipe-able)
|
|
12
|
+
* Name is optional if schema is TaggedStruct, TaggedClass, or Schema.Class
|
|
13
|
+
*/
|
|
14
|
+
const interfaceType = (config) => (builder) => builder.interfaceType(config);
|
|
15
|
+
exports.interfaceType = interfaceType;
|
|
16
|
+
/**
|
|
17
|
+
* Add an enum type to the schema builder (pipe-able)
|
|
18
|
+
*/
|
|
19
|
+
const enumType = (config) => (builder) => builder.enumType(config);
|
|
20
|
+
exports.enumType = enumType;
|
|
21
|
+
/**
|
|
22
|
+
* Add a union type to the schema builder (pipe-able)
|
|
23
|
+
*/
|
|
24
|
+
const unionType = (config) => (builder) => builder.unionType(config);
|
|
25
|
+
exports.unionType = unionType;
|
|
26
|
+
/**
|
|
27
|
+
* Add an input type to the schema builder (pipe-able)
|
|
28
|
+
* Name is optional if schema is TaggedStruct, TaggedClass, or Schema.Class
|
|
29
|
+
*/
|
|
30
|
+
const inputType = (config) => (builder) => builder.inputType(config);
|
|
31
|
+
exports.inputType = inputType;
|
|
32
|
+
/**
|
|
33
|
+
* Register a directive (pipe-able)
|
|
34
|
+
*
|
|
35
|
+
* @param config - Directive configuration
|
|
36
|
+
* @param config.name - The directive name (without @)
|
|
37
|
+
* @param config.description - Optional description
|
|
38
|
+
* @param config.locations - Array of DirectiveLocation values where this directive can be applied
|
|
39
|
+
* @param config.args - Optional Effect Schema for directive arguments
|
|
40
|
+
* @param config.apply - Optional function to transform resolver Effects (for executable directives)
|
|
41
|
+
*/
|
|
42
|
+
const directive = (config) => (builder) => builder.directive(config);
|
|
43
|
+
exports.directive = directive;
|
|
44
|
+
/**
|
|
45
|
+
* Register a middleware (pipe-able)
|
|
46
|
+
*
|
|
47
|
+
* Middleware wraps all resolvers (or those matching a pattern) and executes
|
|
48
|
+
* in an "onion" model - first registered middleware is the outermost layer.
|
|
49
|
+
*
|
|
50
|
+
* @param config.name - Middleware name (for debugging/logging)
|
|
51
|
+
* @param config.description - Optional description
|
|
52
|
+
* @param config.match - Optional predicate to filter which fields this applies to
|
|
53
|
+
* @param config.apply - Function that transforms the resolver Effect
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* GraphQLSchemaBuilder.empty.pipe(
|
|
58
|
+
* middleware({
|
|
59
|
+
* name: "logging",
|
|
60
|
+
* apply: (effect, ctx) => Effect.gen(function*() {
|
|
61
|
+
* yield* Effect.logInfo(`Resolving ${ctx.info.fieldName}`)
|
|
62
|
+
* return yield* effect
|
|
63
|
+
* })
|
|
64
|
+
* }),
|
|
65
|
+
* middleware({
|
|
66
|
+
* name: "adminOnly",
|
|
67
|
+
* match: (info) => info.fieldName.startsWith("admin"),
|
|
68
|
+
* apply: (effect) => Effect.gen(function*() {
|
|
69
|
+
* const auth = yield* AuthService
|
|
70
|
+
* yield* auth.requireAdmin()
|
|
71
|
+
* return yield* effect
|
|
72
|
+
* })
|
|
73
|
+
* })
|
|
74
|
+
* )
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
const middleware = (config) => (builder) => builder.middleware(config);
|
|
78
|
+
exports.middleware = middleware;
|
|
79
|
+
/**
|
|
80
|
+
* Register an extension (pipe-able)
|
|
81
|
+
*
|
|
82
|
+
* Extensions provide lifecycle hooks that run at each phase of request processing
|
|
83
|
+
* (parse, validate, execute) and can contribute data to the response's extensions field.
|
|
84
|
+
*
|
|
85
|
+
* @param config.name - Extension name (for debugging/logging)
|
|
86
|
+
* @param config.description - Optional description
|
|
87
|
+
* @param config.onParse - Called after query parsing
|
|
88
|
+
* @param config.onValidate - Called after validation
|
|
89
|
+
* @param config.onExecuteStart - Called before execution begins
|
|
90
|
+
* @param config.onExecuteEnd - Called after execution completes
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* GraphQLSchemaBuilder.empty.pipe(
|
|
95
|
+
* extension({
|
|
96
|
+
* name: "tracing",
|
|
97
|
+
* onExecuteStart: () => Effect.gen(function*() {
|
|
98
|
+
* const ext = yield* ExtensionsService
|
|
99
|
+
* yield* ext.set("tracing", { startTime: Date.now() })
|
|
100
|
+
* }),
|
|
101
|
+
* onExecuteEnd: () => Effect.gen(function*() {
|
|
102
|
+
* const ext = yield* ExtensionsService
|
|
103
|
+
* yield* ext.merge("tracing", { endTime: Date.now() })
|
|
104
|
+
* }),
|
|
105
|
+
* })
|
|
106
|
+
* )
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
const extension = (config) => (builder) => builder.extension(config);
|
|
110
|
+
exports.extension = extension;
|
|
111
|
+
/**
|
|
112
|
+
* Add a query field to the schema builder (pipe-able)
|
|
113
|
+
*/
|
|
114
|
+
const query = (name, config) => (builder) => builder.query(name, config);
|
|
115
|
+
exports.query = query;
|
|
116
|
+
/**
|
|
117
|
+
* Add a mutation field to the schema builder (pipe-able)
|
|
118
|
+
*/
|
|
119
|
+
const mutation = (name, config) => (builder) => builder.mutation(name, config);
|
|
120
|
+
exports.mutation = mutation;
|
|
121
|
+
/**
|
|
122
|
+
* Add a subscription field to the schema builder (pipe-able)
|
|
123
|
+
*
|
|
124
|
+
* Subscriptions return a Stream that yields values over time.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* GraphQLSchemaBuilder.empty.pipe(
|
|
129
|
+
* subscription("userCreated", {
|
|
130
|
+
* type: User,
|
|
131
|
+
* subscribe: Effect.gen(function*() {
|
|
132
|
+
* const pubsub = yield* PubSubService
|
|
133
|
+
* return pubsub.subscribe("USER_CREATED")
|
|
134
|
+
* }),
|
|
135
|
+
* })
|
|
136
|
+
* )
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
const subscription = (name, config) => (builder) => builder.subscription(name, config);
|
|
140
|
+
exports.subscription = subscription;
|
|
141
|
+
/**
|
|
142
|
+
* Add a field to an existing object type (pipe-able)
|
|
143
|
+
*/
|
|
144
|
+
const field = (typeName, fieldName, config) => (builder) => builder.field(typeName, fieldName, config);
|
|
145
|
+
exports.field = field;
|
|
146
|
+
/**
|
|
147
|
+
* Compose multiple schema operations (helper for arrays)
|
|
148
|
+
*/
|
|
149
|
+
const compose = (...operations) => (builder) => operations.reduce((b, op) => op(b), builder);
|
|
150
|
+
exports.compose = compose;
|
|
151
|
+
//# sourceMappingURL=pipe-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe-api.js","sourceRoot":"","sources":["../../src/builder/pipe-api.ts"],"names":[],"mappings":";;;AAcA;;;GAGG;AACI,MAAM,UAAU,GACrB,CAAgB,MAsBf,EAAE,EAAE,CACL,CAAI,OAAgC,EAAgC,EAAE,CACpE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;AAzBjB,QAAA,UAAU,cAyBO;AAE9B;;;GAGG;AACI,MAAM,aAAa,GACxB,CAAC,MAKA,EAAE,EAAE,CACL,CAAI,OAAgC,EAA2B,EAAE,CAC/D,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;AARpB,QAAA,aAAa,iBAQO;AAEjC;;GAEG;AACI,MAAM,QAAQ,GACnB,CAAC,MAKA,EAAE,EAAE,CACL,CAAI,OAAgC,EAA2B,EAAE,CAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AARf,QAAA,QAAQ,YAQO;AAE5B;;GAEG;AACI,MAAM,SAAS,GACpB,CAAC,MAKA,EAAE,EAAE,CACL,CAAI,OAAgC,EAA2B,EAAE,CAC/D,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;AARhB,QAAA,SAAS,aAQO;AAE7B;;;GAGG;AACI,MAAM,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