@effect-gql/node 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/config.d.ts +43 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +52 -0
- package/dist/config.js.map +1 -0
- package/dist/graphiql.d.ts +5 -0
- package/dist/graphiql.d.ts.map +1 -0
- package/dist/graphiql.js +43 -0
- package/dist/graphiql.js.map +1 -0
- package/dist/http-utils.d.ts +20 -0
- package/dist/http-utils.d.ts.map +1 -0
- package/dist/http-utils.js +36 -0
- package/dist/http-utils.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/router.d.ts +32 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +77 -0
- package/dist/router.js.map +1 -0
- package/dist/schema-builder-extensions.d.ts +31 -0
- package/dist/schema-builder-extensions.d.ts.map +1 -0
- package/dist/schema-builder-extensions.js +35 -0
- package/dist/schema-builder-extensions.js.map +1 -0
- package/dist/serve.d.ts +73 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/serve.js +176 -0
- package/dist/serve.js.map +1 -0
- package/dist/sse.d.ts +86 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +175 -0
- package/dist/sse.js.map +1 -0
- package/dist/ws.d.ts +97 -0
- package/dist/ws.d.ts.map +1 -0
- package/dist/ws.js +137 -0
- package/dist/ws.js.map +1 -0
- package/package.json +57 -0
- package/src/http-utils.ts +32 -0
- package/src/index.ts +15 -0
- package/src/serve.ts +217 -0
- package/src/sse.ts +234 -0
- package/src/ws.ts +183 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Nick Fisher
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Config } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the GraphiQL UI
|
|
4
|
+
*/
|
|
5
|
+
export interface GraphiQLConfig {
|
|
6
|
+
/** Path where GraphiQL UI is served (default: "/graphiql") */
|
|
7
|
+
readonly path: string;
|
|
8
|
+
/** URL where GraphiQL sends requests (default: same as graphql path) */
|
|
9
|
+
readonly endpoint: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the GraphQL router
|
|
13
|
+
*/
|
|
14
|
+
export interface GraphQLRouterConfig {
|
|
15
|
+
/** Path for GraphQL endpoint (default: "/graphql") */
|
|
16
|
+
readonly path: string;
|
|
17
|
+
/** GraphiQL configuration, or false to disable */
|
|
18
|
+
readonly graphiql: false | GraphiQLConfig;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Default configuration values
|
|
22
|
+
*/
|
|
23
|
+
export declare const defaultConfig: GraphQLRouterConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Normalize user-provided config (which may use boolean shorthand for graphiql)
|
|
26
|
+
* into the full GraphQLRouterConfig format
|
|
27
|
+
*/
|
|
28
|
+
export interface GraphQLRouterConfigInput {
|
|
29
|
+
readonly path?: string;
|
|
30
|
+
readonly graphiql?: boolean | Partial<GraphiQLConfig>;
|
|
31
|
+
}
|
|
32
|
+
export declare const normalizeConfig: (input?: GraphQLRouterConfigInput) => GraphQLRouterConfig;
|
|
33
|
+
/**
|
|
34
|
+
* Effect Config for loading GraphQL router configuration from environment variables.
|
|
35
|
+
*
|
|
36
|
+
* Environment variables:
|
|
37
|
+
* - GRAPHQL_PATH: Path for GraphQL endpoint (default: "/graphql")
|
|
38
|
+
* - GRAPHIQL_ENABLED: Enable GraphiQL UI (default: false)
|
|
39
|
+
* - GRAPHIQL_PATH: Path for GraphiQL UI (default: "/graphiql")
|
|
40
|
+
* - GRAPHIQL_ENDPOINT: URL where GraphiQL sends requests (default: same as GRAPHQL_PATH)
|
|
41
|
+
*/
|
|
42
|
+
export declare const GraphQLRouterConfigFromEnv: Config.Config<GraphQLRouterConfig>;
|
|
43
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,KAAK,GAAG,cAAc,CAAA;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,mBAG3B,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CACtD;AAED,eAAO,MAAM,eAAe,GAC1B,QAAO,wBAA6B,KACnC,mBAcF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAsBvE,CAAA"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphQLRouterConfigFromEnv = exports.normalizeConfig = exports.defaultConfig = void 0;
|
|
4
|
+
const effect_1 = require("effect");
|
|
5
|
+
/**
|
|
6
|
+
* Default configuration values
|
|
7
|
+
*/
|
|
8
|
+
exports.defaultConfig = {
|
|
9
|
+
path: "/graphql",
|
|
10
|
+
graphiql: false,
|
|
11
|
+
};
|
|
12
|
+
const normalizeConfig = (input = {}) => {
|
|
13
|
+
const path = input.path ?? exports.defaultConfig.path;
|
|
14
|
+
let graphiql = false;
|
|
15
|
+
if (input.graphiql === true) {
|
|
16
|
+
graphiql = { path: "/graphiql", endpoint: path };
|
|
17
|
+
}
|
|
18
|
+
else if (input.graphiql && typeof input.graphiql === "object") {
|
|
19
|
+
graphiql = {
|
|
20
|
+
path: input.graphiql.path ?? "/graphiql",
|
|
21
|
+
endpoint: input.graphiql.endpoint ?? path,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return { path, graphiql };
|
|
25
|
+
};
|
|
26
|
+
exports.normalizeConfig = normalizeConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Effect Config for loading GraphQL router configuration from environment variables.
|
|
29
|
+
*
|
|
30
|
+
* Environment variables:
|
|
31
|
+
* - GRAPHQL_PATH: Path for GraphQL endpoint (default: "/graphql")
|
|
32
|
+
* - GRAPHIQL_ENABLED: Enable GraphiQL UI (default: false)
|
|
33
|
+
* - GRAPHIQL_PATH: Path for GraphiQL UI (default: "/graphiql")
|
|
34
|
+
* - GRAPHIQL_ENDPOINT: URL where GraphiQL sends requests (default: same as GRAPHQL_PATH)
|
|
35
|
+
*/
|
|
36
|
+
exports.GraphQLRouterConfigFromEnv = effect_1.Config.all({
|
|
37
|
+
path: effect_1.Config.string("GRAPHQL_PATH").pipe(effect_1.Config.withDefault("/graphql")),
|
|
38
|
+
graphiqlEnabled: effect_1.Config.boolean("GRAPHIQL_ENABLED").pipe(effect_1.Config.withDefault(false)),
|
|
39
|
+
graphiqlPath: effect_1.Config.string("GRAPHIQL_PATH").pipe(effect_1.Config.withDefault("/graphiql")),
|
|
40
|
+
graphiqlEndpoint: effect_1.Config.string("GRAPHIQL_ENDPOINT").pipe(effect_1.Config.option),
|
|
41
|
+
}).pipe(effect_1.Config.map(({ path, graphiqlEnabled, graphiqlPath, graphiqlEndpoint }) => ({
|
|
42
|
+
path,
|
|
43
|
+
graphiql: graphiqlEnabled
|
|
44
|
+
? {
|
|
45
|
+
path: graphiqlPath,
|
|
46
|
+
endpoint: graphiqlEndpoint._tag === "Some"
|
|
47
|
+
? graphiqlEndpoint.value
|
|
48
|
+
: path,
|
|
49
|
+
}
|
|
50
|
+
: false,
|
|
51
|
+
})));
|
|
52
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAsB/B;;GAEG;AACU,QAAA,aAAa,GAAwB;IAChD,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,KAAK;CAChB,CAAA;AAWM,MAAM,eAAe,GAAG,CAC7B,QAAkC,EAAE,EACf,EAAE;IACvB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,qBAAa,CAAC,I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AAE,eAAe;QACvB,CAAC,CAAC;YACE,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,gBAAgB,CAAC,IAAI,KAAK,MAAM;gBACxC,CAAC,CAAC,gBAAgB,CAAC,KAAK;gBACxB,CAAC,CAAC,IAAI;SACT;QACH,CAAC,CAAE,KAAe;CACrB,CAAC,CAAC,CACJ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphiql.d.ts","sourceRoot":"","sources":["../src/graphiql.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,MAkCxC,CAAA"}
|
package/dist/graphiql.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.graphiqlHtml = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Generate HTML for GraphiQL IDE, loading dependencies from CDN
|
|
6
|
+
*/
|
|
7
|
+
const graphiqlHtml = (endpoint) => `<!DOCTYPE html>
|
|
8
|
+
<html lang="en">
|
|
9
|
+
<head>
|
|
10
|
+
<meta charset="utf-8" />
|
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
+
<title>GraphiQL</title>
|
|
13
|
+
<link
|
|
14
|
+
rel="stylesheet"
|
|
15
|
+
href="https://unpkg.com/graphiql@3/graphiql.min.css"
|
|
16
|
+
/>
|
|
17
|
+
</head>
|
|
18
|
+
<body style="margin: 0; overflow: hidden;">
|
|
19
|
+
<div id="graphiql" style="height: 100vh;"></div>
|
|
20
|
+
<script
|
|
21
|
+
crossorigin
|
|
22
|
+
src="https://unpkg.com/react@18/umd/react.production.min.js"
|
|
23
|
+
></script>
|
|
24
|
+
<script
|
|
25
|
+
crossorigin
|
|
26
|
+
src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
|
|
27
|
+
></script>
|
|
28
|
+
<script
|
|
29
|
+
crossorigin
|
|
30
|
+
src="https://unpkg.com/graphiql@3/graphiql.min.js"
|
|
31
|
+
></script>
|
|
32
|
+
<script>
|
|
33
|
+
const fetcher = GraphiQL.createFetcher({
|
|
34
|
+
url: '${endpoint}',
|
|
35
|
+
});
|
|
36
|
+
ReactDOM.createRoot(document.getElementById('graphiql')).render(
|
|
37
|
+
React.createElement(GraphiQL, { fetcher })
|
|
38
|
+
);
|
|
39
|
+
</script>
|
|
40
|
+
</body>
|
|
41
|
+
</html>`;
|
|
42
|
+
exports.graphiqlHtml = graphiqlHtml;
|
|
43
|
+
//# sourceMappingURL=graphiql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphiql.js","sourceRoot":"","sources":["../src/graphiql.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2B1C,QAAQ;;;;;;;QAOhB,CAAA;AAlCK,QAAA,YAAY,gBAkCjB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders } from "node:http";
|
|
2
|
+
/**
|
|
3
|
+
* Convert Node.js IncomingHttpHeaders to web standard Headers.
|
|
4
|
+
*
|
|
5
|
+
* This handles the difference between Node.js headers (which can be
|
|
6
|
+
* string | string[] | undefined) and web Headers (which are always strings).
|
|
7
|
+
*
|
|
8
|
+
* @param nodeHeaders - Headers from IncomingMessage.headers
|
|
9
|
+
* @returns A web standard Headers object
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { toWebHeaders } from "@effect-gql/node"
|
|
14
|
+
*
|
|
15
|
+
* const webHeaders = toWebHeaders(req.headers)
|
|
16
|
+
* const auth = webHeaders.get("authorization")
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const toWebHeaders: (nodeHeaders: IncomingHttpHeaders) => Headers;
|
|
20
|
+
//# sourceMappingURL=http-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-utils.d.ts","sourceRoot":"","sources":["../src/http-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,GAAI,aAAa,mBAAmB,KAAG,OAY/D,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toWebHeaders = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Convert Node.js IncomingHttpHeaders to web standard Headers.
|
|
6
|
+
*
|
|
7
|
+
* This handles the difference between Node.js headers (which can be
|
|
8
|
+
* string | string[] | undefined) and web Headers (which are always strings).
|
|
9
|
+
*
|
|
10
|
+
* @param nodeHeaders - Headers from IncomingMessage.headers
|
|
11
|
+
* @returns A web standard Headers object
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { toWebHeaders } from "@effect-gql/node"
|
|
16
|
+
*
|
|
17
|
+
* const webHeaders = toWebHeaders(req.headers)
|
|
18
|
+
* const auth = webHeaders.get("authorization")
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
const toWebHeaders = (nodeHeaders) => {
|
|
22
|
+
const headers = new Headers();
|
|
23
|
+
for (const [key, value] of Object.entries(nodeHeaders)) {
|
|
24
|
+
if (value) {
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
value.forEach((v) => headers.append(key, v));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
headers.set(key, value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return headers;
|
|
34
|
+
};
|
|
35
|
+
exports.toWebHeaders = toWebHeaders;
|
|
36
|
+
//# sourceMappingURL=http-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-utils.js","sourceRoot":"","sources":["../src/http-utils.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,YAAY,GAAG,CAAC,WAAgC,EAAW,EAAE;IACxE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;IAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACvD,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;YAC9C,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAZY,QAAA,YAAY,gBAYxB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { serve, type ServeOptions } from "./serve";
|
|
2
|
+
export { toWebHeaders } from "./http-utils";
|
|
3
|
+
export { toEffectWebSocket, createGraphQLWSServer, attachWebSocketToServer, type NodeWSOptions, } from "./ws";
|
|
4
|
+
export { createSSEHandler, createSSEServer, type NodeSSEOptions } from "./sse";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,aAAa,GACnB,MAAM,MAAM,CAAA;AAGb,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSSEServer = exports.createSSEHandler = exports.attachWebSocketToServer = exports.createGraphQLWSServer = exports.toEffectWebSocket = exports.toWebHeaders = exports.serve = void 0;
|
|
4
|
+
var serve_1 = require("./serve");
|
|
5
|
+
Object.defineProperty(exports, "serve", { enumerable: true, get: function () { return serve_1.serve; } });
|
|
6
|
+
// HTTP utilities
|
|
7
|
+
var http_utils_1 = require("./http-utils");
|
|
8
|
+
Object.defineProperty(exports, "toWebHeaders", { enumerable: true, get: function () { return http_utils_1.toWebHeaders; } });
|
|
9
|
+
// WebSocket subscription support
|
|
10
|
+
var ws_1 = require("./ws");
|
|
11
|
+
Object.defineProperty(exports, "toEffectWebSocket", { enumerable: true, get: function () { return ws_1.toEffectWebSocket; } });
|
|
12
|
+
Object.defineProperty(exports, "createGraphQLWSServer", { enumerable: true, get: function () { return ws_1.createGraphQLWSServer; } });
|
|
13
|
+
Object.defineProperty(exports, "attachWebSocketToServer", { enumerable: true, get: function () { return ws_1.attachWebSocketToServer; } });
|
|
14
|
+
// SSE (Server-Sent Events) subscription support
|
|
15
|
+
var sse_1 = require("./sse");
|
|
16
|
+
Object.defineProperty(exports, "createSSEHandler", { enumerable: true, get: function () { return sse_1.createSSEHandler; } });
|
|
17
|
+
Object.defineProperty(exports, "createSSEServer", { enumerable: true, get: function () { return sse_1.createSSEServer; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAkD;AAAzC,8FAAA,KAAK,OAAA;AAEd,iBAAiB;AACjB,2CAA2C;AAAlC,0GAAA,YAAY,OAAA;AAErB,iCAAiC;AACjC,2BAKa;AAJX,uGAAA,iBAAiB,OAAA;AACjB,2GAAA,qBAAqB,OAAA;AACrB,6GAAA,uBAAuB,OAAA;AAIzB,gDAAgD;AAChD,6BAA8E;AAArE,uGAAA,gBAAgB,OAAA;AAAE,sGAAA,eAAe,OAAA"}
|
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HttpRouter } from "@effect/platform";
|
|
2
|
+
import { Layer } from "effect";
|
|
3
|
+
import { GraphQLSchema } from "graphql";
|
|
4
|
+
import { type GraphQLRouterConfigInput } from "./config";
|
|
5
|
+
/**
|
|
6
|
+
* Create an HttpRouter configured for GraphQL
|
|
7
|
+
*
|
|
8
|
+
* The router handles:
|
|
9
|
+
* - POST requests to the GraphQL endpoint
|
|
10
|
+
* - GET requests to the GraphiQL UI (if enabled)
|
|
11
|
+
*
|
|
12
|
+
* @param schema - The GraphQL schema
|
|
13
|
+
* @param layer - Effect layer providing services required by resolvers
|
|
14
|
+
* @param config - Optional configuration for paths and GraphiQL
|
|
15
|
+
* @returns An HttpRouter that can be composed with other routes
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const router = makeGraphQLRouter(schema, Layer.empty, {
|
|
20
|
+
* path: "/graphql",
|
|
21
|
+
* graphiql: { path: "/graphiql" }
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* // Compose with other routes
|
|
25
|
+
* const app = HttpRouter.empty.pipe(
|
|
26
|
+
* HttpRouter.get("/health", HttpServerResponse.json({ status: "ok" })),
|
|
27
|
+
* HttpRouter.concat(router)
|
|
28
|
+
* )
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const makeGraphQLRouter: <R>(schema: GraphQLSchema, layer: Layer.Layer<R>, config?: GraphQLRouterConfigInput) => HttpRouter.HttpRouter<never, never>;
|
|
32
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyC,MAAM,kBAAkB,CAAA;AACpF,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,aAAa,EAAW,MAAM,SAAS,CAAA;AAGhD,OAAO,EAAmB,KAAK,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EACjC,QAAQ,aAAa,EACrB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EACrB,SAAQ,wBAA6B,KACpC,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAoEpC,CAAA"}
|
package/dist/router.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeGraphQLRouter = void 0;
|
|
4
|
+
const platform_1 = require("@effect/platform");
|
|
5
|
+
const effect_1 = require("effect");
|
|
6
|
+
const graphql_1 = require("graphql");
|
|
7
|
+
const graphiql_1 = require("./graphiql");
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
/**
|
|
10
|
+
* Create an HttpRouter configured for GraphQL
|
|
11
|
+
*
|
|
12
|
+
* The router handles:
|
|
13
|
+
* - POST requests to the GraphQL endpoint
|
|
14
|
+
* - GET requests to the GraphiQL UI (if enabled)
|
|
15
|
+
*
|
|
16
|
+
* @param schema - The GraphQL schema
|
|
17
|
+
* @param layer - Effect layer providing services required by resolvers
|
|
18
|
+
* @param config - Optional configuration for paths and GraphiQL
|
|
19
|
+
* @returns An HttpRouter that can be composed with other routes
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const router = makeGraphQLRouter(schema, Layer.empty, {
|
|
24
|
+
* path: "/graphql",
|
|
25
|
+
* graphiql: { path: "/graphiql" }
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // Compose with other routes
|
|
29
|
+
* const app = HttpRouter.empty.pipe(
|
|
30
|
+
* HttpRouter.get("/health", HttpServerResponse.json({ status: "ok" })),
|
|
31
|
+
* HttpRouter.concat(router)
|
|
32
|
+
* )
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
const makeGraphQLRouter = (schema, layer, config = {}) => {
|
|
36
|
+
const resolvedConfig = (0, config_1.normalizeConfig)(config);
|
|
37
|
+
// GraphQL POST handler
|
|
38
|
+
const graphqlHandler = effect_1.Effect.gen(function* () {
|
|
39
|
+
// Get the runtime from the layer
|
|
40
|
+
const runtime = yield* effect_1.Effect.runtime();
|
|
41
|
+
// Parse request body
|
|
42
|
+
const request = yield* platform_1.HttpServerRequest.HttpServerRequest;
|
|
43
|
+
const body = yield* request.json;
|
|
44
|
+
// Execute GraphQL query
|
|
45
|
+
const result = yield* effect_1.Effect.tryPromise({
|
|
46
|
+
try: () => (0, graphql_1.graphql)({
|
|
47
|
+
schema,
|
|
48
|
+
source: body.query,
|
|
49
|
+
variableValues: body.variables,
|
|
50
|
+
operationName: body.operationName,
|
|
51
|
+
contextValue: { runtime },
|
|
52
|
+
}),
|
|
53
|
+
catch: (error) => new Error(String(error)),
|
|
54
|
+
});
|
|
55
|
+
return yield* platform_1.HttpServerResponse.json(result);
|
|
56
|
+
}).pipe(effect_1.Effect.provide(layer), effect_1.Effect.catchAllCause((cause) => platform_1.HttpServerResponse.json({
|
|
57
|
+
errors: [
|
|
58
|
+
{
|
|
59
|
+
message: cause._tag === "Fail"
|
|
60
|
+
? cause.error instanceof Error
|
|
61
|
+
? cause.error.message
|
|
62
|
+
: String(cause.error)
|
|
63
|
+
: "Internal server error",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}, { status: 400 }).pipe(effect_1.Effect.orDie)));
|
|
67
|
+
// Build router with GraphQL endpoint
|
|
68
|
+
let router = platform_1.HttpRouter.empty.pipe(platform_1.HttpRouter.post(resolvedConfig.path, graphqlHandler));
|
|
69
|
+
// Add GraphiQL route if enabled
|
|
70
|
+
if (resolvedConfig.graphiql) {
|
|
71
|
+
const { path, endpoint } = resolvedConfig.graphiql;
|
|
72
|
+
router = router.pipe(platform_1.HttpRouter.get(path, platform_1.HttpServerResponse.html((0, graphiql_1.graphiqlHtml)(endpoint))));
|
|
73
|
+
}
|
|
74
|
+
return router;
|
|
75
|
+
};
|
|
76
|
+
exports.makeGraphQLRouter = makeGraphQLRouter;
|
|
77
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":";;;AAAA,+CAAoF;AACpF,mCAAsC;AACtC,qCAAgD;AAEhD,yCAAyC;AACzC,qCAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,MAAM,iBAAiB,GAAG,CAC/B,MAAqB,EACrB,KAAqB,EACrB,SAAmC,EAAE,EACA,EAAE;IACvC,MAAM,cAAc,GAAG,IAAA,wBAAe,EAAC,MAAM,CAAC,CAAA;IAE9C,uBAAuB;IACvB,MAAM,cAAc,GAAG,eAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzC,iCAAiC;QACjC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,eAAM,CAAC,OAAO,EAAK,CAAA;QAE1C,qBAAqB;QACrB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,4BAAiB,CAAC,iBAAiB,CAAA;QAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,IAI1B,CAAA;QAEF,wBAAwB;QACxB,MAA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AAI,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAA;QAClD,MAAM,GAAG,MAAM,CAAC,IAAI,CAClB,qBAAU,CAAC,GAAG,CACZ,IAA4B,EAC5B,6BAAkB,CAAC,IAAI,CAAC,IAAA,uBAAY,EAAC,QAAQ,CAAC,CAAC,CAChD,CACF,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAxEY,QAAA,iBAAiB,qBAwE7B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { HttpRouter } from "@effect/platform";
|
|
3
|
+
import { GraphQLSchemaBuilder } from "@effect-gql/core";
|
|
4
|
+
import type { GraphQLRouterConfigInput } from "./config";
|
|
5
|
+
/**
|
|
6
|
+
* Convert a GraphQLSchemaBuilder to an HttpRouter.
|
|
7
|
+
*
|
|
8
|
+
* This is the Node.js server integration that bridges the core
|
|
9
|
+
* GraphQL schema with the @effect/platform HTTP server.
|
|
10
|
+
*
|
|
11
|
+
* @param builder - The GraphQL schema builder
|
|
12
|
+
* @param layer - Effect layer providing services required by resolvers
|
|
13
|
+
* @param config - Optional configuration for paths and GraphiQL
|
|
14
|
+
* @returns An HttpRouter that can be composed with other routes
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { GraphQLSchemaBuilder, query } from "@effect-gql/core"
|
|
19
|
+
* import { toRouter } from "@effect-gql/node"
|
|
20
|
+
* import { Layer } from "effect"
|
|
21
|
+
* import * as S from "effect/Schema"
|
|
22
|
+
*
|
|
23
|
+
* const builder = GraphQLSchemaBuilder.empty.pipe(
|
|
24
|
+
* query("hello", { type: S.String, resolve: () => Effect.succeed("world") })
|
|
25
|
+
* )
|
|
26
|
+
*
|
|
27
|
+
* const router = toRouter(builder, Layer.empty, { graphiql: true })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const toRouter: <R, R2>(builder: GraphQLSchemaBuilder<R>, layer: Layer.Layer<R2>, config?: GraphQLRouterConfigInput) => HttpRouter.HttpRouter<never, never>;
|
|
31
|
+
//# sourceMappingURL=schema-builder-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-builder-extensions.d.ts","sourceRoot":"","sources":["../src/schema-builder-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAE3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,EAAE,EAC5B,SAAS,oBAAoB,CAAC,CAAC,CAAC,EAChC,OAAO,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,EACtB,SAAS,wBAAwB,KAChC,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAGpC,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toRouter = void 0;
|
|
4
|
+
const router_1 = require("./router");
|
|
5
|
+
/**
|
|
6
|
+
* Convert a GraphQLSchemaBuilder to an HttpRouter.
|
|
7
|
+
*
|
|
8
|
+
* This is the Node.js server integration that bridges the core
|
|
9
|
+
* GraphQL schema with the @effect/platform HTTP server.
|
|
10
|
+
*
|
|
11
|
+
* @param builder - The GraphQL schema builder
|
|
12
|
+
* @param layer - Effect layer providing services required by resolvers
|
|
13
|
+
* @param config - Optional configuration for paths and GraphiQL
|
|
14
|
+
* @returns An HttpRouter that can be composed with other routes
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { GraphQLSchemaBuilder, query } from "@effect-graphql/core"
|
|
19
|
+
* import { toRouter } from "@effect-graphql/node"
|
|
20
|
+
* import { Layer } from "effect"
|
|
21
|
+
* import * as S from "effect/Schema"
|
|
22
|
+
*
|
|
23
|
+
* const builder = GraphQLSchemaBuilder.empty.pipe(
|
|
24
|
+
* query("hello", { type: S.String, resolve: () => Effect.succeed("world") })
|
|
25
|
+
* )
|
|
26
|
+
*
|
|
27
|
+
* const router = toRouter(builder, Layer.empty, { graphiql: true })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
const toRouter = (builder, layer, config) => {
|
|
31
|
+
const schema = builder.buildSchema();
|
|
32
|
+
return (0, router_1.makeGraphQLRouter)(schema, layer, config);
|
|
33
|
+
};
|
|
34
|
+
exports.toRouter = toRouter;
|
|
35
|
+
//# sourceMappingURL=schema-builder-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-builder-extensions.js","sourceRoot":"","sources":["../src/schema-builder-extensions.ts"],"names":[],"mappings":";;;AAGA,qCAA4C;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,QAAQ,GAAG,CACtB,OAAgC,EAChC,KAAsB,EACtB,MAAiC,EACI,EAAE;IACvC,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;IACpC,OAAO,IAAA,0BAAiB,EAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AACjD,CAAC,CAAA;AAPY,QAAA,QAAQ,YAOpB"}
|
package/dist/serve.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { HttpRouter } from "@effect/platform";
|
|
3
|
+
import type { GraphQLSchema } from "graphql";
|
|
4
|
+
import type { GraphQLWSOptions } from "@effect-gql/core";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for WebSocket subscriptions
|
|
7
|
+
*/
|
|
8
|
+
export interface SubscriptionsConfig<R> extends GraphQLWSOptions<R> {
|
|
9
|
+
/**
|
|
10
|
+
* The GraphQL schema (required for subscriptions).
|
|
11
|
+
* Must be the same schema used to create the router.
|
|
12
|
+
*/
|
|
13
|
+
readonly schema: GraphQLSchema;
|
|
14
|
+
/**
|
|
15
|
+
* Path for WebSocket connections.
|
|
16
|
+
* @default "/graphql"
|
|
17
|
+
*/
|
|
18
|
+
readonly path?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for the Node.js GraphQL server
|
|
22
|
+
*/
|
|
23
|
+
export interface ServeOptions<R = never> {
|
|
24
|
+
/** Port to listen on (default: 4000) */
|
|
25
|
+
readonly port?: number;
|
|
26
|
+
/** Hostname to bind to (default: "0.0.0.0") */
|
|
27
|
+
readonly host?: string;
|
|
28
|
+
/** Callback when server starts */
|
|
29
|
+
readonly onStart?: (url: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Enable WebSocket subscriptions.
|
|
32
|
+
* When provided, the server will handle WebSocket upgrade requests
|
|
33
|
+
* for GraphQL subscriptions using the graphql-ws protocol.
|
|
34
|
+
*/
|
|
35
|
+
readonly subscriptions?: SubscriptionsConfig<R>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Start a Node.js HTTP server with the given router.
|
|
39
|
+
*
|
|
40
|
+
* This is the main entry point for running a GraphQL server on Node.js.
|
|
41
|
+
* It handles all the Effect runtime setup and server lifecycle.
|
|
42
|
+
*
|
|
43
|
+
* @param router - The HttpRouter to serve (typically from makeGraphQLRouter or toRouter)
|
|
44
|
+
* @param layer - Layer providing the router's service dependencies
|
|
45
|
+
* @param options - Server configuration options
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { makeGraphQLRouter } from "@effect-gql/core"
|
|
50
|
+
* import { serve } from "@effect-gql/node"
|
|
51
|
+
*
|
|
52
|
+
* const schema = GraphQLSchemaBuilder.empty
|
|
53
|
+
* .query("hello", { type: S.String, resolve: () => Effect.succeed("world") })
|
|
54
|
+
* .buildSchema()
|
|
55
|
+
*
|
|
56
|
+
* const router = makeGraphQLRouter(schema, Layer.empty, { graphiql: true })
|
|
57
|
+
*
|
|
58
|
+
* // Without subscriptions
|
|
59
|
+
* serve(router, serviceLayer, {
|
|
60
|
+
* port: 4000,
|
|
61
|
+
* onStart: (url) => console.log(`Server running at ${url}`)
|
|
62
|
+
* })
|
|
63
|
+
*
|
|
64
|
+
* // With subscriptions
|
|
65
|
+
* serve(router, serviceLayer, {
|
|
66
|
+
* port: 4000,
|
|
67
|
+
* subscriptions: { schema },
|
|
68
|
+
* onStart: (url) => console.log(`Server running at ${url}`)
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare const serve: <E, R, RE>(router: HttpRouter.HttpRouter<E, R>, layer: Layer.Layer<R, RE>, options?: ServeOptions<R>) => void;
|
|
73
|
+
//# sourceMappingURL=serve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAW,UAAU,EAAc,MAAM,kBAAkB,CAAA;AAGlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGxD;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC,CAAC;IACjE;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;IAC9B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,KAAK;IACrC,wCAAwC;IACxC,QAAQ,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