@cedarjs/graphql-server 4.2.0 → 4.2.1-next.258
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/dist/cjs/createGraphQLYoga.d.ts.map +1 -1
- package/dist/cjs/createGraphQLYoga.js +1 -0
- package/dist/cjs/errors.d.ts +12 -8
- package/dist/cjs/errors.d.ts.map +1 -1
- package/dist/cjs/errors.js +11 -8
- package/dist/cjs/functions/graphql.d.ts.map +1 -1
- package/dist/cjs/functions/graphql.js +15 -8
- package/dist/cjs/plugins/useRedwoodTrustedDocuments.js +4 -4
- package/dist/createGraphQLYoga.d.ts.map +1 -1
- package/dist/createGraphQLYoga.js +6 -1
- package/dist/errors.d.ts +12 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -8
- package/dist/functions/graphql.d.ts.map +1 -1
- package/dist/functions/graphql.js +15 -8
- package/dist/plugins/useRedwoodTrustedDocuments.js +4 -4
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGraphQLYoga.d.ts","sourceRoot":"","sources":["../../src/createGraphQLYoga.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -106,6 +106,7 @@ const createGraphQLYoga = async ({
|
|
|
106
106
|
const { useCedarRealtime } = await import("@cedarjs/realtime");
|
|
107
107
|
plugins.push(useCedarRealtime(realtime));
|
|
108
108
|
}
|
|
109
|
+
plugins.push((0, import_graphql_yoga.useExecutionCancellation)());
|
|
109
110
|
const { disableIntrospection } = (0, import_introspection.configureGraphQLIntrospection)({
|
|
110
111
|
allowIntrospection
|
|
111
112
|
});
|
package/dist/cjs/errors.d.ts
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class CedarGraphQLError extends GraphQLError {
|
|
3
3
|
constructor(message: string, extensions?: Record<string, any>, originalError?: Error & {
|
|
4
4
|
readonly extensions?: unknown;
|
|
5
5
|
});
|
|
6
6
|
}
|
|
7
|
-
|
|
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 {
|
|
8
12
|
constructor(message: string);
|
|
9
13
|
}
|
|
10
|
-
export declare class ValidationError extends
|
|
14
|
+
export declare class ValidationError extends CedarGraphQLError {
|
|
11
15
|
constructor(message: string);
|
|
12
16
|
}
|
|
13
|
-
export declare class AuthenticationError extends
|
|
17
|
+
export declare class AuthenticationError extends CedarGraphQLError {
|
|
14
18
|
constructor(message: string);
|
|
15
19
|
}
|
|
16
|
-
export declare class ForbiddenError extends
|
|
20
|
+
export declare class ForbiddenError extends CedarGraphQLError {
|
|
17
21
|
constructor(message: string);
|
|
18
22
|
}
|
|
19
|
-
export declare class PersistedQueryNotFoundError extends
|
|
23
|
+
export declare class PersistedQueryNotFoundError extends CedarGraphQLError {
|
|
20
24
|
constructor();
|
|
21
25
|
}
|
|
22
|
-
export declare class PersistedQueryNotSupportedError extends
|
|
26
|
+
export declare class PersistedQueryNotSupportedError extends CedarGraphQLError {
|
|
23
27
|
constructor();
|
|
24
28
|
}
|
|
25
|
-
export declare class UserInputError extends
|
|
29
|
+
export declare class UserInputError extends CedarGraphQLError {
|
|
26
30
|
constructor(message: string, properties?: Record<string, any>);
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/cjs/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,qBAAa,
|
|
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"}
|
package/dist/cjs/errors.js
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var errors_exports = {};
|
|
20
20
|
__export(errors_exports, {
|
|
21
21
|
AuthenticationError: () => AuthenticationError,
|
|
22
|
+
CedarGraphQLError: () => CedarGraphQLError,
|
|
22
23
|
ForbiddenError: () => ForbiddenError,
|
|
23
24
|
PersistedQueryNotFoundError: () => PersistedQueryNotFoundError,
|
|
24
25
|
PersistedQueryNotSupportedError: () => PersistedQueryNotSupportedError,
|
|
@@ -29,7 +30,7 @@ __export(errors_exports, {
|
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(errors_exports);
|
|
31
32
|
var import_graphql = require("graphql");
|
|
32
|
-
class
|
|
33
|
+
class CedarGraphQLError extends import_graphql.GraphQLError {
|
|
33
34
|
constructor(message, extensions, originalError) {
|
|
34
35
|
super(message, {
|
|
35
36
|
extensions: {
|
|
@@ -41,37 +42,38 @@ class RedwoodGraphQLError extends import_graphql.GraphQLError {
|
|
|
41
42
|
Object.setPrototypeOf(this, import_graphql.GraphQLError.prototype);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
const RedwoodGraphQLError = CedarGraphQLError;
|
|
46
|
+
class SyntaxError extends CedarGraphQLError {
|
|
45
47
|
constructor(message) {
|
|
46
48
|
super(message, { code: "GRAPHQL_PARSE_FAILED" });
|
|
47
49
|
Object.setPrototypeOf(this, SyntaxError.prototype);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
class ValidationError extends
|
|
52
|
+
class ValidationError extends CedarGraphQLError {
|
|
51
53
|
constructor(message) {
|
|
52
54
|
super(message, { code: "GRAPHQL_VALIDATION_FAILED" });
|
|
53
55
|
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
class AuthenticationError extends
|
|
58
|
+
class AuthenticationError extends CedarGraphQLError {
|
|
57
59
|
constructor(message) {
|
|
58
60
|
super(message, { code: "UNAUTHENTICATED" });
|
|
59
61
|
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
|
-
class ForbiddenError extends
|
|
64
|
+
class ForbiddenError extends CedarGraphQLError {
|
|
63
65
|
constructor(message) {
|
|
64
66
|
super(message, { code: "FORBIDDEN" });
|
|
65
67
|
Object.setPrototypeOf(this, ForbiddenError.prototype);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
|
-
class PersistedQueryNotFoundError extends
|
|
70
|
+
class PersistedQueryNotFoundError extends CedarGraphQLError {
|
|
69
71
|
constructor() {
|
|
70
72
|
super("PersistedQueryNotFound", { code: "PERSISTED_QUERY_NOT_FOUND" });
|
|
71
73
|
Object.setPrototypeOf(this, PersistedQueryNotFoundError.prototype);
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
|
-
class PersistedQueryNotSupportedError extends
|
|
76
|
+
class PersistedQueryNotSupportedError extends CedarGraphQLError {
|
|
75
77
|
constructor() {
|
|
76
78
|
super("PersistedQueryNotSupported", {
|
|
77
79
|
code: "PERSISTED_QUERY_NOT_SUPPORTED"
|
|
@@ -79,7 +81,7 @@ class PersistedQueryNotSupportedError extends RedwoodGraphQLError {
|
|
|
79
81
|
Object.setPrototypeOf(this, PersistedQueryNotSupportedError.prototype);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
|
-
class UserInputError extends
|
|
84
|
+
class UserInputError extends CedarGraphQLError {
|
|
83
85
|
constructor(message, properties) {
|
|
84
86
|
super(message, { code: "BAD_USER_INPUT", properties });
|
|
85
87
|
Object.setPrototypeOf(this, UserInputError.prototype);
|
|
@@ -88,6 +90,7 @@ class UserInputError extends RedwoodGraphQLError {
|
|
|
88
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
89
91
|
0 && (module.exports = {
|
|
90
92
|
AuthenticationError,
|
|
93
|
+
CedarGraphQLError,
|
|
91
94
|
ForbiddenError,
|
|
92
95
|
PersistedQueryNotFoundError,
|
|
93
96
|
PersistedQueryNotSupportedError,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/functions/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAQnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AA4CxD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,iUAuBlC,qBAAqB,MA+
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/functions/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAQnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AA4CxD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,iUAuBlC,qBAAqB,MA+IpB,OAAO,oBAAoB,EAC3B,SAAS,aAAa,KACrB,OAAO,CAAC,GAAG,CAcf,CAAA"}
|
|
@@ -159,15 +159,22 @@ const createGraphQLHandler = ({
|
|
|
159
159
|
isBase64Encoded: false
|
|
160
160
|
};
|
|
161
161
|
} catch (e) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
163
|
+
lambdaResponse = {
|
|
164
|
+
body: JSON.stringify({ error: "Client disconnected" }),
|
|
165
|
+
statusCode: 499
|
|
166
|
+
};
|
|
167
|
+
} else {
|
|
168
|
+
logger.error(e);
|
|
169
|
+
if (onException) {
|
|
170
|
+
onException();
|
|
171
|
+
}
|
|
172
|
+
lambdaResponse = {
|
|
173
|
+
body: JSON.stringify({ error: "GraphQL execution failed" }),
|
|
174
|
+
statusCode: 200
|
|
175
|
+
// should be 500
|
|
176
|
+
};
|
|
165
177
|
}
|
|
166
|
-
lambdaResponse = {
|
|
167
|
-
body: JSON.stringify({ error: "GraphQL execution failed" }),
|
|
168
|
-
statusCode: 200
|
|
169
|
-
// should be 500
|
|
170
|
-
};
|
|
171
178
|
}
|
|
172
179
|
if (!lambdaResponse.headers) {
|
|
173
180
|
lambdaResponse.headers = {};
|
|
@@ -22,17 +22,17 @@ __export(useRedwoodTrustedDocuments_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useRedwoodTrustedDocuments_exports);
|
|
24
24
|
var import_plugin_persisted_operations = require("@graphql-yoga/plugin-persisted-operations");
|
|
25
|
-
const
|
|
25
|
+
const CEDAR__AUTH_GET_CURRENT_USER_QUERY = '{"query":"query __CEDAR__AUTH_GET_CURRENT_USER { cedar { currentUser } }"}';
|
|
26
26
|
const CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION = '{"query":"mutation { resyncMailRenderers }"}';
|
|
27
27
|
const CEDAR__STUDIO_TEMPLATE_MUTATION = '{"query":"mutation { resyncMailTemplate }"}';
|
|
28
|
-
const
|
|
28
|
+
const allowCedarAuthCurrentUserQuery = async (request) => {
|
|
29
29
|
const headers = request.headers;
|
|
30
30
|
const hasContentType = headers.get("content-type") === "application/json";
|
|
31
31
|
const hasAuthProvider = !!headers.get("auth-provider");
|
|
32
32
|
const hasAuthorization = !!headers.get("authorization");
|
|
33
33
|
const hasAllowedHeaders = hasContentType && hasAuthProvider && hasAuthorization;
|
|
34
34
|
const query = await request.text();
|
|
35
|
-
const hasAllowedQuery = query ===
|
|
35
|
+
const hasAllowedQuery = query === CEDAR__AUTH_GET_CURRENT_USER_QUERY;
|
|
36
36
|
return hasAllowedHeaders && hasAllowedQuery;
|
|
37
37
|
};
|
|
38
38
|
const allowCedarStudioResyncMailMutations = async (request) => {
|
|
@@ -70,7 +70,7 @@ const useRedwoodTrustedDocuments = (options) => {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
return
|
|
73
|
+
return allowCedarAuthCurrentUserQuery(request) || allowCedarStudioResyncMailMutations(request);
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGraphQLYoga.d.ts","sourceRoot":"","sources":["../src/createGraphQLYoga.ts"],"names":[],"mappings":"
|
|
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,7 +1,11 @@
|
|
|
1
1
|
import { useDisableIntrospection } from "@envelop/disable-introspection";
|
|
2
2
|
import { useFilterAllowedOperations } from "@envelop/filter-operation-type";
|
|
3
3
|
import { OperationTypeNode } from "graphql";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useReadinessCheck,
|
|
6
|
+
createYoga,
|
|
7
|
+
useExecutionCancellation
|
|
8
|
+
} from "graphql-yoga";
|
|
5
9
|
import { mapRwCorsOptionsToYoga } from "./cors.js";
|
|
6
10
|
import { makeDirectivesForPlugin } from "./directives/makeDirectives.js";
|
|
7
11
|
import { configureGraphiQLPlayground } from "./graphiql.js";
|
|
@@ -83,6 +87,7 @@ const createGraphQLYoga = async ({
|
|
|
83
87
|
const { useCedarRealtime } = await import("@cedarjs/realtime");
|
|
84
88
|
plugins.push(useCedarRealtime(realtime));
|
|
85
89
|
}
|
|
90
|
+
plugins.push(useExecutionCancellation());
|
|
86
91
|
const { disableIntrospection } = configureGraphQLIntrospection({
|
|
87
92
|
allowIntrospection
|
|
88
93
|
});
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class CedarGraphQLError extends GraphQLError {
|
|
3
3
|
constructor(message: string, extensions?: Record<string, any>, originalError?: Error & {
|
|
4
4
|
readonly extensions?: unknown;
|
|
5
5
|
});
|
|
6
6
|
}
|
|
7
|
-
|
|
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 {
|
|
8
12
|
constructor(message: string);
|
|
9
13
|
}
|
|
10
|
-
export declare class ValidationError extends
|
|
14
|
+
export declare class ValidationError extends CedarGraphQLError {
|
|
11
15
|
constructor(message: string);
|
|
12
16
|
}
|
|
13
|
-
export declare class AuthenticationError extends
|
|
17
|
+
export declare class AuthenticationError extends CedarGraphQLError {
|
|
14
18
|
constructor(message: string);
|
|
15
19
|
}
|
|
16
|
-
export declare class ForbiddenError extends
|
|
20
|
+
export declare class ForbiddenError extends CedarGraphQLError {
|
|
17
21
|
constructor(message: string);
|
|
18
22
|
}
|
|
19
|
-
export declare class PersistedQueryNotFoundError extends
|
|
23
|
+
export declare class PersistedQueryNotFoundError extends CedarGraphQLError {
|
|
20
24
|
constructor();
|
|
21
25
|
}
|
|
22
|
-
export declare class PersistedQueryNotSupportedError extends
|
|
26
|
+
export declare class PersistedQueryNotSupportedError extends CedarGraphQLError {
|
|
23
27
|
constructor();
|
|
24
28
|
}
|
|
25
|
-
export declare class UserInputError extends
|
|
29
|
+
export declare class UserInputError extends CedarGraphQLError {
|
|
26
30
|
constructor(message: string, properties?: Record<string, any>);
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,qBAAa,
|
|
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"}
|
package/dist/errors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLError } from "graphql";
|
|
2
|
-
class
|
|
2
|
+
class CedarGraphQLError extends GraphQLError {
|
|
3
3
|
constructor(message, extensions, originalError) {
|
|
4
4
|
super(message, {
|
|
5
5
|
extensions: {
|
|
@@ -11,37 +11,38 @@ class RedwoodGraphQLError extends GraphQLError {
|
|
|
11
11
|
Object.setPrototypeOf(this, GraphQLError.prototype);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const RedwoodGraphQLError = CedarGraphQLError;
|
|
15
|
+
class SyntaxError extends CedarGraphQLError {
|
|
15
16
|
constructor(message) {
|
|
16
17
|
super(message, { code: "GRAPHQL_PARSE_FAILED" });
|
|
17
18
|
Object.setPrototypeOf(this, SyntaxError.prototype);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
class ValidationError extends
|
|
21
|
+
class ValidationError extends CedarGraphQLError {
|
|
21
22
|
constructor(message) {
|
|
22
23
|
super(message, { code: "GRAPHQL_VALIDATION_FAILED" });
|
|
23
24
|
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
class AuthenticationError extends
|
|
27
|
+
class AuthenticationError extends CedarGraphQLError {
|
|
27
28
|
constructor(message) {
|
|
28
29
|
super(message, { code: "UNAUTHENTICATED" });
|
|
29
30
|
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
class ForbiddenError extends
|
|
33
|
+
class ForbiddenError extends CedarGraphQLError {
|
|
33
34
|
constructor(message) {
|
|
34
35
|
super(message, { code: "FORBIDDEN" });
|
|
35
36
|
Object.setPrototypeOf(this, ForbiddenError.prototype);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
class PersistedQueryNotFoundError extends
|
|
39
|
+
class PersistedQueryNotFoundError extends CedarGraphQLError {
|
|
39
40
|
constructor() {
|
|
40
41
|
super("PersistedQueryNotFound", { code: "PERSISTED_QUERY_NOT_FOUND" });
|
|
41
42
|
Object.setPrototypeOf(this, PersistedQueryNotFoundError.prototype);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
class PersistedQueryNotSupportedError extends
|
|
45
|
+
class PersistedQueryNotSupportedError extends CedarGraphQLError {
|
|
45
46
|
constructor() {
|
|
46
47
|
super("PersistedQueryNotSupported", {
|
|
47
48
|
code: "PERSISTED_QUERY_NOT_SUPPORTED"
|
|
@@ -49,7 +50,7 @@ class PersistedQueryNotSupportedError extends RedwoodGraphQLError {
|
|
|
49
50
|
Object.setPrototypeOf(this, PersistedQueryNotSupportedError.prototype);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
class UserInputError extends
|
|
53
|
+
class UserInputError extends CedarGraphQLError {
|
|
53
54
|
constructor(message, properties) {
|
|
54
55
|
super(message, { code: "BAD_USER_INPUT", properties });
|
|
55
56
|
Object.setPrototypeOf(this, UserInputError.prototype);
|
|
@@ -57,6 +58,7 @@ class UserInputError extends RedwoodGraphQLError {
|
|
|
57
58
|
}
|
|
58
59
|
export {
|
|
59
60
|
AuthenticationError,
|
|
61
|
+
CedarGraphQLError,
|
|
60
62
|
ForbiddenError,
|
|
61
63
|
PersistedQueryNotFoundError,
|
|
62
64
|
PersistedQueryNotSupportedError,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/functions/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAQnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AA4CxD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,iUAuBlC,qBAAqB,MA+
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/functions/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAQnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AA4CxD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,iUAuBlC,qBAAqB,MA+IpB,OAAO,oBAAoB,EAC3B,SAAS,aAAa,KACrB,OAAO,CAAC,GAAG,CAcf,CAAA"}
|
|
@@ -126,15 +126,22 @@ const createGraphQLHandler = ({
|
|
|
126
126
|
isBase64Encoded: false
|
|
127
127
|
};
|
|
128
128
|
} catch (e) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
130
|
+
lambdaResponse = {
|
|
131
|
+
body: JSON.stringify({ error: "Client disconnected" }),
|
|
132
|
+
statusCode: 499
|
|
133
|
+
};
|
|
134
|
+
} else {
|
|
135
|
+
logger.error(e);
|
|
136
|
+
if (onException) {
|
|
137
|
+
onException();
|
|
138
|
+
}
|
|
139
|
+
lambdaResponse = {
|
|
140
|
+
body: JSON.stringify({ error: "GraphQL execution failed" }),
|
|
141
|
+
statusCode: 200
|
|
142
|
+
// should be 500
|
|
143
|
+
};
|
|
132
144
|
}
|
|
133
|
-
lambdaResponse = {
|
|
134
|
-
body: JSON.stringify({ error: "GraphQL execution failed" }),
|
|
135
|
-
statusCode: 200
|
|
136
|
-
// should be 500
|
|
137
|
-
};
|
|
138
145
|
}
|
|
139
146
|
if (!lambdaResponse.headers) {
|
|
140
147
|
lambdaResponse.headers = {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { usePersistedOperations } from "@graphql-yoga/plugin-persisted-operations";
|
|
2
|
-
const
|
|
2
|
+
const CEDAR__AUTH_GET_CURRENT_USER_QUERY = '{"query":"query __CEDAR__AUTH_GET_CURRENT_USER { cedar { currentUser } }"}';
|
|
3
3
|
const CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION = '{"query":"mutation { resyncMailRenderers }"}';
|
|
4
4
|
const CEDAR__STUDIO_TEMPLATE_MUTATION = '{"query":"mutation { resyncMailTemplate }"}';
|
|
5
|
-
const
|
|
5
|
+
const allowCedarAuthCurrentUserQuery = async (request) => {
|
|
6
6
|
const headers = request.headers;
|
|
7
7
|
const hasContentType = headers.get("content-type") === "application/json";
|
|
8
8
|
const hasAuthProvider = !!headers.get("auth-provider");
|
|
9
9
|
const hasAuthorization = !!headers.get("authorization");
|
|
10
10
|
const hasAllowedHeaders = hasContentType && hasAuthProvider && hasAuthorization;
|
|
11
11
|
const query = await request.text();
|
|
12
|
-
const hasAllowedQuery = query ===
|
|
12
|
+
const hasAllowedQuery = query === CEDAR__AUTH_GET_CURRENT_USER_QUERY;
|
|
13
13
|
return hasAllowedHeaders && hasAllowedQuery;
|
|
14
14
|
};
|
|
15
15
|
const allowCedarStudioResyncMailMutations = async (request) => {
|
|
@@ -47,7 +47,7 @@ const useRedwoodTrustedDocuments = (options) => {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return allowCedarAuthCurrentUserQuery(request) || allowCedarStudioResyncMailMutations(request);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/graphql-server",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1-next.258",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
31
31
|
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
32
32
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
|
|
33
|
-
"check:attw": "yarn
|
|
33
|
+
"check:attw": "yarn cedar-fwtools-attw",
|
|
34
34
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
35
35
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
36
36
|
"test": "yarn vitest run src/",
|
|
@@ -48,34 +48,34 @@
|
|
|
48
48
|
"@graphql-tools/merge": "9.1.9",
|
|
49
49
|
"@graphql-tools/schema": "10.0.33",
|
|
50
50
|
"@graphql-tools/utils": "10.11.0",
|
|
51
|
-
"@graphql-yoga/plugin-persisted-operations": "3.21.
|
|
52
|
-
"@opentelemetry/api": "1.9.
|
|
51
|
+
"@graphql-yoga/plugin-persisted-operations": "3.21.2",
|
|
52
|
+
"@opentelemetry/api": "1.9.1",
|
|
53
53
|
"cookie": "1.1.1",
|
|
54
54
|
"graphql": "16.13.2",
|
|
55
55
|
"graphql-scalars": "1.25.0",
|
|
56
56
|
"graphql-tag": "2.12.6",
|
|
57
|
-
"graphql-yoga": "5.21.
|
|
57
|
+
"graphql-yoga": "5.21.2",
|
|
58
58
|
"lodash": "4.18.1",
|
|
59
59
|
"uuid": "11.1.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@babel/cli": "7.
|
|
62
|
+
"@babel/cli": "7.29.7",
|
|
63
63
|
"@babel/core": "^7.26.10",
|
|
64
64
|
"@cedarjs/framework-tools": "4.2.0",
|
|
65
65
|
"@cedarjs/project-config": "4.2.0",
|
|
66
66
|
"@cedarjs/realtime": "4.2.0",
|
|
67
67
|
"@envelop/types": "5.2.1",
|
|
68
|
-
"@types/aws-lambda": "8.10.
|
|
68
|
+
"@types/aws-lambda": "8.10.162",
|
|
69
69
|
"@types/jsonwebtoken": "9.0.10",
|
|
70
70
|
"@types/lodash": "4.17.24",
|
|
71
71
|
"@whatwg-node/fetch": "0.10.13",
|
|
72
72
|
"@whatwg-node/promise-helpers": "^1.3.0",
|
|
73
73
|
"concurrently": "9.2.1",
|
|
74
74
|
"jsonwebtoken": "9.0.3",
|
|
75
|
-
"publint": "0.3.
|
|
76
|
-
"tsx": "4.
|
|
75
|
+
"publint": "0.3.21",
|
|
76
|
+
"tsx": "4.22.4",
|
|
77
77
|
"typescript": "5.9.3",
|
|
78
|
-
"vitest": "3.2.
|
|
78
|
+
"vitest": "3.2.6"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=24"
|