@cedarjs/graphql-server 5.0.6 → 5.0.7-next.186

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.
Files changed (82) hide show
  1. package/dist/plugins/useRedwoodAuthContext.d.ts.map +1 -1
  2. package/dist/plugins/useRedwoodAuthContext.js +4 -24
  3. package/package.json +11 -16
  4. package/dist/cjs/cors.d.ts +0 -10
  5. package/dist/cjs/cors.d.ts.map +0 -1
  6. package/dist/cjs/cors.js +0 -70
  7. package/dist/cjs/createGraphQLYoga.d.ts +0 -6
  8. package/dist/cjs/createGraphQLYoga.d.ts.map +0 -1
  9. package/dist/cjs/createGraphQLYoga.js +0 -193
  10. package/dist/cjs/directives/makeDirectives.d.ts +0 -8
  11. package/dist/cjs/directives/makeDirectives.d.ts.map +0 -1
  12. package/dist/cjs/directives/makeDirectives.js +0 -89
  13. package/dist/cjs/errors.d.ts +0 -32
  14. package/dist/cjs/errors.d.ts.map +0 -1
  15. package/dist/cjs/errors.js +0 -101
  16. package/dist/cjs/functions/graphql.d.ts +0 -15
  17. package/dist/cjs/functions/graphql.d.ts.map +0 -1
  18. package/dist/cjs/functions/graphql.js +0 -201
  19. package/dist/cjs/functions/useRequireAuth.d.ts +0 -12
  20. package/dist/cjs/functions/useRequireAuth.d.ts.map +0 -1
  21. package/dist/cjs/functions/useRequireAuth.js +0 -70
  22. package/dist/cjs/global.api-auto-imports.d.ts +0 -7
  23. package/dist/cjs/global.api-auto-imports.d.ts.map +0 -1
  24. package/dist/cjs/global.api-auto-imports.js +0 -1
  25. package/dist/cjs/globalContext.d.ts +0 -25
  26. package/dist/cjs/globalContext.d.ts.map +0 -1
  27. package/dist/cjs/globalContext.js +0 -55
  28. package/dist/cjs/globalContextStore.d.ts +0 -9
  29. package/dist/cjs/globalContextStore.d.ts.map +0 -1
  30. package/dist/cjs/globalContextStore.js +0 -35
  31. package/dist/cjs/graphiql.d.ts +0 -8
  32. package/dist/cjs/graphiql.d.ts.map +0 -1
  33. package/dist/cjs/graphiql.js +0 -45
  34. package/dist/cjs/index.d.ts +0 -14
  35. package/dist/cjs/index.d.ts.map +0 -1
  36. package/dist/cjs/index.js +0 -75
  37. package/dist/cjs/introspection.d.ts +0 -7
  38. package/dist/cjs/introspection.d.ts.map +0 -1
  39. package/dist/cjs/introspection.js +0 -36
  40. package/dist/cjs/makeMergedSchema.d.ts +0 -17
  41. package/dist/cjs/makeMergedSchema.d.ts.map +0 -1
  42. package/dist/cjs/makeMergedSchema.js +0 -283
  43. package/dist/cjs/package.json +0 -1
  44. package/dist/cjs/plugins/index.d.ts +0 -10
  45. package/dist/cjs/plugins/index.d.ts.map +0 -1
  46. package/dist/cjs/plugins/index.js +0 -52
  47. package/dist/cjs/plugins/useArmor.d.ts +0 -4
  48. package/dist/cjs/plugins/useArmor.d.ts.map +0 -1
  49. package/dist/cjs/plugins/useArmor.js +0 -69
  50. package/dist/cjs/plugins/useRedwoodAuthContext.d.ts +0 -9
  51. package/dist/cjs/plugins/useRedwoodAuthContext.d.ts.map +0 -1
  52. package/dist/cjs/plugins/useRedwoodAuthContext.js +0 -74
  53. package/dist/cjs/plugins/useRedwoodDirective.d.ts +0 -83
  54. package/dist/cjs/plugins/useRedwoodDirective.d.ts.map +0 -1
  55. package/dist/cjs/plugins/useRedwoodDirective.js +0 -166
  56. package/dist/cjs/plugins/useRedwoodError.d.ts +0 -20
  57. package/dist/cjs/plugins/useRedwoodError.d.ts.map +0 -1
  58. package/dist/cjs/plugins/useRedwoodError.js +0 -62
  59. package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts +0 -9
  60. package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts.map +0 -1
  61. package/dist/cjs/plugins/useRedwoodGlobalContextSetter.js +0 -35
  62. package/dist/cjs/plugins/useRedwoodLogger.d.ts +0 -115
  63. package/dist/cjs/plugins/useRedwoodLogger.d.ts.map +0 -1
  64. package/dist/cjs/plugins/useRedwoodLogger.js +0 -156
  65. package/dist/cjs/plugins/useRedwoodOpenTelemetry.d.ts +0 -22
  66. package/dist/cjs/plugins/useRedwoodOpenTelemetry.d.ts.map +0 -1
  67. package/dist/cjs/plugins/useRedwoodOpenTelemetry.js +0 -156
  68. package/dist/cjs/plugins/useRedwoodPopulateContext.d.ts +0 -9
  69. package/dist/cjs/plugins/useRedwoodPopulateContext.d.ts.map +0 -1
  70. package/dist/cjs/plugins/useRedwoodPopulateContext.js +0 -35
  71. package/dist/cjs/plugins/useRedwoodTrustedDocuments.d.ts +0 -23
  72. package/dist/cjs/plugins/useRedwoodTrustedDocuments.d.ts.map +0 -1
  73. package/dist/cjs/plugins/useRedwoodTrustedDocuments.js +0 -80
  74. package/dist/cjs/rootSchema.d.ts +0 -25
  75. package/dist/cjs/rootSchema.d.ts.map +0 -1
  76. package/dist/cjs/rootSchema.js +0 -108
  77. package/dist/cjs/subscriptions/makeSubscriptions.d.ts +0 -18
  78. package/dist/cjs/subscriptions/makeSubscriptions.d.ts.map +0 -1
  79. package/dist/cjs/subscriptions/makeSubscriptions.js +0 -40
  80. package/dist/cjs/types.d.ts +0 -231
  81. package/dist/cjs/types.d.ts.map +0 -1
  82. package/dist/cjs/types.js +0 -16
