@cedarjs/graphql-server 5.0.6 → 5.0.7-next.219
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.js +19 -19
- package/dist/directives/makeDirectives.d.ts +2 -2
- package/dist/directives/makeDirectives.d.ts.map +1 -1
- 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/{useRedwoodAuthContext.d.ts → useCedarAuthContext.d.ts} +2 -2
- package/dist/plugins/useCedarAuthContext.d.ts.map +1 -0
- package/dist/plugins/useCedarAuthContext.js +30 -0
- 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} +2 -2
- package/dist/{cjs/plugins/useRedwoodOpenTelemetry.d.ts → plugins/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} +2 -2
- package/dist/plugins/useRedwoodDirective.d.ts +9 -3
- package/dist/plugins/useRedwoodDirective.d.ts.map +1 -1
- package/dist/plugins/useRedwoodDirective.js +3 -1
- package/dist/subscriptions/makeSubscriptions.d.ts +3 -3
- package/dist/subscriptions/makeSubscriptions.d.ts.map +1 -1
- package/dist/types.d.ts +13 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -20
- 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 -193
- 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 -32
- package/dist/cjs/errors.d.ts.map +0 -1
- package/dist/cjs/errors.js +0 -101
- 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 -201
- 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 -74
- 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 -156
- 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 -231
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/cjs/types.js +0 -16
- package/dist/plugins/useRedwoodAuthContext.d.ts.map +0 -1
- package/dist/plugins/useRedwoodAuthContext.js +0 -50
- 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 +0 -22
- 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
|
@@ -13,14 +13,14 @@ import { configureGraphQLIntrospection } from "./introspection.js";
|
|
|
13
13
|
import { makeMergedSchema } from "./makeMergedSchema.js";
|
|
14
14
|
import {
|
|
15
15
|
useArmor,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
useCedarAuthContext,
|
|
17
|
+
useCedarDirective,
|
|
18
|
+
useCedarError,
|
|
19
|
+
useCedarGlobalContextSetter,
|
|
20
|
+
useCedarOpenTelemetry,
|
|
21
|
+
useCedarLogger,
|
|
22
|
+
useCedarPopulateContext,
|
|
23
|
+
useCedarTrustedDocuments
|
|
24
24
|
} from "./plugins/index.js";
|
|
25
25
|
import { makeSubscriptions } from "./subscriptions/makeSubscriptions.js";
|
|
26
26
|
const createGraphQLYoga = async ({
|
|
@@ -49,15 +49,15 @@ const createGraphQLYoga = async ({
|
|
|
49
49
|
includeScalars
|
|
50
50
|
}) => {
|
|
51
51
|
let schema;
|
|
52
|
-
let
|
|
52
|
+
let cedarDirectivePlugins = [];
|
|
53
53
|
const logger = loggerConfig.logger;
|
|
54
54
|
const isDevEnv = process.env.NODE_ENV === "development";
|
|
55
55
|
try {
|
|
56
56
|
const projectDirectives = makeDirectivesForPlugin(directives);
|
|
57
57
|
if (projectDirectives.length > 0) {
|
|
58
58
|
;
|
|
59
|
-
|
|
60
|
-
(directive) =>
|
|
59
|
+
cedarDirectivePlugins = projectDirectives.map(
|
|
60
|
+
(directive) => useCedarDirective(directive)
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
let projectSubscriptions = [];
|
|
@@ -94,14 +94,14 @@ const createGraphQLYoga = async ({
|
|
|
94
94
|
if (disableIntrospection) {
|
|
95
95
|
plugins.push(useDisableIntrospection());
|
|
96
96
|
}
|
|
97
|
-
plugins.push(
|
|
98
|
-
plugins.push(
|
|
97
|
+
plugins.push(useCedarAuthContext(getCurrentUser, authDecoder));
|
|
98
|
+
plugins.push(useCedarGlobalContextSetter());
|
|
99
99
|
if (context) {
|
|
100
|
-
plugins.push(
|
|
100
|
+
plugins.push(useCedarPopulateContext(context));
|
|
101
101
|
}
|
|
102
|
-
plugins.push(...
|
|
102
|
+
plugins.push(...cedarDirectivePlugins);
|
|
103
103
|
if (openTelemetryOptions !== void 0) {
|
|
104
|
-
plugins.push(
|
|
104
|
+
plugins.push(useCedarOpenTelemetry(openTelemetryOptions));
|
|
105
105
|
}
|
|
106
106
|
plugins.push(useArmor(logger, armorConfig));
|
|
107
107
|
const defaultAllowedOperations = [
|
|
@@ -115,12 +115,12 @@ const createGraphQLYoga = async ({
|
|
|
115
115
|
useFilterAllowedOperations(allowedOperations || defaultAllowedOperations)
|
|
116
116
|
);
|
|
117
117
|
if (trustedDocuments && !trustedDocuments.disabled) {
|
|
118
|
-
plugins.push(
|
|
118
|
+
plugins.push(useCedarTrustedDocuments(trustedDocuments));
|
|
119
119
|
}
|
|
120
120
|
if (extraPlugins && extraPlugins.length > 0) {
|
|
121
121
|
plugins.push(...extraPlugins);
|
|
122
122
|
}
|
|
123
|
-
plugins.push(
|
|
123
|
+
plugins.push(useCedarError(logger));
|
|
124
124
|
plugins.push(
|
|
125
125
|
useReadinessCheck({
|
|
126
126
|
endpoint: graphiQLEndpoint + "/readiness",
|
|
@@ -138,7 +138,7 @@ const createGraphQLYoga = async ({
|
|
|
138
138
|
}
|
|
139
139
|
})
|
|
140
140
|
);
|
|
141
|
-
plugins.push(
|
|
141
|
+
plugins.push(useCedarLogger(loggerConfig));
|
|
142
142
|
const yoga = createYoga({
|
|
143
143
|
id: healthCheckId,
|
|
144
144
|
landingPage: isDevEnv,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DocumentNode } from 'graphql';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CedarDirective, TransformerDirective, TransformerDirectiveFunc, ValidatorDirective, ValidatorDirectiveFunc } from '../plugins/useRedwoodDirective.js';
|
|
3
3
|
export type DirectiveGlobImports = Record<string, any>;
|
|
4
|
-
export declare const makeDirectivesForPlugin: (directiveGlobs: DirectiveGlobImports) =>
|
|
4
|
+
export declare const makeDirectivesForPlugin: (directiveGlobs: DirectiveGlobImports) => CedarDirective[];
|
|
5
5
|
export declare const getDirectiveName: (schema: DocumentNode) => string | undefined;
|
|
6
6
|
export declare const createValidatorDirective: (schema: DocumentNode, directiveFunc: ValidatorDirectiveFunc) => ValidatorDirective;
|
|
7
7
|
export declare const createTransformerDirective: (schema: DocumentNode, directiveFunc: TransformerDirectiveFunc) => TransformerDirective;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,cAAc,EACd,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,cAAc,EAwBhB,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export * from './makeMergedSchema.js';
|
|
|
7
7
|
export * from './createGraphQLYoga.js';
|
|
8
8
|
export * from './types.js';
|
|
9
9
|
export { createValidatorDirective, createTransformerDirective, getDirectiveName, makeDirectivesForPlugin, } from './directives/makeDirectives.js';
|
|
10
|
-
export { hasDirective, DirectiveType, useRedwoodDirective, } from './plugins/useRedwoodDirective.js';
|
|
11
|
-
export type { DirectiveParams, RedwoodDirective, ValidatorDirective, ValidatorDirectiveFunc, TransformerDirective, TransformerDirectiveFunc, ValidateArgs, TransformArgs, } from './plugins/useRedwoodDirective.js';
|
|
10
|
+
export { hasDirective, DirectiveType, useCedarDirective, useRedwoodDirective, } from './plugins/useRedwoodDirective.js';
|
|
11
|
+
export type { DirectiveParams, CedarDirective, RedwoodDirective, ValidatorDirective, ValidatorDirectiveFunc, TransformerDirective, TransformerDirectiveFunc, ValidateArgs, TransformArgs, } from './plugins/useRedwoodDirective.js';
|
|
12
12
|
export * as rootSchema from './rootSchema.js';
|
|
13
13
|
export { context, setContext } from '@cedarjs/context';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AAErC,cAAc,8BAA8B,CAAA;AAE5C,cAAc,aAAa,CAAA;AAC3B,cAAc,wBAAwB,CAAA;AACtC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,YAAY,CAAA;AAE1B,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,mBAAmB,GACpB,MAAM,kCAAkC,CAAA;AAEzC,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,aAAa,GACd,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAG7C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AAErC,cAAc,8BAA8B,CAAA;AAE5C,cAAc,aAAa,CAAA;AAC3B,cAAc,wBAAwB,CAAA;AACtC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,YAAY,CAAA;AAE1B,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,kCAAkC,CAAA;AAEzC,YAAY,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,aAAa,GACd,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAG7C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
hasDirective,
|
|
17
17
|
DirectiveType,
|
|
18
|
+
useCedarDirective,
|
|
18
19
|
useRedwoodDirective
|
|
19
20
|
} from "./plugins/useRedwoodDirective.js";
|
|
20
21
|
import * as rootSchema from "./rootSchema.js";
|
|
@@ -29,5 +30,6 @@ export {
|
|
|
29
30
|
makeDirectivesForPlugin,
|
|
30
31
|
rootSchema,
|
|
31
32
|
setContext,
|
|
33
|
+
useCedarDirective,
|
|
32
34
|
useRedwoodDirective
|
|
33
35
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { IExecutableSchemaDefinition } from '@graphql-tools/schema';
|
|
2
2
|
import type { GraphQLSchema } from 'graphql';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { ServicesGlobImports, SdlGlobImports,
|
|
3
|
+
import type { CedarDirective } from './plugins/useRedwoodDirective.js';
|
|
4
|
+
import type { CedarSubscription } from './subscriptions/makeSubscriptions.js';
|
|
5
|
+
import type { ServicesGlobImports, SdlGlobImports, CedarScalarConfig } from './types.js';
|
|
6
6
|
export declare const makeMergedSchema: ({ sdls, services, schemaOptions, directives, subscriptions, includeScalars, }: {
|
|
7
7
|
sdls: SdlGlobImports;
|
|
8
8
|
services: ServicesGlobImports;
|
|
9
|
-
directives:
|
|
10
|
-
subscriptions:
|
|
11
|
-
includeScalars?:
|
|
9
|
+
directives: CedarDirective[];
|
|
10
|
+
subscriptions: CedarSubscription[];
|
|
11
|
+
includeScalars?: CedarScalarConfig;
|
|
12
12
|
/**
|
|
13
13
|
* A list of options passed to [makeExecutableSchema](https://www.graphql-tools.com/docs/generate-schema/#makeexecutableschemaoptions).
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeMergedSchema.d.ts","sourceRoot":"","sources":["../src/makeMergedSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAUxE,OAAO,KAAK,EACV,aAAa,EAKd,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"makeMergedSchema.d.ts","sourceRoot":"","sources":["../src/makeMergedSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAUxE,OAAO,KAAK,EACV,aAAa,EAKd,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAEV,mBAAmB,EAEnB,cAAc,EACd,iBAAiB,EAClB,MAAM,YAAY,CAAA;AAuUnB,eAAO,MAAM,gBAAgB,GAAI,+EAO9B;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,UAAU,EAAE,cAAc,EAAE,CAAA;IAC5B,aAAa,EAAE,iBAAiB,EAAE,CAAA;IAClC,cAAc,CAAC,EAAE,iBAAiB,CAAA;IAElC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAA;CACrD,kBA+CA,CAAA"}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { useArmor } from './useArmor.js';
|
|
2
|
-
export {
|
|
3
|
-
export { useRedwoodDirective } from './useRedwoodDirective.js';
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
2
|
+
export { useCedarAuthContext } from './useCedarAuthContext.js';
|
|
3
|
+
export { useCedarDirective, useRedwoodDirective, } from './useRedwoodDirective.js';
|
|
4
|
+
export { useCedarError } from './useCedarError.js';
|
|
5
|
+
export { useCedarGlobalContextSetter } from './useCedarGlobalContextSetter.js';
|
|
6
|
+
export { useCedarLogger } from './useCedarLogger.js';
|
|
7
|
+
export { useCedarTrustedDocuments } from './useCedarTrustedDocuments.js';
|
|
8
|
+
export { useCedarPopulateContext } from './useCedarPopulateContext.js';
|
|
9
|
+
export { useCedarOpenTelemetry } from './useCedarOpenTelemetry.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAExE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { useArmor } from "./useArmor.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
2
|
+
import { useCedarAuthContext } from "./useCedarAuthContext.js";
|
|
3
|
+
import {
|
|
4
|
+
useCedarDirective,
|
|
5
|
+
useRedwoodDirective
|
|
6
|
+
} from "./useRedwoodDirective.js";
|
|
7
|
+
import { useCedarError } from "./useCedarError.js";
|
|
8
|
+
import { useCedarGlobalContextSetter } from "./useCedarGlobalContextSetter.js";
|
|
9
|
+
import { useCedarLogger } from "./useCedarLogger.js";
|
|
10
|
+
import { useCedarTrustedDocuments } from "./useCedarTrustedDocuments.js";
|
|
11
|
+
import { useCedarPopulateContext } from "./useCedarPopulateContext.js";
|
|
12
|
+
import { useCedarOpenTelemetry } from "./useCedarOpenTelemetry.js";
|
|
10
13
|
export {
|
|
11
14
|
useArmor,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
useCedarAuthContext,
|
|
16
|
+
useCedarDirective,
|
|
17
|
+
useCedarError,
|
|
18
|
+
useCedarGlobalContextSetter,
|
|
19
|
+
useCedarLogger,
|
|
20
|
+
useCedarOpenTelemetry,
|
|
21
|
+
useCedarPopulateContext,
|
|
22
|
+
useCedarTrustedDocuments,
|
|
23
|
+
useRedwoodDirective
|
|
20
24
|
};
|
|
@@ -5,5 +5,5 @@ import type { CedarGraphQLContext, GraphQLHandlerOptions } from '../types.js';
|
|
|
5
5
|
* Envelop plugin for injecting the current user into the GraphQL Context,
|
|
6
6
|
* based on custom getCurrentUser function.
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
export declare const useCedarAuthContext: (getCurrentUser: GraphQLHandlerOptions["getCurrentUser"], authDecoder?: Decoder | Decoder[]) => Plugin<CedarGraphQLContext>;
|
|
9
|
+
//# sourceMappingURL=useCedarAuthContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCedarAuthContext.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarAuthContext.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,mBAAmB,GAC9B,gBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EACvD,cAAc,OAAO,GAAG,OAAO,EAAE,KAChC,MAAM,CAAC,mBAAmB,CA2C5B,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { hasAuthDecoder } from "@cedarjs/api";
|
|
2
|
+
const useCedarAuthContext = (getCurrentUser, authDecoder) => {
|
|
3
|
+
return {
|
|
4
|
+
async onContextBuilding({ context, extendContext }) {
|
|
5
|
+
if (!context.cedarContext && hasAuthDecoder(authDecoder)) {
|
|
6
|
+
throw new Error(
|
|
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`."
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
const authContext = context.cedarContext?.serverAuthState;
|
|
11
|
+
try {
|
|
12
|
+
if (authContext) {
|
|
13
|
+
const currentUser = getCurrentUser ? await getCurrentUser(
|
|
14
|
+
authContext[0],
|
|
15
|
+
authContext[1],
|
|
16
|
+
authContext[2]
|
|
17
|
+
) : null;
|
|
18
|
+
if (currentUser) {
|
|
19
|
+
extendContext({ currentUser });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw new Error(`Exception in getCurrentUser: ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
useCedarAuthContext
|
|
30
|
+
};
|
|
@@ -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({
|
|
@@ -128,5 +128,5 @@ const useRedwoodLogger = (loggerConfig) => {
|
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
130
|
export {
|
|
131
|
-
|
|
131
|
+
useCedarLogger
|
|
132
132
|
};
|
package/dist/{cjs/plugins/useRedwoodOpenTelemetry.d.ts → plugins/useCedarOpenTelemetry.d.ts}
RENAMED
|
@@ -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,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,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;AAoEvE,eAAO,MAAM,wBAAwB,GACnC,SAAS,2BAA2B,KACnC,MAAM,CAAC,mBAAmB,CA8B5B,CAAA"}
|
|
@@ -23,7 +23,7 @@ const allowCedarStudioResyncMailMutations = async (request) => {
|
|
|
23
23
|
const isAllowedQuery = query === CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION || query === CEDAR__STUDIO_TEMPLATE_MUTATION;
|
|
24
24
|
return hasContentType && isAllowedQuery;
|
|
25
25
|
};
|
|
26
|
-
const
|
|
26
|
+
const useCedarTrustedDocuments = (options) => {
|
|
27
27
|
return usePersistedOperations({
|
|
28
28
|
...options,
|
|
29
29
|
customErrors: {
|
|
@@ -52,5 +52,5 @@ const useRedwoodTrustedDocuments = (options) => {
|
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
54
|
export {
|
|
55
|
-
|
|
55
|
+
useCedarTrustedDocuments
|
|
56
56
|
};
|
|
@@ -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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AI,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,7 +107,7 @@ function wrapAffectedResolvers(schema, options) {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
const
|
|
110
|
+
const useCedarDirective = (options) => {
|
|
111
111
|
const wasDirectiveApplied = /* @__PURE__ */ Symbol.for(`useRedwoodDirective.${options.name}}`);
|
|
112
112
|
return {
|
|
113
113
|
onSchemaChange({ schema, replaceSchema }) {
|
|
@@ -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
|
};
|
|
@@ -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"}
|