@effect-gql/core 1.4.13 → 1.5.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/index.cjs +11 -1
- package/index.cjs.map +1 -1
- package/index.js +11 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/server/index.cjs +12 -1
- package/server/index.cjs.map +1 -1
- package/server/index.js +13 -2
- package/server/index.js.map +1 -1
package/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, Option,
|
|
1
|
+
import { Config, Option, Context, Data, Schema, Effect, Runtime, Queue, Deferred, Stream, Ref, Fiber } from 'effect';
|
|
2
2
|
import { HttpIncomingMessage, HttpServerResponse, HttpServerRequest, HttpRouter } from '@effect/platform';
|
|
3
3
|
import { Kind, GraphQLObjectType, parse, specifiedRules, NoSchemaIntrospectionCustomRule, validate, GraphQLError, subscribe, GraphQLNonNull, GraphQLList, GraphQLSchema, GraphQLScalarType, GraphQLEnumType, execute } from 'graphql';
|
|
4
4
|
|
|
@@ -131,6 +131,7 @@ var graphiqlHtml = (endpoint, subscriptionEndpoint) => `<!DOCTYPE html>
|
|
|
131
131
|
</script>
|
|
132
132
|
</body>
|
|
133
133
|
</html>`;
|
|
134
|
+
var GraphQLRequestContext = Context.GenericTag("GraphQLRequestContext");
|
|
134
135
|
var ComplexityLimitExceededError = class extends Data.TaggedError("ComplexityLimitExceededError") {
|
|
135
136
|
};
|
|
136
137
|
var ComplexityAnalysisError = class extends Data.TaggedError("ComplexityAnalysisError") {
|
|
@@ -968,14 +969,24 @@ var makeGraphQLRouter = (schema, layer, options = {}) => {
|
|
|
968
969
|
const errorHandler = options.errorHandler ?? defaultErrorHandler;
|
|
969
970
|
const graphqlHandler = Effect.gen(function* () {
|
|
970
971
|
const extensionsService = yield* makeExtensionsService();
|
|
971
|
-
const runtime = yield* Effect.runtime();
|
|
972
972
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
973
|
+
const headers = request.headers;
|
|
973
974
|
const parsedBody = yield* decodeRequestBody(request);
|
|
974
975
|
const body = {
|
|
975
976
|
query: parsedBody.query,
|
|
976
977
|
variables: parsedBody.variables._tag === "Some" ? parsedBody.variables.value : void 0,
|
|
977
978
|
operationName: parsedBody.operationName._tag === "Some" ? parsedBody.operationName.value : void 0
|
|
978
979
|
};
|
|
980
|
+
const requestContext = {
|
|
981
|
+
request: {
|
|
982
|
+
headers,
|
|
983
|
+
query: body.query,
|
|
984
|
+
variables: body.variables,
|
|
985
|
+
operationName: body.operationName
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
const baseRuntime = yield* Effect.runtime();
|
|
989
|
+
const runtime = baseRuntime.pipe(Runtime.provideService(GraphQLRequestContext, requestContext));
|
|
979
990
|
const parseResult = yield* parseGraphQLQuery(body.query, extensionsService);
|
|
980
991
|
if (!parseResult.ok) {
|
|
981
992
|
return parseResult.response;
|