@cedarjs/graphql-server 9.0.0-canary.1784 → 9.0.0-canary.3124
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/createGraphQLYoga.d.ts +31 -5
- package/dist/createGraphQLYoga.d.ts.map +1 -1
- package/dist/createGraphQLYoga.js +43 -22
- package/dist/directives/makeDirectives.d.ts +2 -2
- package/dist/directives/makeDirectives.d.ts.map +1 -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 +1 -1
- package/dist/functions/graphql.d.ts.map +1 -1
- package/dist/functions/graphql.js +60 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/makeMergedSchema.d.ts +6 -6
- package/dist/makeMergedSchema.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +8 -8
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +20 -16
- package/dist/plugins/useCedarAuthContext.d.ts +8 -0
- package/dist/plugins/useCedarAuthContext.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodAuthContext.js → useCedarAuthContext.js} +5 -12
- package/dist/{cjs/plugins/useRedwoodError.d.ts → plugins/useCedarError.d.ts} +4 -4
- package/dist/plugins/useCedarError.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodError.js → useCedarError.js} +5 -5
- package/dist/plugins/{useRedwoodGlobalContextSetter.d.ts → useCedarGlobalContextSetter.d.ts} +2 -2
- package/dist/plugins/useCedarGlobalContextSetter.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodGlobalContextSetter.js → useCedarGlobalContextSetter.js} +2 -2
- package/dist/plugins/{useRedwoodLogger.d.ts → useCedarLogger.d.ts} +2 -2
- package/dist/plugins/useCedarLogger.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodLogger.js → useCedarLogger.js} +11 -4
- package/dist/plugins/{useRedwoodOpenTelemetry.d.ts → useCedarOpenTelemetry.d.ts} +3 -3
- package/dist/plugins/useCedarOpenTelemetry.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodOpenTelemetry.js → useCedarOpenTelemetry.js} +3 -3
- package/dist/{cjs/plugins/useRedwoodPopulateContext.d.ts → plugins/useCedarPopulateContext.d.ts} +2 -2
- package/dist/plugins/useCedarPopulateContext.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodPopulateContext.js → useCedarPopulateContext.js} +2 -2
- package/dist/{cjs/plugins/useRedwoodTrustedDocuments.d.ts → plugins/useCedarTrustedDocuments.d.ts} +5 -3
- package/dist/plugins/useCedarTrustedDocuments.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodTrustedDocuments.js → useCedarTrustedDocuments.js} +20 -13
- package/dist/plugins/useRedwoodDirective.d.ts +9 -3
- package/dist/plugins/useRedwoodDirective.d.ts.map +1 -1
- package/dist/plugins/useRedwoodDirective.js +4 -2
- package/dist/serverAuthState.d.ts +25 -0
- package/dist/serverAuthState.d.ts.map +1 -0
- package/dist/serverAuthState.js +10 -0
- package/dist/subscriptions/makeSubscriptions.d.ts +3 -3
- package/dist/subscriptions/makeSubscriptions.d.ts.map +1 -1
- package/dist/types.d.ts +27 -14
- package/dist/types.d.ts.map +1 -1
- package/package.json +30 -37
- package/LICENSE +0 -21
- package/dist/cjs/cors.d.ts +0 -10
- package/dist/cjs/cors.d.ts.map +0 -1
- package/dist/cjs/cors.js +0 -70
- package/dist/cjs/createGraphQLYoga.d.ts +0 -6
- package/dist/cjs/createGraphQLYoga.d.ts.map +0 -1
- package/dist/cjs/createGraphQLYoga.js +0 -178
- package/dist/cjs/directives/makeDirectives.d.ts +0 -8
- package/dist/cjs/directives/makeDirectives.d.ts.map +0 -1
- package/dist/cjs/directives/makeDirectives.js +0 -89
- package/dist/cjs/errors.d.ts +0 -28
- package/dist/cjs/errors.d.ts.map +0 -1
- package/dist/cjs/errors.js +0 -98
- package/dist/cjs/functions/graphql.d.ts +0 -15
- package/dist/cjs/functions/graphql.d.ts.map +0 -1
- package/dist/cjs/functions/graphql.js +0 -141
- package/dist/cjs/functions/useRequireAuth.d.ts +0 -12
- package/dist/cjs/functions/useRequireAuth.d.ts.map +0 -1
- package/dist/cjs/functions/useRequireAuth.js +0 -70
- package/dist/cjs/global.api-auto-imports.d.ts +0 -7
- package/dist/cjs/global.api-auto-imports.d.ts.map +0 -1
- package/dist/cjs/global.api-auto-imports.js +0 -1
- package/dist/cjs/globalContext.d.ts +0 -25
- package/dist/cjs/globalContext.d.ts.map +0 -1
- package/dist/cjs/globalContext.js +0 -55
- package/dist/cjs/globalContextStore.d.ts +0 -9
- package/dist/cjs/globalContextStore.d.ts.map +0 -1
- package/dist/cjs/globalContextStore.js +0 -35
- package/dist/cjs/graphiql.d.ts +0 -8
- package/dist/cjs/graphiql.d.ts.map +0 -1
- package/dist/cjs/graphiql.js +0 -45
- package/dist/cjs/index.d.ts +0 -14
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -75
- package/dist/cjs/introspection.d.ts +0 -7
- package/dist/cjs/introspection.d.ts.map +0 -1
- package/dist/cjs/introspection.js +0 -36
- package/dist/cjs/makeMergedSchema.d.ts +0 -17
- package/dist/cjs/makeMergedSchema.d.ts.map +0 -1
- package/dist/cjs/makeMergedSchema.js +0 -283
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/plugins/index.d.ts +0 -10
- package/dist/cjs/plugins/index.d.ts.map +0 -1
- package/dist/cjs/plugins/index.js +0 -52
- package/dist/cjs/plugins/useArmor.d.ts +0 -4
- package/dist/cjs/plugins/useArmor.d.ts.map +0 -1
- package/dist/cjs/plugins/useArmor.js +0 -69
- package/dist/cjs/plugins/useRedwoodAuthContext.d.ts +0 -9
- package/dist/cjs/plugins/useRedwoodAuthContext.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodAuthContext.js +0 -60
- package/dist/cjs/plugins/useRedwoodDirective.d.ts +0 -83
- package/dist/cjs/plugins/useRedwoodDirective.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodDirective.js +0 -166
- package/dist/cjs/plugins/useRedwoodError.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodError.js +0 -62
- package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts +0 -9
- package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodGlobalContextSetter.js +0 -35
- package/dist/cjs/plugins/useRedwoodLogger.d.ts +0 -115
- package/dist/cjs/plugins/useRedwoodLogger.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodLogger.js +0 -149
- package/dist/cjs/plugins/useRedwoodOpenTelemetry.d.ts +0 -22
- package/dist/cjs/plugins/useRedwoodOpenTelemetry.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodOpenTelemetry.js +0 -156
- package/dist/cjs/plugins/useRedwoodPopulateContext.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodPopulateContext.js +0 -35
- package/dist/cjs/plugins/useRedwoodTrustedDocuments.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodTrustedDocuments.js +0 -80
- package/dist/cjs/rootSchema.d.ts +0 -25
- package/dist/cjs/rootSchema.d.ts.map +0 -1
- package/dist/cjs/rootSchema.js +0 -108
- package/dist/cjs/subscriptions/makeSubscriptions.d.ts +0 -18
- package/dist/cjs/subscriptions/makeSubscriptions.d.ts.map +0 -1
- package/dist/cjs/subscriptions/makeSubscriptions.js +0 -40
- package/dist/cjs/types.d.ts +0 -227
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/cjs/types.js +0 -16
- package/dist/plugins/useRedwoodAuthContext.d.ts +0 -9
- package/dist/plugins/useRedwoodAuthContext.d.ts.map +0 -1
- package/dist/plugins/useRedwoodError.d.ts +0 -20
- package/dist/plugins/useRedwoodError.d.ts.map +0 -1
- package/dist/plugins/useRedwoodGlobalContextSetter.d.ts.map +0 -1
- package/dist/plugins/useRedwoodLogger.d.ts.map +0 -1
- package/dist/plugins/useRedwoodOpenTelemetry.d.ts.map +0 -1
- package/dist/plugins/useRedwoodPopulateContext.d.ts +0 -9
- package/dist/plugins/useRedwoodPopulateContext.d.ts.map +0 -1
- package/dist/plugins/useRedwoodTrustedDocuments.d.ts +0 -23
- package/dist/plugins/useRedwoodTrustedDocuments.d.ts.map +0 -1
|
@@ -2,13 +2,13 @@ import type { Plugin } from 'graphql-yoga';
|
|
|
2
2
|
import type { Logger } from '@cedarjs/api/logger';
|
|
3
3
|
import type { CedarGraphQLContext } from '../types.js';
|
|
4
4
|
/**
|
|
5
|
-
* Converts
|
|
5
|
+
* Converts CedarErrors to GraphQLErrors
|
|
6
6
|
*
|
|
7
7
|
* This is a workaround for the fact that graphql-yoga doesn't support custom error types.
|
|
8
8
|
*
|
|
9
9
|
* Yoga automatically masks unexpected errors and prevents leaking sensitive information to clients.
|
|
10
10
|
*
|
|
11
|
-
* Since
|
|
11
|
+
* Since CedarErrors (such as ServiceValidation errors) are expected,
|
|
12
12
|
* we need to convert them to GraphQLErrors so that they are not masked.
|
|
13
13
|
*
|
|
14
14
|
* See: https://the-guild.dev/graphql/yoga-server/docs/features/error-masking
|
|
@@ -16,5 +16,5 @@ import type { CedarGraphQLContext } from '../types.js';
|
|
|
16
16
|
* @param logger
|
|
17
17
|
* @returns ExecutionResult
|
|
18
18
|
*/
|
|
19
|
-
export declare const
|
|
20
|
-
//# sourceMappingURL=
|
|
19
|
+
export declare const useCedarError: (logger: Logger) => Plugin<CedarGraphQLContext>;
|
|
20
|
+
//# sourceMappingURL=useCedarError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCedarError.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAO1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,KAAG,MAAM,CAAC,mBAAmB,CAsCxE,CAAA"}
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
handleStreamOrSingleExecutionResult,
|
|
3
3
|
createGraphQLError
|
|
4
4
|
} from "graphql-yoga";
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
5
|
+
import { CedarError } from "@cedarjs/api";
|
|
6
|
+
const useCedarError = (logger) => {
|
|
7
7
|
return {
|
|
8
8
|
async onExecute() {
|
|
9
9
|
return {
|
|
@@ -12,10 +12,10 @@ const useRedwoodError = (logger) => {
|
|
|
12
12
|
payload,
|
|
13
13
|
({ result, setResult }) => {
|
|
14
14
|
const errors = result.errors?.map((error) => {
|
|
15
|
-
if (error.originalError instanceof
|
|
15
|
+
if (error.originalError instanceof CedarError) {
|
|
16
16
|
logger.debug(
|
|
17
17
|
{ custom: { name: error.originalError.name } },
|
|
18
|
-
"Converting
|
|
18
|
+
"Converting CedarError to GraphQLError"
|
|
19
19
|
);
|
|
20
20
|
return createGraphQLError(error.message, {
|
|
21
21
|
extensions: error.extensions
|
|
@@ -37,5 +37,5 @@ const useRedwoodError = (logger) => {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
useCedarError
|
|
41
41
|
};
|
package/dist/plugins/{useRedwoodGlobalContextSetter.d.ts → useCedarGlobalContextSetter.d.ts}
RENAMED
|
@@ -5,5 +5,5 @@ import type { CedarGraphQLContext } from '../types.js';
|
|
|
5
5
|
* the CedarJS global context which can be imported with:
|
|
6
6
|
* `import { context } from '@cedarjs/context'`
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
export declare const useCedarGlobalContextSetter: () => Plugin<CedarGraphQLContext>;
|
|
9
|
+
//# sourceMappingURL=useCedarGlobalContextSetter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCedarGlobalContextSetter.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarGlobalContextSetter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAI1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAAO,MAAM,CAAC,mBAAmB,CAMvE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setContext } from "@cedarjs/context";
|
|
2
|
-
const
|
|
2
|
+
const useCedarGlobalContextSetter = () => ({
|
|
3
3
|
onContextBuilding() {
|
|
4
4
|
return ({ context }) => {
|
|
5
5
|
setContext(context);
|
|
@@ -7,5 +7,5 @@ const useRedwoodGlobalContextSetter = () => ({
|
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
useCedarGlobalContextSetter
|
|
11
11
|
};
|
|
@@ -110,6 +110,6 @@ export type LoggerConfig = {
|
|
|
110
110
|
* @see https://www.envelop.dev/docs/plugins/lifecycle
|
|
111
111
|
* @returns
|
|
112
112
|
*/
|
|
113
|
-
export declare const
|
|
113
|
+
export declare const useCedarLogger: (loggerConfig: LoggerConfig) => Plugin<CedarGraphQLContext>;
|
|
114
114
|
export {};
|
|
115
|
-
//# sourceMappingURL=
|
|
115
|
+
//# sourceMappingURL=useCedarLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCedarLogger.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarLogger.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAI1C,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAGlE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD;;;;;;;;;;;;;GAaG;AACH,KAAK,oBAAoB,GAAG;IAC1B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,EAAE,eAAe,GAAG,MAAM,CAAA;IAEhC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC7B,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,oBAAoB,CAAA;CAC/B,CAAA;AA+DD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GACzB,cAAc,YAAY,KACzB,MAAM,CAAC,mBAAmB,CAgH5B,CAAA"}
|
|
@@ -39,7 +39,7 @@ const logResult = (loggerConfig, envelopLogger, operationName) => ({ result }) =
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
const
|
|
42
|
+
const useCedarLogger = (loggerConfig) => {
|
|
43
43
|
const logger = loggerConfig.logger;
|
|
44
44
|
const level = loggerConfig.options?.level || logger.level || "warn";
|
|
45
45
|
const childLogger = logger.child({
|
|
@@ -99,10 +99,17 @@ const useRedwoodLogger = (loggerConfig) => {
|
|
|
99
99
|
options["query"] = args.variableValues;
|
|
100
100
|
}
|
|
101
101
|
if (includeRequestId) {
|
|
102
|
-
options["requestId"] =
|
|
102
|
+
options["requestId"] = // x-request-id is a widely adopted (though informal) HTTP header for
|
|
103
|
+
// distributed tracing. Load balancers, API gateways, and clients set
|
|
104
|
+
// it on each request so that all log lines for a single request can
|
|
105
|
+
// be correlated across services. We check it first so that an
|
|
106
|
+
// externally assigned ID is preserved end-to-end; if it is absent we
|
|
107
|
+
// fall back to the Lambda/API-Gateway request ID, and finally
|
|
108
|
+
// generate a UUID so there is always something to correlate on.
|
|
109
|
+
args.contextValue.request?.headers.get("x-request-id") || args.contextValue.requestContext?.awsRequestId || args.contextValue.event?.requestContext?.requestId || uuidv4();
|
|
103
110
|
}
|
|
104
111
|
if (includeUserAgent) {
|
|
105
|
-
options["userAgent"] = args.contextValue.event?.headers["user-agent"];
|
|
112
|
+
options["userAgent"] = args.contextValue.request?.headers.get("user-agent") || args.contextValue.event?.headers["user-agent"];
|
|
106
113
|
}
|
|
107
114
|
const envelopLogger = childLogger.child({
|
|
108
115
|
...options
|
|
@@ -121,5 +128,5 @@ const useRedwoodLogger = (loggerConfig) => {
|
|
|
121
128
|
};
|
|
122
129
|
};
|
|
123
130
|
export {
|
|
124
|
-
|
|
131
|
+
useCedarLogger
|
|
125
132
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from '@envelop/core';
|
|
2
2
|
import * as opentelemetry from '@opentelemetry/api';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CedarOpenTelemetryConfig } from '../types.js';
|
|
4
4
|
export declare enum AttributeName {
|
|
5
5
|
EXECUTION_ERROR = "graphql.execute.error",
|
|
6
6
|
EXECUTION_RESULT = "graphql.execute.result",
|
|
@@ -17,6 +17,6 @@ declare const tracingSpanSymbol = "OPEN_TELEMETRY_GRAPHQL";
|
|
|
17
17
|
type PluginContext = {
|
|
18
18
|
[tracingSpanSymbol]: opentelemetry.Span;
|
|
19
19
|
};
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const useCedarOpenTelemetry: (options: CedarOpenTelemetryConfig) => Plugin<PluginContext>;
|
|
21
21
|
export {};
|
|
22
|
-
//# sourceMappingURL=
|
|
22
|
+
//# sourceMappingURL=useCedarOpenTelemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCedarOpenTelemetry.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarOpenTelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,eAAe,CAAA;AAKhE,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAGnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAE3D,oBAAY,aAAa;IACvB,eAAe,0BAA0B;IACzC,gBAAgB,2BAA2B;IAC3C,kBAAkB,+BAA+B;IACjD,mBAAmB,+BAA+B;IAClD,kBAAkB,8BAA8B;IAChD,oBAAoB,gCAAgC;IACpD,aAAa,0BAA0B;IACvC,wBAAwB,kCAAkC;IAC1D,4BAA4B,6BAA6B;IACzD,mBAAmB,8BAA8B;CAClD;AAGD,QAAA,MAAM,iBAAiB,2BAA2B,CAAA;AAElD,KAAK,aAAa,GAAG;IACnB,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC,IAAI,CAAA;CACxC,CAAA;AAED,eAAO,MAAM,qBAAqB,GAChC,SAAS,wBAAwB,KAChC,MAAM,CAAC,aAAa,CAgHtB,CAAA"}
|
|
@@ -17,7 +17,7 @@ var AttributeName = /* @__PURE__ */ ((AttributeName2) => {
|
|
|
17
17
|
return AttributeName2;
|
|
18
18
|
})(AttributeName || {});
|
|
19
19
|
const tracingSpanSymbol = "OPEN_TELEMETRY_GRAPHQL";
|
|
20
|
-
const
|
|
20
|
+
const useCedarOpenTelemetry = (options) => {
|
|
21
21
|
const spanKind = SpanKind.SERVER;
|
|
22
22
|
const spanAdditionalAttributes = {};
|
|
23
23
|
const tracer = opentelemetry.trace.getTracer("redwoodjs");
|
|
@@ -85,7 +85,7 @@ const useRedwoodOpenTelemetry = (options) => {
|
|
|
85
85
|
if (isAsyncIterable(result)) {
|
|
86
86
|
executionSpan.end();
|
|
87
87
|
console.warn(
|
|
88
|
-
`Plugin "
|
|
88
|
+
`Plugin "CedarOpenTelemetry" encountered an AsyncIterator which is not supported yet, so tracing data is not available for the operation.`
|
|
89
89
|
);
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
@@ -117,5 +117,5 @@ const useRedwoodOpenTelemetry = (options) => {
|
|
|
117
117
|
};
|
|
118
118
|
export {
|
|
119
119
|
AttributeName,
|
|
120
|
-
|
|
120
|
+
useCedarOpenTelemetry
|
|
121
121
|
};
|
package/dist/{cjs/plugins/useRedwoodPopulateContext.d.ts → plugins/useCedarPopulateContext.d.ts}
RENAMED
|
@@ -5,5 +5,5 @@ import type { CedarGraphQLContext, GraphQLHandlerOptions } from '../types.js';
|
|
|
5
5
|
* by populating it with the results of a custom function
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
export declare const useCedarPopulateContext: (populateContextBuilder: NonNullable<GraphQLHandlerOptions["context"]>) => Plugin<CedarGraphQLContext>;
|
|
9
|
+
//# sourceMappingURL=useCedarPopulateContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCedarPopulateContext.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarPopulateContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE7E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,wBAAwB,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,KACpE,MAAM,CAAC,mBAAmB,CAW5B,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const useCedarPopulateContext = (populateContextBuilder) => {
|
|
2
2
|
return {
|
|
3
3
|
async onContextBuilding({ context, extendContext }) {
|
|
4
4
|
const populateContext = typeof populateContextBuilder === "function" ? await populateContextBuilder({ context }) : populateContextBuilder;
|
|
@@ -7,5 +7,5 @@ const useRedwoodPopulateContext = (populateContextBuilder) => {
|
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
useCedarPopulateContext
|
|
11
11
|
};
|
package/dist/{cjs/plugins/useRedwoodTrustedDocuments.d.ts → plugins/useCedarTrustedDocuments.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { UsePersistedOperationsOptions } from '@graphql-yoga/plugin-persisted-operations';
|
|
2
2
|
import type { Plugin } from 'graphql-yoga';
|
|
3
3
|
import type { CedarGraphQLContext } from '../types.js';
|
|
4
|
-
export type
|
|
4
|
+
export type CedarTrustedDocumentOptions = Omit<UsePersistedOperationsOptions, 'getPersistedOperation'> & {
|
|
5
5
|
/**
|
|
6
6
|
* Whether to disable the plugin
|
|
7
7
|
* @default false
|
|
@@ -19,5 +19,7 @@ export type RedwoodTrustedDocumentOptions = Omit<UsePersistedOperationsOptions,
|
|
|
19
19
|
disabled?: false;
|
|
20
20
|
store: Readonly<Record<string, string>>;
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/** @deprecated Use `CedarTrustedDocumentOptions` instead. */
|
|
23
|
+
export type RedwoodTrustedDocumentOptions = CedarTrustedDocumentOptions;
|
|
24
|
+
export declare const useCedarTrustedDocuments: (options: CedarTrustedDocumentOptions) => Plugin<CedarGraphQLContext>;
|
|
25
|
+
//# sourceMappingURL=useCedarTrustedDocuments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCedarTrustedDocuments.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarTrustedDocuments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAA;AAC9F,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,6BAA6B,EAC7B,uBAAuB,CACxB,GAAG;IACF;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACzC,GAAG,CACE;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAChE,CAAA;AAEH,6DAA6D;AAC7D,MAAM,MAAM,6BAA6B,GAAG,2BAA2B,CAAA;AAuEvE,eAAO,MAAM,wBAAwB,GACnC,SAAS,2BAA2B,KACnC,MAAM,CAAC,mBAAmB,CAyD5B,CAAA"}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { usePersistedOperations } from "@graphql-yoga/plugin-persisted-operations";
|
|
2
|
-
const
|
|
3
|
-
const CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION =
|
|
4
|
-
const CEDAR__STUDIO_TEMPLATE_MUTATION =
|
|
5
|
-
const
|
|
2
|
+
const CEDAR__AUTH_GET_CURRENT_USER_QUERY = "query __CEDAR__AUTH_GET_CURRENT_USER { cedar { currentUser } }";
|
|
3
|
+
const CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION = "mutation { resyncMailRenderers }";
|
|
4
|
+
const CEDAR__STUDIO_TEMPLATE_MUTATION = "mutation { resyncMailTemplate }";
|
|
5
|
+
const allowCedarAuthCurrentUserQuery = (request, params) => {
|
|
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
|
-
const
|
|
12
|
-
const hasAllowedQuery = query === REDWOOD__AUTH_GET_CURRENT_USER_QUERY;
|
|
11
|
+
const hasAllowedQuery = params?.query === CEDAR__AUTH_GET_CURRENT_USER_QUERY;
|
|
13
12
|
return hasAllowedHeaders && hasAllowedQuery;
|
|
14
13
|
};
|
|
15
|
-
const allowCedarStudioResyncMailMutations =
|
|
14
|
+
const allowCedarStudioResyncMailMutations = (request, params) => {
|
|
16
15
|
const isLocalDevelopment = process.env.NODE_ENV === "development";
|
|
17
16
|
if (!isLocalDevelopment) {
|
|
18
17
|
return false;
|
|
19
18
|
}
|
|
20
19
|
const headers = request.headers;
|
|
21
20
|
const hasContentType = headers.get("content-type") === "application/json";
|
|
22
|
-
const
|
|
23
|
-
const isAllowedQuery = query === CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION || query === CEDAR__STUDIO_TEMPLATE_MUTATION;
|
|
21
|
+
const isAllowedQuery = params?.query === CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION || params?.query === CEDAR__STUDIO_TEMPLATE_MUTATION;
|
|
24
22
|
return hasContentType && isAllowedQuery;
|
|
25
23
|
};
|
|
26
|
-
const
|
|
27
|
-
|
|
24
|
+
const useCedarTrustedDocuments = (options) => {
|
|
25
|
+
const paramsByRequest = /* @__PURE__ */ new WeakMap();
|
|
26
|
+
const persistedOperations = usePersistedOperations({
|
|
28
27
|
...options,
|
|
29
28
|
customErrors: {
|
|
30
29
|
persistedQueryOnly: "Use Trusted Only!",
|
|
@@ -47,10 +46,18 @@ const useRedwoodTrustedDocuments = (options) => {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
const params = paramsByRequest.get(request);
|
|
50
|
+
return allowCedarAuthCurrentUserQuery(request, params) || allowCedarStudioResyncMailMutations(request, params);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
+
return {
|
|
54
|
+
...persistedOperations,
|
|
55
|
+
onParams(payload) {
|
|
56
|
+
paramsByRequest.set(payload.request, payload.params);
|
|
57
|
+
return persistedOperations.onParams?.(payload);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
53
60
|
};
|
|
54
61
|
export {
|
|
55
|
-
|
|
62
|
+
useCedarTrustedDocuments
|
|
56
63
|
};
|
|
@@ -54,7 +54,9 @@ export declare enum DirectiveType {
|
|
|
54
54
|
VALIDATOR = "VALIDATOR_DIRECTIVE",
|
|
55
55
|
TRANSFORMER = "TRANSFORMER_DIRECTIVE"
|
|
56
56
|
}
|
|
57
|
-
export type
|
|
57
|
+
export type CedarDirective = ValidatorDirective | TransformerDirective;
|
|
58
|
+
/** @deprecated Use `CedarDirective` instead. */
|
|
59
|
+
export type RedwoodDirective = CedarDirective;
|
|
58
60
|
export interface ValidatorDirective extends ValidatorDirectiveOptions {
|
|
59
61
|
schema: DocumentNode;
|
|
60
62
|
}
|
|
@@ -75,9 +77,13 @@ export type DirectivePluginOptions = ValidatorDirectiveOptions | TransformerDire
|
|
|
75
77
|
export declare function hasDirective(info: GraphQLResolveInfo): boolean;
|
|
76
78
|
export declare function getDirectiveByName(fieldConfig: GraphQLFieldConfig<any, any, any>, directiveName: string): null | DirectiveNode;
|
|
77
79
|
export declare function isPromise(value: any): value is Promise<unknown>;
|
|
78
|
-
export type
|
|
80
|
+
export type UseCedarDirectiveReturn = Plugin<{
|
|
79
81
|
onResolvedValue: ValidatorDirectiveFunc | TransformerDirectiveFunc;
|
|
80
82
|
}>;
|
|
81
|
-
|
|
83
|
+
/** @deprecated Use `UseCedarDirectiveReturn` instead. */
|
|
84
|
+
export type useRedwoodDirectiveReturn = UseCedarDirectiveReturn;
|
|
85
|
+
export declare const useCedarDirective: (options: DirectivePluginOptions) => UseCedarDirectiveReturn;
|
|
86
|
+
/** @deprecated Use `useCedarDirective` instead. */
|
|
87
|
+
export declare const useRedwoodDirective: (options: DirectivePluginOptions) => UseCedarDirectiveReturn;
|
|
82
88
|
export {};
|
|
83
89
|
//# sourceMappingURL=useRedwoodDirective.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedwoodDirective.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodDirective.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAElB,kBAAkB,EAEnB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,MAAM,WAAW,eAAe,CAC9B,SAAS,GAAG,GAAG,EACf,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAEnC,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,EAAE,aAAa,CAAA;IACtB,IAAI,EAAE,kBAAkB,CAAA;IACxB,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,aAAa,EAAE,aAAa,CAAA;IAC5B,aAAa,EAAE,SAAS,CAAA;CACzB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,MAAM,YAAY,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CAC1E,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,8CAA8C;AACrF,eAAe,CAChB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sBAAsB,CAAC,cAAc,GAA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AE,aAAa,CAAC,SAAS,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,UAAU,2BAA2B;IACnC,eAAe,EAAE,wBAAwB,CAAA;IACzC,IAAI,EAAE,aAAa,CAAC,WAAW,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,sBAAsB,GAChC,yBAAyB,GAAG,2BAA2B,CAAA;AAEzD,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAa9D;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9C,aAAa,EAAE,MAAM,GACpB,IAAI,GAAG,aAAa,CAKtB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAE/D;AA8GD,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC;IAC3C,eAAe,EAAE,sBAAsB,GAAG,wBAAwB,CAAA;CACnE,CAAC,CAAA;AAEF,yDAAyD;AACzD,MAAM,MAAM,yBAAyB,GAAG,uBAAuB,CAAA;AAE/D,eAAO,MAAM,iBAAiB,GAC5B,SAAS,sBAAsB,KAC9B,uBAwBF,CAAA;AAED,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,YA5BrB,sBAAsB,KAC9B,uBA2BiD,CAAA"}
|
|
@@ -107,8 +107,8 @@ function wrapAffectedResolvers(schema, options) {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
const wasDirectiveApplied = Symbol.for(`useRedwoodDirective.${options.name}}`);
|
|
110
|
+
const useCedarDirective = (options) => {
|
|
111
|
+
const wasDirectiveApplied = /* @__PURE__ */ Symbol.for(`useRedwoodDirective.${options.name}}`);
|
|
112
112
|
return {
|
|
113
113
|
onSchemaChange({ schema, replaceSchema }) {
|
|
114
114
|
if (schema.extensions?.[wasDirectiveApplied] === true) {
|
|
@@ -123,6 +123,7 @@ const useRedwoodDirective = (options) => {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
};
|
|
126
|
+
const useRedwoodDirective = useCedarDirective;
|
|
126
127
|
const _isValidator = (options) => {
|
|
127
128
|
return options.type === "VALIDATOR_DIRECTIVE" /* VALIDATOR */;
|
|
128
129
|
};
|
|
@@ -134,5 +135,6 @@ export {
|
|
|
134
135
|
getDirectiveByName,
|
|
135
136
|
hasDirective,
|
|
136
137
|
isPromise,
|
|
138
|
+
useCedarDirective,
|
|
137
139
|
useRedwoodDirective
|
|
138
140
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda';
|
|
2
|
+
import type { AuthContextPayload } from '@cedarjs/api';
|
|
3
|
+
import type { GraphQLYogaOptions } from './types.js';
|
|
4
|
+
export type ServerAuthOptions = Pick<GraphQLYogaOptions, 'authDecoder' | 'getCurrentUser'>;
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the auth state a GraphQL request carries: the token and provider
|
|
7
|
+
* type from its `Authorization`/`auth-provider` headers or cookies, plus what
|
|
8
|
+
* the configured decoders make of the token. `getCurrentUser` turns that into
|
|
9
|
+
* the current user.
|
|
10
|
+
*
|
|
11
|
+
* `getCurrentUser` is the only consumer, so when a server has none there is
|
|
12
|
+
* nothing to resolve for. That also spares a server without auth from failing
|
|
13
|
+
* a request that carries a stray `auth-provider` header but no usable
|
|
14
|
+
* `Authorization` header.
|
|
15
|
+
*
|
|
16
|
+
* Decoders are optional. A project whose tokens can't be decoded locally, such
|
|
17
|
+
* as opaque OAuth access tokens, has `getCurrentUser` validate the raw token
|
|
18
|
+
* it's handed instead, and the decoded value it receives is `null`.
|
|
19
|
+
*
|
|
20
|
+
* On fetch-native paths this has to run before the GraphQL server reads the
|
|
21
|
+
* request body: the payload carries a Lambda-style event built from the
|
|
22
|
+
* `Request`, and building it reads the body.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveServerAuthState({ authDecoder, getCurrentUser }: ServerAuthOptions, event: APIGatewayProxyEvent | Request, context?: LambdaContext): Promise<AuthContextPayload | undefined>;
|
|
25
|
+
//# sourceMappingURL=serverAuthState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverAuthState.d.ts","sourceRoot":"","sources":["../src/serverAuthState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,YAAY,CAAA;AAGhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,kBAAkB,EAClB,aAAa,GAAG,gBAAgB,CACjC,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,sBAAsB,CAC1C,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE,iBAAiB,EAClD,KAAK,EAAE,oBAAoB,GAAG,OAAO,EACrC,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAMzC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getAuthenticationContext } from "@cedarjs/api";
|
|
2
|
+
async function resolveServerAuthState({ authDecoder, getCurrentUser }, event, context) {
|
|
3
|
+
if (!getCurrentUser) {
|
|
4
|
+
return void 0;
|
|
5
|
+
}
|
|
6
|
+
return getAuthenticationContext({ authDecoder, event, context });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
resolveServerAuthState
|
|
10
|
+
};
|
|
@@ -5,14 +5,14 @@ import type { DocumentNode } from 'graphql';
|
|
|
5
5
|
* But not fully supported in TS
|
|
6
6
|
* {
|
|
7
7
|
* schema: DocumentNode // <-- required
|
|
8
|
-
* [string]:
|
|
8
|
+
* [string]: CedarSubscription
|
|
9
9
|
* }
|
|
10
10
|
*/
|
|
11
11
|
export type SubscriptionGlobImports = Record<string, any>;
|
|
12
|
-
export type
|
|
12
|
+
export type CedarSubscription = {
|
|
13
13
|
schema: DocumentNode;
|
|
14
14
|
resolvers: any;
|
|
15
15
|
name: string;
|
|
16
16
|
};
|
|
17
|
-
export declare const makeSubscriptions: (SubscriptionGlobs: SubscriptionGlobImports) =>
|
|
17
|
+
export declare const makeSubscriptions: (SubscriptionGlobs: SubscriptionGlobImports) => CedarSubscription[];
|
|
18
18
|
//# sourceMappingURL=makeSubscriptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeSubscriptions.d.ts","sourceRoot":"","sources":["../../src/subscriptions/makeSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEzD,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"makeSubscriptions.d.ts","sourceRoot":"","sources":["../../src/subscriptions/makeSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,YAAY,CAAA;IACpB,SAAS,EAAE,GAAG,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,mBAAmB,uBAAuB,KACzC,iBAAiB,EAmBnB,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import type { GraphQLArmorConfig } from '@escape.tech/graphql-armor-types';
|
|
|
3
3
|
import type { IExecutableSchemaDefinition } from '@graphql-tools/schema';
|
|
4
4
|
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda';
|
|
5
5
|
import type { GraphQLObjectType, GraphQLInterfaceType, DocumentNode } from 'graphql';
|
|
6
|
-
import type { Plugin } from 'graphql-yoga';
|
|
7
|
-
import type { AuthContextPayload, Decoder } from '@cedarjs/api';
|
|
8
|
-
import type {
|
|
6
|
+
import type { GraphQLParams, Plugin } from 'graphql-yoga';
|
|
7
|
+
import type { AuthContextPayload, CorsConfig, Decoder } from '@cedarjs/api';
|
|
8
|
+
import type { CedarRequestContext } from '@cedarjs/api/runtime';
|
|
9
9
|
import type { CedarRealtimeOptions } from '@cedarjs/realtime';
|
|
10
10
|
import type { DirectiveGlobImports } from './directives/makeDirectives.js';
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
11
|
+
import type { LoggerConfig } from './plugins/useCedarLogger.js';
|
|
12
|
+
import type { CedarTrustedDocumentOptions, RedwoodTrustedDocumentOptions } from './plugins/useCedarTrustedDocuments.js';
|
|
13
|
+
import type { UseCedarDirectiveReturn, useRedwoodDirectiveReturn, DirectivePluginOptions } from './plugins/useRedwoodDirective.js';
|
|
14
14
|
export type Resolver = (...args: unknown[]) => unknown;
|
|
15
15
|
export type Services = {
|
|
16
16
|
[funcName: string]: Resolver;
|
|
@@ -33,7 +33,7 @@ export interface MakeServicesInterface {
|
|
|
33
33
|
}
|
|
34
34
|
export type MakeServices = (args: MakeServicesInterface) => ServicesGlobImports;
|
|
35
35
|
export type GraphQLTypeWithFields = GraphQLObjectType | GraphQLInterfaceType;
|
|
36
|
-
export type { useRedwoodDirectiveReturn, DirectivePluginOptions };
|
|
36
|
+
export type { UseCedarDirectiveReturn, useRedwoodDirectiveReturn, DirectivePluginOptions, CedarTrustedDocumentOptions, RedwoodTrustedDocumentOptions, };
|
|
37
37
|
export type GetCurrentUser = (decoded: AuthContextPayload[0], raw: AuthContextPayload[1], req?: AuthContextPayload[2]) => Promise<null | Record<string, unknown>>;
|
|
38
38
|
export type GenerateGraphiQLHeader = () => string;
|
|
39
39
|
export type Context = Record<string, unknown>;
|
|
@@ -46,9 +46,16 @@ export type ArmorConfig = {
|
|
|
46
46
|
* This is an interface so you can extend it inside your application when needed
|
|
47
47
|
*/
|
|
48
48
|
export interface CedarGraphQLContext {
|
|
49
|
-
|
|
49
|
+
request?: Request;
|
|
50
|
+
cedarContext?: CedarRequestContext;
|
|
51
|
+
event?: APIGatewayProxyEvent;
|
|
50
52
|
requestContext?: LambdaContext | undefined;
|
|
51
53
|
currentUser?: ThenArg<ReturnType<GetCurrentUser>> | AuthContextPayload | null;
|
|
54
|
+
/**
|
|
55
|
+
* The GraphQL request's query, variables and operation name, as Yoga parsed
|
|
56
|
+
* them. Available to a `context` function, which runs after parsing.
|
|
57
|
+
*/
|
|
58
|
+
params: GraphQLParams;
|
|
52
59
|
[index: string]: unknown;
|
|
53
60
|
}
|
|
54
61
|
/**
|
|
@@ -56,12 +63,14 @@ export interface CedarGraphQLContext {
|
|
|
56
63
|
* @deprecated Please use CedarGraphQLContext
|
|
57
64
|
*/
|
|
58
65
|
export interface RedwoodGraphQLContext {
|
|
59
|
-
|
|
66
|
+
request?: Request;
|
|
67
|
+
cedarContext?: CedarRequestContext;
|
|
68
|
+
event?: APIGatewayProxyEvent;
|
|
60
69
|
requestContext: LambdaContext | undefined;
|
|
61
70
|
currentUser?: ThenArg<ReturnType<GetCurrentUser>> | AuthContextPayload | null;
|
|
62
71
|
[index: string]: unknown;
|
|
63
72
|
}
|
|
64
|
-
export interface
|
|
73
|
+
export interface CedarOpenTelemetryConfig {
|
|
65
74
|
/**
|
|
66
75
|
* @description Enables the creation of a span for each resolver execution.
|
|
67
76
|
*/
|
|
@@ -75,9 +84,13 @@ export interface RedwoodOpenTelemetryConfig {
|
|
|
75
84
|
*/
|
|
76
85
|
result: boolean;
|
|
77
86
|
}
|
|
78
|
-
|
|
87
|
+
/** @deprecated Please use CedarOpenTelemetryConfig */
|
|
88
|
+
export type RedwoodOpenTelemetryConfig = CedarOpenTelemetryConfig;
|
|
89
|
+
export interface CedarScalarConfig {
|
|
79
90
|
File?: boolean;
|
|
80
91
|
}
|
|
92
|
+
/** @deprecated Please use CedarScalarConfig */
|
|
93
|
+
export type RedwoodScalarConfig = CedarScalarConfig;
|
|
81
94
|
/**
|
|
82
95
|
* GraphQLYogaOptions
|
|
83
96
|
*/
|
|
@@ -204,18 +217,18 @@ export type GraphQLYogaOptions = {
|
|
|
204
217
|
* @see https://benjie.dev/graphql/trusted-documents
|
|
205
218
|
* @see https://the-guild.dev/graphql/yoga-server/docs/features/persisted-operations
|
|
206
219
|
*/
|
|
207
|
-
trustedDocuments?:
|
|
220
|
+
trustedDocuments?: CedarTrustedDocumentOptions;
|
|
208
221
|
/**
|
|
209
222
|
* @description Configure OpenTelemetry plugin behaviour
|
|
210
223
|
*/
|
|
211
|
-
openTelemetryOptions?:
|
|
224
|
+
openTelemetryOptions?: CedarOpenTelemetryConfig;
|
|
212
225
|
/**
|
|
213
226
|
* @description Configure which scalars to include in the schema. This should match your
|
|
214
227
|
* `graphql.includeScalars` configuration in `cedar.toml`.
|
|
215
228
|
*
|
|
216
229
|
* The default is to include. You must set to `false` to exclude.
|
|
217
230
|
*/
|
|
218
|
-
includeScalars?:
|
|
231
|
+
includeScalars?: CedarScalarConfig;
|
|
219
232
|
};
|
|
220
233
|
/**
|
|
221
234
|
* @description Configure GraphQLHandler with options
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;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