@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-gql/core",
3
- "version": "1.4.13",
3
+ "version": "1.5.0",
4
4
  "description": "Core GraphQL framework for Effect-TS - schema building, type mapping, and execution",
5
5
  "repository": {
6
6
  "url": "https://github.com/nrf110/effect-gql"
@@ -27,7 +27,7 @@
27
27
  }
28
28
  },
29
29
  "peerDependencies": {
30
- "@effect/platform": "^0.94.1",
30
+ "@effect/platform": "^0.94.2",
31
31
  "effect": "^3.19.0",
32
32
  "graphql": "^16.0.0",
33
33
  "graphql-ws": "^6.0.0"
package/server/index.cjs CHANGED
@@ -133,6 +133,7 @@ var graphiqlHtml = (endpoint, subscriptionEndpoint) => `<!DOCTYPE html>
133
133
  </script>
134
134
  </body>
135
135
  </html>`;
136
+ var GraphQLRequestContext = effect.Context.GenericTag("GraphQLRequestContext");
136
137
  var ComplexityLimitExceededError = class extends effect.Data.TaggedError("ComplexityLimitExceededError") {
137
138
  };
138
139
  var ComplexityAnalysisError = class extends effect.Data.TaggedError("ComplexityAnalysisError") {
@@ -970,14 +971,24 @@ var makeGraphQLRouter = (schema, layer, options = {}) => {
970
971
  const errorHandler = options.errorHandler ?? defaultErrorHandler;
971
972
  const graphqlHandler = effect.Effect.gen(function* () {
972
973
  const extensionsService = yield* makeExtensionsService();
973
- const runtime = yield* effect.Effect.runtime();
974
974
  const request = yield* platform.HttpServerRequest.HttpServerRequest;
975
+ const headers = request.headers;
975
976
  const parsedBody = yield* decodeRequestBody(request);
976
977
  const body = {
977
978
  query: parsedBody.query,
978
979
  variables: parsedBody.variables._tag === "Some" ? parsedBody.variables.value : void 0,
979
980
  operationName: parsedBody.operationName._tag === "Some" ? parsedBody.operationName.value : void 0
980
981
  };
982
+ const requestContext = {
983
+ request: {
984
+ headers,
985
+ query: body.query,
986
+ variables: body.variables,
987
+ operationName: body.operationName
988
+ }
989
+ };
990
+ const baseRuntime = yield* effect.Effect.runtime();
991
+ const runtime = baseRuntime.pipe(effect.Runtime.provideService(GraphQLRequestContext, requestContext));
981
992
  const parseResult = yield* parseGraphQLQuery(body.query, extensionsService);
982
993
  if (!parseResult.ok) {
983
994
  return parseResult.response;