@@ -1 +1 @@
1
- {"version":3,"file":"useRedwoodAuthContext.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodAuthContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAsB,OAAO,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,gBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EACvD,cAAc,OAAO,GAAG,OAAO,EAAE,KAChC,MAAM,CAAC,mBAAmB,CAyC5B,CAAA"}
1
+ {"version":3,"file":"useRedwoodAuthContext.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodAuthContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAsB,OAAO,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,gBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EACvD,cAAc,OAAO,GAAG,OAAO,EAAE,KAChC,MAAM,CAAC,mBAAmB,CA2C5B,CAAA"}
@@ -1,22 +1,13 @@
1
- import { getAuthenticationContext } from "@cedarjs/api";
1
+ import { hasAuthDecoder } from "@cedarjs/api";
2
2
  const useRedwoodAuthContext = (getCurrentUser, authDecoder) => {
3
3
  return {
4
4
  async onContextBuilding({ context, extendContext }) {
5
- let authContext = context.cedarContext?.serverAuthState;
6
- try {
7
- if (!authContext) {
8
- const authEvent = getAuthEvent(context);
9
- authContext = await getAuthenticationContext({
10
- authDecoder,
11
- event: authEvent,
12
- context: context.requestContext
13
- });
14
- }
15
- } catch (error) {
5
+ if (!context.cedarContext && hasAuthDecoder(authDecoder)) {
16
6
  throw new Error(
17
- `Exception in getAuthenticationContext: ${error.message}`
7
+ "Auth state is resolved when a request enters Cedar and passed on the GraphQL context, but this context has no `cedarContext`. Whatever is invoking `yoga.handle` needs to build one with `buildCedarContext` from `@cedarjs/api/runtime` and pass it as `cedarContext`."
18
8
  );
19
9
  }
10
+ const authContext = context.cedarContext?.serverAuthState;
20
11
  try {
21
12
  if (authContext) {
22
13
  const currentUser = getCurrentUser ? await getCurrentUser(
@@ -34,17 +25,6 @@ const useRedwoodAuthContext = (getCurrentUser, authDecoder) => {
34
25
  }
35
26
  };
36
27
  };
37
- function getAuthEvent(context) {
38
- if (context.request) {
39
- return context.request;
40
- }
41
- if (context.event) {
42
- return context.event;
43
- }
44
- throw new Error(
45
- "GraphQL context contains neither a fetch-native Request nor a Lambda event. Please report this as a Cedar bug."
46
- );
47
- }
48
28
  export {
49
29
  useRedwoodAuthContext
50
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/graphql-server",
3
- "version": "5.0.6",
3
+ "version": "5.0.7-next.186",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -10,13 +10,9 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
- "import": {
13
+ "default": {
14
14
  "types": "./dist/index.d.ts",
15
15
  "default": "./dist/index.js"
16
- },
17
- "require": {
18
- "types": "./dist/cjs/index.d.ts",
19
- "default": "./dist/cjs/index.js"
20
16
  }
21
17
  }
22
18
  },
@@ -28,7 +24,6 @@
28
24
  "build": "node ./build.mts",
29
25
  "build:pack": "yarn pack -o cedarjs-graphql-server.tgz",
30
26
  "build:types": "tsc --build --verbose ./tsconfig.build.json",
31
- "build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
32
27
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
33
28
  "check:attw": "yarn cedar-fwtools-attw",
34
29
  "check:package": "concurrently npm:check:attw yarn:publint",
@@ -37,16 +32,16 @@
37
32
  "test:watch": "yarn test --watch"
38
33
  },
39
34
  "dependencies": {
40
- "@cedarjs/api": "5.0.6",
41
- "@cedarjs/context": "5.0.6",
35
+ "@cedarjs/api": "5.0.7-next.186",
36
+ "@cedarjs/context": "5.0.7-next.186",
42
37
  "@envelop/core": "5.5.1",
43
38
  "@envelop/depth-limit": "4.0.0",
44
39
  "@envelop/disable-introspection": "6.0.0",
45
40
  "@envelop/filter-operation-type": "6.0.0",
46
41
  "@envelop/on-resolve": "4.1.1",
47
42
  "@escape.tech/graphql-armor": "3.0.1",
48
- "@graphql-tools/merge": "9.1.9",
49
- "@graphql-tools/schema": "10.0.33",
43
+ "@graphql-tools/merge": "9.2.2",
44
+ "@graphql-tools/schema": "10.0.38",
50
45
  "@graphql-tools/utils": "10.11.0",
51
46
  "@graphql-yoga/plugin-persisted-operations": "3.21.2",
52
47
  "@opentelemetry/api": "1.9.1",
@@ -61,9 +56,9 @@
61
56
  "devDependencies": {
62
57
  "@babel/cli": "7.29.7",
63
58
  "@babel/core": "^7.26.10",
64
- "@cedarjs/framework-tools": "5.0.6",
65
- "@cedarjs/project-config": "5.0.6",
66
- "@cedarjs/realtime": "5.0.6",
59
+ "@cedarjs/framework-tools": "5.0.7-next.186",
60
+ "@cedarjs/project-config": "5.0.7-next.186",
61
+ "@cedarjs/realtime": "5.0.7-next.186",
67
62
  "@envelop/types": "5.2.1",
68
63
  "@types/aws-lambda": "8.10.162",
69
64
  "@types/jsonwebtoken": "9.0.10",
@@ -72,9 +67,9 @@
72
67
  "@whatwg-node/promise-helpers": "^1.3.0",
73
68
  "concurrently": "9.2.4",
74
69
  "jsonwebtoken": "9.0.3",
75
- "publint": "0.3.21",
70
+ "publint": "0.3.22",
76
71
  "typescript": "5.9.3",
77
- "vitest": "3.2.6"
72
+ "vitest": "4.1.10"
78
73
  },
79
74
  "engines": {
80
75
  "node": ">=24"
@@ -1,10 +0,0 @@
1
- import type { CorsConfig } from '@cedarjs/api';
2
- export declare const mapRwCorsOptionsToYoga: (rwCorsConfig?: CorsConfig, requestOrigin?: string | null) => false | {
3
- origin?: string[] | string;
4
- methods?: string[];
5
- allowedHeaders?: string[];
6
- exposedHeaders?: string[];
7
- credentials?: boolean;
8
- maxAge?: number;
9
- };
10
- //# sourceMappingURL=cors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../src/cors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,eAAO,MAAM,sBAAsB,GACjC,eAAe,UAAU,EACzB,gBAAgB,MAAM,GAAG,IAAI;;;;;;;CAoD9B,CAAA"}
package/dist/cjs/cors.js DELETED
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var cors_exports = {};
20
- __export(cors_exports, {
21
- mapRwCorsOptionsToYoga: () => mapRwCorsOptionsToYoga
22
- });
23
- module.exports = __toCommonJS(cors_exports);
24
- const mapRwCorsOptionsToYoga = (rwCorsConfig, requestOrigin) => {
25
- const yogaCORSOptions = {};
26
- if (!rwCorsConfig) {
27
- return false;
28
- }
29
- if (rwCorsConfig?.methods) {
30
- if (typeof rwCorsConfig.methods === "string") {
31
- yogaCORSOptions.methods = [rwCorsConfig.methods];
32
- } else if (Array.isArray(rwCorsConfig.methods)) {
33
- yogaCORSOptions.methods = rwCorsConfig.methods;
34
- }
35
- }
36
- if (rwCorsConfig?.allowedHeaders) {
37
- if (typeof rwCorsConfig.allowedHeaders === "string") {
38
- yogaCORSOptions.allowedHeaders = [rwCorsConfig.allowedHeaders];
39
- } else if (Array.isArray(rwCorsConfig.allowedHeaders)) {
40
- yogaCORSOptions.allowedHeaders = rwCorsConfig.allowedHeaders;
41
- }
42
- }
43
- if (rwCorsConfig?.exposedHeaders) {
44
- if (typeof rwCorsConfig.exposedHeaders === "string") {
45
- yogaCORSOptions.exposedHeaders = [rwCorsConfig.exposedHeaders];
46
- } else if (Array.isArray(rwCorsConfig.exposedHeaders)) {
47
- yogaCORSOptions.exposedHeaders = rwCorsConfig.exposedHeaders;
48
- }
49
- }
50
- if (rwCorsConfig?.credentials) {
51
- yogaCORSOptions.credentials = rwCorsConfig.credentials;
52
- }
53
- if (rwCorsConfig?.maxAge) {
54
- yogaCORSOptions.maxAge = rwCorsConfig.maxAge;
55
- }
56
- if (rwCorsConfig?.origin) {
57
- if (typeof rwCorsConfig.origin === "string") {
58
- yogaCORSOptions.origin = [rwCorsConfig.origin];
59
- } else if (rwCorsConfig.origin === true) {
60
- yogaCORSOptions.origin = [requestOrigin || "*"];
61
- } else {
62
- yogaCORSOptions.origin = rwCorsConfig.origin;
63
- }
64
- }
65
- return yogaCORSOptions;
66
- };
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- mapRwCorsOptionsToYoga
70
- });
@@ -1,6 +0,0 @@
1
- import type { GraphQLYogaOptions } from './types.js';
2
- export declare const createGraphQLYoga: ({ healthCheckId, loggerConfig, context, getCurrentUser, onException, generateGraphiQLHeader, extraPlugins, authDecoder, cors, services, sdls, directives, armorConfig, allowedOperations, allowIntrospection, allowGraphiQL, defaultError, graphiQLEndpoint, schemaOptions, realtime, trustedDocuments, openTelemetryOptions, includeScalars, }: GraphQLYogaOptions) => Promise<{
3
- yoga: ServerAdapter<TServerContext, import("graphql-yoga").YogaServer<TServerContext, TUserContext>>;
4
- logger: import("@cedarjs/api/logger").Logger;
5
- }>;
6
- //# sourceMappingURL=createGraphQLYoga.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createGraphQLYoga.d.ts","sourceRoot":"","sources":["../../src/createGraphQLYoga.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,YAAY,CAAA;AAEzE,eAAO,MAAM,iBAAiB,GAAU,iVAwBrC,kBAAkB;;;EAuLpB,CAAA"}
@@ -1,193 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var createGraphQLYoga_exports = {};
30
- __export(createGraphQLYoga_exports, {
31
- createGraphQLYoga: () => createGraphQLYoga
32
- });
33
- module.exports = __toCommonJS(createGraphQLYoga_exports);
34
- var import_disable_introspection = require("@envelop/disable-introspection");
35
- var import_filter_operation_type = require("@envelop/filter-operation-type");
36
- var import_graphql = require("graphql");
37
- var import_graphql_yoga = require("graphql-yoga");
38
- var import_cors = require("./cors.js");
39
- var import_makeDirectives = require("./directives/makeDirectives.js");
40
- var import_graphiql = require("./graphiql.js");
41
- var import_introspection = require("./introspection.js");
42
- var import_makeMergedSchema = require("./makeMergedSchema.js");
43
- var import_plugins = require("./plugins/index.js");
44
- var import_makeSubscriptions = require("./subscriptions/makeSubscriptions.js");
45
- const createGraphQLYoga = async ({
46
- healthCheckId = "yoga",
47
- loggerConfig,
48
- context,
49
- getCurrentUser,
50
- onException,
51
- generateGraphiQLHeader,
52
- extraPlugins,
53
- authDecoder,
54
- cors,
55
- services,
56
- sdls,
57
- directives = [],
58
- armorConfig,
59
- allowedOperations,
60
- allowIntrospection,
61
- allowGraphiQL,
62
- defaultError = "Something went wrong.",
63
- graphiQLEndpoint = "/graphql",
64
- schemaOptions,
65
- realtime,
66
- trustedDocuments,
67
- openTelemetryOptions,
68
- includeScalars
69
- }) => {
70
- let schema;
71
- let redwoodDirectivePlugins = [];
72
- const logger = loggerConfig.logger;
73
- const isDevEnv = process.env.NODE_ENV === "development";
74
- try {
75
- const projectDirectives = (0, import_makeDirectives.makeDirectivesForPlugin)(directives);
76
- if (projectDirectives.length > 0) {
77
- ;
78
- redwoodDirectivePlugins = projectDirectives.map(
79
- (directive) => (0, import_plugins.useRedwoodDirective)(directive)
80
- );
81
- }
82
- let projectSubscriptions = [];
83
- if (realtime?.subscriptions?.subscriptions) {
84
- projectSubscriptions = (0, import_makeSubscriptions.makeSubscriptions)(
85
- realtime.subscriptions.subscriptions
86
- );
87
- }
88
- schema = (0, import_makeMergedSchema.makeMergedSchema)({
89
- sdls,
90
- services,
91
- directives: projectDirectives,
92
- subscriptions: projectSubscriptions,
93
- schemaOptions,
94
- includeScalars
95
- });
96
- } catch (e) {
97
- logger.fatal(e, "\n \u26A0\uFE0F GraphQL server crashed \n");
98
- if (onException) {
99
- onException();
100
- }
101
- process.exit(1);
102
- }
103
- try {
104
- const plugins = [];
105
- if (realtime) {
106
- const { useCedarRealtime } = await import("@cedarjs/realtime");
107
- plugins.push(useCedarRealtime(realtime));
108
- }
109
- plugins.push((0, import_graphql_yoga.useExecutionCancellation)());
110
- const { disableIntrospection } = (0, import_introspection.configureGraphQLIntrospection)({
111
- allowIntrospection
112
- });
113
- if (disableIntrospection) {
114
- plugins.push((0, import_disable_introspection.useDisableIntrospection)());
115
- }
116
- plugins.push((0, import_plugins.useRedwoodAuthContext)(getCurrentUser, authDecoder));
117
- plugins.push((0, import_plugins.useRedwoodGlobalContextSetter)());
118
- if (context) {
119
- plugins.push((0, import_plugins.useRedwoodPopulateContext)(context));
120
- }
121
- plugins.push(...redwoodDirectivePlugins);
122
- if (openTelemetryOptions !== void 0) {
123
- plugins.push((0, import_plugins.useRedwoodOpenTelemetry)(openTelemetryOptions));
124
- }
125
- plugins.push((0, import_plugins.useArmor)(logger, armorConfig));
126
- const defaultAllowedOperations = [
127
- import_graphql.OperationTypeNode.QUERY,
128
- import_graphql.OperationTypeNode.MUTATION
129
- ];
130
- if (realtime?.subscriptions?.subscriptions) {
131
- defaultAllowedOperations.push(import_graphql.OperationTypeNode.SUBSCRIPTION);
132
- }
133
- plugins.push(
134
- (0, import_filter_operation_type.useFilterAllowedOperations)(allowedOperations || defaultAllowedOperations)
135
- );
136
- if (trustedDocuments && !trustedDocuments.disabled) {
137
- plugins.push((0, import_plugins.useRedwoodTrustedDocuments)(trustedDocuments));
138
- }
139
- if (extraPlugins && extraPlugins.length > 0) {
140
- plugins.push(...extraPlugins);
141
- }
142
- plugins.push((0, import_plugins.useRedwoodError)(logger));
143
- plugins.push(
144
- (0, import_graphql_yoga.useReadinessCheck)({
145
- endpoint: graphiQLEndpoint + "/readiness",
146
- check: async ({ request }) => {
147
- try {
148
- const response = await yoga.fetch(
149
- new URL(graphiQLEndpoint + "/health", request.url)
150
- );
151
- const status = response.headers.get("x-yoga-id") === healthCheckId && request.headers.get("x-yoga-id") === healthCheckId;
152
- return status;
153
- } catch (err) {
154
- logger.error(err);
155
- return false;
156
- }
157
- }
158
- })
159
- );
160
- plugins.push((0, import_plugins.useRedwoodLogger)(loggerConfig));
161
- const yoga = (0, import_graphql_yoga.createYoga)({
162
- id: healthCheckId,
163
- landingPage: isDevEnv,
164
- schema,
165
- plugins,
166
- maskedErrors: {
167
- errorMessage: defaultError,
168
- isDev: isDevEnv
169
- },
170
- logging: logger,
171
- healthCheckEndpoint: graphiQLEndpoint + "/health",
172
- graphqlEndpoint: graphiQLEndpoint,
173
- graphiql: (0, import_graphiql.configureGraphiQLPlayground)({
174
- allowGraphiQL,
175
- generateGraphiQLHeader
176
- }),
177
- cors: (request) => {
178
- const requestOrigin = request.headers.get("origin");
179
- return (0, import_cors.mapRwCorsOptionsToYoga)(cors, requestOrigin);
180
- }
181
- });
182
- return { yoga, logger };
183
- } catch (e) {
184
- if (onException) {
185
- onException();
186
- }
187
- throw e;
188
- }
189
- };
190
- // Annotate the CommonJS export names for ESM import in node:
191
- 0 && (module.exports = {
192
- createGraphQLYoga
193
- });
@@ -1,8 +0,0 @@
1
- import { type DocumentNode } from 'graphql';
2
- import type { RedwoodDirective, TransformerDirective, TransformerDirectiveFunc, ValidatorDirective, ValidatorDirectiveFunc } from '../plugins/useRedwoodDirective.js';
3
- export type DirectiveGlobImports = Record<string, any>;
4
- export declare const makeDirectivesForPlugin: (directiveGlobs: DirectiveGlobImports) => RedwoodDirective[];
5
- export declare const getDirectiveName: (schema: DocumentNode) => string | undefined;
6
- export declare const createValidatorDirective: (schema: DocumentNode, directiveFunc: ValidatorDirectiveFunc) => ValidatorDirective;
7
- export declare const createTransformerDirective: (schema: DocumentNode, directiveFunc: TransformerDirectiveFunc) => TransformerDirective;
8
- //# sourceMappingURL=makeDirectives.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeDirectives.d.ts","sourceRoot":"","sources":["../../../src/directives/makeDirectives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,mCAAmC,CAAA;AAW1C,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEtD,eAAO,MAAM,uBAAuB,GAClC,gBAAgB,oBAAoB,KACnC,gBAAgB,EAwBlB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,YAAY,uBAMpD,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,QAAQ,YAAY,EACpB,eAAe,sBAAsB,KACpC,kBAmBF,CAAA;AAED,eAAO,MAAM,0BAA0B,GACrC,QAAQ,YAAY,EACpB,eAAe,wBAAwB,KACtC,oBAmBF,CAAA"}
@@ -1,89 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var makeDirectives_exports = {};
20
- __export(makeDirectives_exports, {
21
- createTransformerDirective: () => createTransformerDirective,
22
- createValidatorDirective: () => createValidatorDirective,
23
- getDirectiveName: () => getDirectiveName,
24
- makeDirectivesForPlugin: () => makeDirectivesForPlugin
25
- });
26
- module.exports = __toCommonJS(makeDirectives_exports);
27
- var import_graphql = require("graphql");
28
- var import_useRedwoodDirective = require("../plugins/useRedwoodDirective.js");
29
- const makeDirectivesForPlugin = (directiveGlobs) => {
30
- return Object.entries(directiveGlobs).flatMap(
31
- ([importedGlobName, exports2]) => {
32
- const [directiveNameFromFile] = importedGlobName.split("_").slice(-2);
33
- const directive = exports2[directiveNameFromFile] || exports2.default;
34
- if (!directive.type) {
35
- throw new Error(
36
- "Please use `createValidatorDirective` or `createTransformerDirective` functions to define your directive"
37
- );
38
- }
39
- return [directive];
40
- }
41
- );
42
- };
43
- const getDirectiveName = (schema) => {
44
- const definition = schema.definitions.find(
45
- (definition2) => definition2.kind === import_graphql.Kind.DIRECTIVE_DEFINITION
46
- );
47
- return definition?.name?.value;
48
- };
49
- const createValidatorDirective = (schema, directiveFunc) => {
50
- const directiveName = getDirectiveName(schema);
51
- if (!directiveName) {
52
- throw new Error("Could not parse directive schema");
53
- }
54
- if (typeof directiveFunc !== "function") {
55
- throw new Error(
56
- `Directive validation function not implemented for @${directiveName}`
57
- );
58
- }
59
- return {
60
- name: directiveName,
61
- schema,
62
- onResolvedValue: directiveFunc,
63
- type: import_useRedwoodDirective.DirectiveType.VALIDATOR
64
- };
65
- };
66
- const createTransformerDirective = (schema, directiveFunc) => {
67
- const directiveName = getDirectiveName(schema);
68
- if (!directiveName) {
69
- throw new Error("Could not parse directive schema");
70
- }
71
- if (typeof directiveFunc !== "function") {
72
- throw new Error(
73
- `Directive transformer function not implemented for @${directiveName}`
74
- );
75
- }
76
- return {
77
- name: directiveName,
78
- schema,
79
- onResolvedValue: directiveFunc,
80
- type: import_useRedwoodDirective.DirectiveType.TRANSFORMER
81
- };
82
- };
83
- // Annotate the CommonJS export names for ESM import in node:
84
- 0 && (module.exports = {
85
- createTransformerDirective,
86
- createValidatorDirective,
87
- getDirectiveName,
88
- makeDirectivesForPlugin
89
- });
@@ -1,32 +0,0 @@
1
- import { GraphQLError } from 'graphql';
2
- export declare class CedarGraphQLError extends GraphQLError {
3
- constructor(message: string, extensions?: Record<string, any>, originalError?: Error & {
4
- readonly extensions?: unknown;
5
- });
6
- }
7
- /** @deprecated Use `CedarGraphQLError` instead */
8
- export declare const RedwoodGraphQLError: typeof CedarGraphQLError;
9
- /** @deprecated Use `CedarGraphQLError` instead */
10
- export type RedwoodGraphQLError = CedarGraphQLError;
11
- export declare class SyntaxError extends CedarGraphQLError {
12
- constructor(message: string);
13
- }
14
- export declare class ValidationError extends CedarGraphQLError {
15
- constructor(message: string);
16
- }
17
- export declare class AuthenticationError extends CedarGraphQLError {
18
- constructor(message: string);
19
- }
20
- export declare class ForbiddenError extends CedarGraphQLError {
21
- constructor(message: string);
22
- }
23
- export declare class PersistedQueryNotFoundError extends CedarGraphQLError {
24
- constructor();
25
- }
26
- export declare class PersistedQueryNotSupportedError extends CedarGraphQLError {
27
- constructor();
28
- }
29
- export declare class UserInputError extends CedarGraphQLError {
30
- constructor(message: string, properties?: Record<string, any>);
31
- }
32
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,qBAAa,iBAAkB,SAAQ,YAAY;gBAE/C,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,aAAa,CAAC,EAAE,KAAK,GAAG;QACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAC9B;CAYJ;AAED,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,0BAAoB,CAAA;AASpD,kDAAkD;AAClD,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAA;AAEnD,qBAAa,WAAY,SAAQ,iBAAiB;gBACpC,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,eAAgB,SAAQ,iBAAiB;gBACxC,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,mBAAoB,SAAQ,iBAAiB;gBAC5C,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,cAAe,SAAQ,iBAAiB;gBACvC,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,2BAA4B,SAAQ,iBAAiB;;CAMjE;AAED,qBAAa,+BAAgC,SAAQ,iBAAiB;;CAQrE;AAED,qBAAa,cAAe,SAAQ,iBAAiB;gBACvC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAK9D"}
@@ -1,101 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var errors_exports = {};
20
- __export(errors_exports, {
21
- AuthenticationError: () => AuthenticationError,
22
- CedarGraphQLError: () => CedarGraphQLError,
23
- ForbiddenError: () => ForbiddenError,
24
- PersistedQueryNotFoundError: () => PersistedQueryNotFoundError,
25
- PersistedQueryNotSupportedError: () => PersistedQueryNotSupportedError,
26
- RedwoodGraphQLError: () => RedwoodGraphQLError,
27
- SyntaxError: () => SyntaxError,
28
- UserInputError: () => UserInputError,
29
- ValidationError: () => ValidationError
30
- });
31
- module.exports = __toCommonJS(errors_exports);
32
- var import_graphql = require("graphql");
33
- class CedarGraphQLError extends import_graphql.GraphQLError {
34
- constructor(message, extensions, originalError) {
35
- super(message, {
36
- extensions: {
37
- ...extensions,
38
- code: extensions?.code || "REDWOODJS_ERROR"
39
- },
40
- originalError
41
- });
42
- Object.setPrototypeOf(this, import_graphql.GraphQLError.prototype);
43
- }
44
- }
45
- const RedwoodGraphQLError = CedarGraphQLError;
46
- class SyntaxError extends CedarGraphQLError {
47
- constructor(message) {
48
- super(message, { code: "GRAPHQL_PARSE_FAILED" });
49
- Object.setPrototypeOf(this, SyntaxError.prototype);
50
- }
51
- }
52
- class ValidationError extends CedarGraphQLError {
53
- constructor(message) {
54
- super(message, { code: "GRAPHQL_VALIDATION_FAILED" });
55
- Object.setPrototypeOf(this, ValidationError.prototype);
56
- }
57
- }
58
- class AuthenticationError extends CedarGraphQLError {
59
- constructor(message) {
60
- super(message, { code: "UNAUTHENTICATED" });
61
- Object.setPrototypeOf(this, AuthenticationError.prototype);
62
- }
63
- }
64
- class ForbiddenError extends CedarGraphQLError {
65
- constructor(message) {
66
- super(message, { code: "FORBIDDEN" });
67
- Object.setPrototypeOf(this, ForbiddenError.prototype);
68
- }
69
- }
70
- class PersistedQueryNotFoundError extends CedarGraphQLError {
71
- constructor() {
72
- super("PersistedQueryNotFound", { code: "PERSISTED_QUERY_NOT_FOUND" });
73
- Object.setPrototypeOf(this, PersistedQueryNotFoundError.prototype);
74
- }
75
- }
76
- class PersistedQueryNotSupportedError extends CedarGraphQLError {
77
- constructor() {
78
- super("PersistedQueryNotSupported", {
79
- code: "PERSISTED_QUERY_NOT_SUPPORTED"
80
- });
81
- Object.setPrototypeOf(this, PersistedQueryNotSupportedError.prototype);
82
- }
83
- }
84
- class UserInputError extends CedarGraphQLError {
85
- constructor(message, properties) {
86
- super(message, { code: "BAD_USER_INPUT", properties });
87
- Object.setPrototypeOf(this, UserInputError.prototype);
88
- }
89
- }
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
92
- AuthenticationError,
93
- CedarGraphQLError,
94
- ForbiddenError,
95
- PersistedQueryNotFoundError,
96
- PersistedQueryNotSupportedError,
97
- RedwoodGraphQLError,
98
- SyntaxError,
99
- UserInputError,
100
- ValidationError
101
- });
@@ -1,15 +0,0 @@
1
- import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda';
2
- import type { GraphQLHandlerOptions } from '../types.js';
3
- /**
4
- * Creates an Enveloped GraphQL Server, configured with default Redwood plugins
5
- *
6
- * You can add your own plugins by passing them to the extraPlugins object
7
- *
8
- * @see https://www.envelop.dev/ for information about envelop
9
- * @see https://www.envelop.dev/plugins for available envelop plugins
10
- * ```js
11
- * export const handler = createGraphQLHandler({ schema, context, getCurrentUser })
12
- * ```
13
- */
14
- export declare const createGraphQLHandler: ({ healthCheckId, loggerConfig, context, getCurrentUser, onException, generateGraphiQLHeader, extraPlugins, authDecoder, cors, services, sdls, directives, armorConfig, allowedOperations, allowIntrospection, allowGraphiQL, defaultError, graphiQLEndpoint, schemaOptions, realtime, openTelemetryOptions, trustedDocuments, }: GraphQLHandlerOptions) => (event: APIGatewayProxyEvent, context: LambdaContext) => Promise<any>;
15
- //# sourceMappingURL=graphql.d.ts.map