@cedarjs/graphql-server 5.0.7-next.338 → 5.0.7
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/cors.d.ts +10 -0
- package/dist/cjs/cors.d.ts.map +1 -0
- package/dist/cjs/cors.js +70 -0
- package/dist/cjs/createGraphQLYoga.d.ts +6 -0
- package/dist/cjs/createGraphQLYoga.d.ts.map +1 -0
- package/dist/cjs/createGraphQLYoga.js +193 -0
- package/dist/cjs/directives/makeDirectives.d.ts +8 -0
- package/dist/cjs/directives/makeDirectives.d.ts.map +1 -0
- package/dist/cjs/directives/makeDirectives.js +89 -0
- package/dist/cjs/errors.d.ts +32 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +101 -0
- package/dist/cjs/functions/graphql.d.ts +15 -0
- package/dist/cjs/functions/graphql.d.ts.map +1 -0
- package/dist/cjs/functions/graphql.js +201 -0
- package/dist/cjs/functions/useRequireAuth.d.ts +12 -0
- package/dist/cjs/functions/useRequireAuth.d.ts.map +1 -0
- package/dist/cjs/functions/useRequireAuth.js +70 -0
- package/dist/cjs/global.api-auto-imports.d.ts +7 -0
- package/dist/cjs/global.api-auto-imports.d.ts.map +1 -0
- package/dist/cjs/global.api-auto-imports.js +1 -0
- package/dist/cjs/globalContext.d.ts +25 -0
- package/dist/cjs/globalContext.d.ts.map +1 -0
- package/dist/cjs/globalContext.js +55 -0
- package/dist/cjs/globalContextStore.d.ts +9 -0
- package/dist/cjs/globalContextStore.d.ts.map +1 -0
- package/dist/cjs/globalContextStore.js +35 -0
- package/dist/cjs/graphiql.d.ts +8 -0
- package/dist/cjs/graphiql.d.ts.map +1 -0
- package/dist/cjs/graphiql.js +45 -0
- package/dist/cjs/index.d.ts +14 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +75 -0
- package/dist/cjs/introspection.d.ts +7 -0
- package/dist/cjs/introspection.d.ts.map +1 -0
- package/dist/cjs/introspection.js +36 -0
- package/dist/cjs/makeMergedSchema.d.ts +17 -0
- package/dist/cjs/makeMergedSchema.d.ts.map +1 -0
- package/dist/cjs/makeMergedSchema.js +283 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/index.d.ts +10 -0
- package/dist/cjs/plugins/index.d.ts.map +1 -0
- package/dist/cjs/plugins/index.js +52 -0
- package/dist/cjs/plugins/useArmor.d.ts +4 -0
- package/dist/cjs/plugins/useArmor.d.ts.map +1 -0
- package/dist/cjs/plugins/useArmor.js +69 -0
- package/dist/{plugins/useCedarAuthContext.d.ts → cjs/plugins/useRedwoodAuthContext.d.ts} +2 -2
- package/dist/cjs/plugins/useRedwoodAuthContext.d.ts.map +1 -0
- package/dist/cjs/plugins/useRedwoodAuthContext.js +74 -0
- package/dist/cjs/plugins/useRedwoodDirective.d.ts +83 -0
- package/dist/cjs/plugins/useRedwoodDirective.d.ts.map +1 -0
- package/dist/cjs/plugins/useRedwoodDirective.js +166 -0
- package/dist/{plugins/useCedarError.d.ts → cjs/plugins/useRedwoodError.d.ts} +4 -4
- package/dist/cjs/plugins/useRedwoodError.d.ts.map +1 -0
- package/dist/cjs/plugins/useRedwoodError.js +62 -0
- package/dist/{plugins/useCedarGlobalContextSetter.d.ts → cjs/plugins/useRedwoodGlobalContextSetter.d.ts} +2 -2
- package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts.map +1 -0
- package/dist/cjs/plugins/useRedwoodGlobalContextSetter.js +35 -0
- package/dist/{plugins/useCedarLogger.d.ts → cjs/plugins/useRedwoodLogger.d.ts} +2 -2
- package/dist/cjs/plugins/useRedwoodLogger.d.ts.map +1 -0
- package/dist/cjs/plugins/useRedwoodLogger.js +156 -0
- package/dist/{plugins/useCedarOpenTelemetry.d.ts → cjs/plugins/useRedwoodOpenTelemetry.d.ts} +3 -3
- package/dist/cjs/plugins/useRedwoodOpenTelemetry.d.ts.map +1 -0
- package/dist/cjs/plugins/useRedwoodOpenTelemetry.js +156 -0
- package/dist/{plugins/useCedarPopulateContext.d.ts → cjs/plugins/useRedwoodPopulateContext.d.ts} +2 -2
- package/dist/cjs/plugins/useRedwoodPopulateContext.d.ts.map +1 -0
- package/dist/cjs/plugins/useRedwoodPopulateContext.js +35 -0
- package/dist/{plugins/useCedarTrustedDocuments.d.ts → cjs/plugins/useRedwoodTrustedDocuments.d.ts} +3 -5
- package/dist/cjs/plugins/useRedwoodTrustedDocuments.d.ts.map +1 -0
- package/dist/cjs/plugins/useRedwoodTrustedDocuments.js +80 -0
- package/dist/cjs/rootSchema.d.ts +25 -0
- package/dist/cjs/rootSchema.d.ts.map +1 -0
- package/dist/cjs/rootSchema.js +108 -0
- package/dist/cjs/subscriptions/makeSubscriptions.d.ts +18 -0
- package/dist/cjs/subscriptions/makeSubscriptions.d.ts.map +1 -0
- package/dist/cjs/subscriptions/makeSubscriptions.js +40 -0
- package/dist/cjs/types.d.ts +231 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +16 -0
- 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 +0 -2
- 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 +16 -20
- package/dist/plugins/useRedwoodAuthContext.d.ts +9 -0
- package/dist/plugins/useRedwoodAuthContext.d.ts.map +1 -0
- package/dist/plugins/useRedwoodAuthContext.js +50 -0
- package/dist/plugins/useRedwoodDirective.d.ts +3 -9
- package/dist/plugins/useRedwoodDirective.d.ts.map +1 -1
- package/dist/plugins/useRedwoodDirective.js +1 -3
- package/dist/plugins/useRedwoodError.d.ts +20 -0
- package/dist/plugins/useRedwoodError.d.ts.map +1 -0
- package/dist/plugins/{useCedarError.js → useRedwoodError.js} +5 -5
- package/dist/plugins/useRedwoodGlobalContextSetter.d.ts +9 -0
- package/dist/plugins/useRedwoodGlobalContextSetter.d.ts.map +1 -0
- package/dist/plugins/{useCedarGlobalContextSetter.js → useRedwoodGlobalContextSetter.js} +2 -2
- package/dist/plugins/useRedwoodLogger.d.ts +115 -0
- package/dist/plugins/useRedwoodLogger.d.ts.map +1 -0
- package/dist/plugins/{useCedarLogger.js → useRedwoodLogger.js} +2 -2
- package/dist/plugins/useRedwoodOpenTelemetry.d.ts +22 -0
- package/dist/plugins/useRedwoodOpenTelemetry.d.ts.map +1 -0
- package/dist/plugins/{useCedarOpenTelemetry.js → useRedwoodOpenTelemetry.js} +3 -3
- package/dist/plugins/useRedwoodPopulateContext.d.ts +9 -0
- package/dist/plugins/useRedwoodPopulateContext.d.ts.map +1 -0
- package/dist/plugins/{useCedarPopulateContext.js → useRedwoodPopulateContext.js} +2 -2
- package/dist/plugins/useRedwoodTrustedDocuments.d.ts +23 -0
- package/dist/plugins/useRedwoodTrustedDocuments.d.ts.map +1 -0
- package/dist/plugins/{useCedarTrustedDocuments.js → useRedwoodTrustedDocuments.js} +13 -20
- package/dist/subscriptions/makeSubscriptions.d.ts +3 -3
- package/dist/subscriptions/makeSubscriptions.d.ts.map +1 -1
- package/dist/types.d.ts +9 -13
- package/dist/types.d.ts.map +1 -1
- package/package.json +24 -16
- package/dist/plugins/useCedarAuthContext.d.ts.map +0 -1
- package/dist/plugins/useCedarAuthContext.js +0 -30
- package/dist/plugins/useCedarError.d.ts.map +0 -1
- package/dist/plugins/useCedarGlobalContextSetter.d.ts.map +0 -1
- package/dist/plugins/useCedarLogger.d.ts.map +0 -1
- package/dist/plugins/useCedarOpenTelemetry.d.ts.map +0 -1
- package/dist/plugins/useCedarPopulateContext.d.ts.map +0 -1
- package/dist/plugins/useCedarTrustedDocuments.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
|
+
useRedwoodAuthContext,
|
|
17
|
+
useRedwoodDirective,
|
|
18
|
+
useRedwoodError,
|
|
19
|
+
useRedwoodGlobalContextSetter,
|
|
20
|
+
useRedwoodOpenTelemetry,
|
|
21
|
+
useRedwoodLogger,
|
|
22
|
+
useRedwoodPopulateContext,
|
|
23
|
+
useRedwoodTrustedDocuments
|
|
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 redwoodDirectivePlugins = [];
|
|
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
|
+
redwoodDirectivePlugins = projectDirectives.map(
|
|
60
|
+
(directive) => useRedwoodDirective(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(useRedwoodAuthContext(getCurrentUser, authDecoder));
|
|
98
|
+
plugins.push(useRedwoodGlobalContextSetter());
|
|
99
99
|
if (context) {
|
|
100
|
-
plugins.push(
|
|
100
|
+
plugins.push(useRedwoodPopulateContext(context));
|
|
101
101
|
}
|
|
102
|
-
plugins.push(...
|
|
102
|
+
plugins.push(...redwoodDirectivePlugins);
|
|
103
103
|
if (openTelemetryOptions !== void 0) {
|
|
104
|
-
plugins.push(
|
|
104
|
+
plugins.push(useRedwoodOpenTelemetry(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(useRedwoodTrustedDocuments(trustedDocuments));
|
|
119
119
|
}
|
|
120
120
|
if (extraPlugins && extraPlugins.length > 0) {
|
|
121
121
|
plugins.push(...extraPlugins);
|
|
122
122
|
}
|
|
123
|
-
plugins.push(
|
|
123
|
+
plugins.push(useRedwoodError(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(useRedwoodLogger(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 { RedwoodDirective, 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) => RedwoodDirective[];
|
|
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,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,mCAAmC,CAAA;AAW1C,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEtD,eAAO,MAAM,uBAAuB,GAClC,gBAAgB,oBAAoB,KACnC,gBAAgB,EAwBlB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,YAAY,uBAMpD,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,QAAQ,YAAY,EACpB,eAAe,sBAAsB,KACpC,kBAmBF,CAAA;AAED,eAAO,MAAM,0BAA0B,GACrC,QAAQ,YAAY,EACpB,eAAe,wBAAwB,KACtC,oBAmBF,CAAA"}
|
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,
|
|
11
|
-
export type { DirectiveParams,
|
|
10
|
+
export { hasDirective, DirectiveType, useRedwoodDirective, } from './plugins/useRedwoodDirective.js';
|
|
11
|
+
export type { DirectiveParams, 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,
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
hasDirective,
|
|
17
17
|
DirectiveType,
|
|
18
|
-
useCedarDirective,
|
|
19
18
|
useRedwoodDirective
|
|
20
19
|
} from "./plugins/useRedwoodDirective.js";
|
|
21
20
|
import * as rootSchema from "./rootSchema.js";
|
|
@@ -30,6 +29,5 @@ export {
|
|
|
30
29
|
makeDirectivesForPlugin,
|
|
31
30
|
rootSchema,
|
|
32
31
|
setContext,
|
|
33
|
-
useCedarDirective,
|
|
34
32
|
useRedwoodDirective
|
|
35
33
|
};
|
|
@@ -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 { RedwoodDirective } from './plugins/useRedwoodDirective.js';
|
|
4
|
+
import type { RedwoodSubscription } from './subscriptions/makeSubscriptions.js';
|
|
5
|
+
import type { ServicesGlobImports, SdlGlobImports, RedwoodScalarConfig } 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: RedwoodDirective[];
|
|
10
|
+
subscriptions: RedwoodSubscription[];
|
|
11
|
+
includeScalars?: RedwoodScalarConfig;
|
|
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,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AAC/E,OAAO,KAAK,EAEV,mBAAmB,EAEnB,cAAc,EACd,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAuUnB,eAAO,MAAM,gBAAgB,GAAI,+EAO9B;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,UAAU,EAAE,gBAAgB,EAAE,CAAA;IAC9B,aAAa,EAAE,mBAAmB,EAAE,CAAA;IACpC,cAAc,CAAC,EAAE,mBAAmB,CAAA;IAEpC;;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 {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
2
|
+
export { useRedwoodAuthContext } from './useRedwoodAuthContext.js';
|
|
3
|
+
export { useRedwoodDirective } from './useRedwoodDirective.js';
|
|
4
|
+
export { useRedwoodError } from './useRedwoodError.js';
|
|
5
|
+
export { useRedwoodGlobalContextSetter } from './useRedwoodGlobalContextSetter.js';
|
|
6
|
+
export { useRedwoodLogger } from './useRedwoodLogger.js';
|
|
7
|
+
export { useRedwoodTrustedDocuments } from './useRedwoodTrustedDocuments.js';
|
|
8
|
+
export { useRedwoodPopulateContext } from './useRedwoodPopulateContext.js';
|
|
9
|
+
export { useRedwoodOpenTelemetry } from './useRedwoodOpenTelemetry.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,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAA;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AAE5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { useArmor } from "./useArmor.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { useCedarTrustedDocuments } from "./useCedarTrustedDocuments.js";
|
|
11
|
-
import { useCedarPopulateContext } from "./useCedarPopulateContext.js";
|
|
12
|
-
import { useCedarOpenTelemetry } from "./useCedarOpenTelemetry.js";
|
|
2
|
+
import { useRedwoodAuthContext } from "./useRedwoodAuthContext.js";
|
|
3
|
+
import { useRedwoodDirective } from "./useRedwoodDirective.js";
|
|
4
|
+
import { useRedwoodError } from "./useRedwoodError.js";
|
|
5
|
+
import { useRedwoodGlobalContextSetter } from "./useRedwoodGlobalContextSetter.js";
|
|
6
|
+
import { useRedwoodLogger } from "./useRedwoodLogger.js";
|
|
7
|
+
import { useRedwoodTrustedDocuments } from "./useRedwoodTrustedDocuments.js";
|
|
8
|
+
import { useRedwoodPopulateContext } from "./useRedwoodPopulateContext.js";
|
|
9
|
+
import { useRedwoodOpenTelemetry } from "./useRedwoodOpenTelemetry.js";
|
|
13
10
|
export {
|
|
14
11
|
useArmor,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
useRedwoodDirective
|
|
12
|
+
useRedwoodAuthContext,
|
|
13
|
+
useRedwoodDirective,
|
|
14
|
+
useRedwoodError,
|
|
15
|
+
useRedwoodGlobalContextSetter,
|
|
16
|
+
useRedwoodLogger,
|
|
17
|
+
useRedwoodOpenTelemetry,
|
|
18
|
+
useRedwoodPopulateContext,
|
|
19
|
+
useRedwoodTrustedDocuments
|
|
24
20
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'graphql-yoga';
|
|
2
|
+
import type { Decoder } from '@cedarjs/api';
|
|
3
|
+
import type { CedarGraphQLContext, GraphQLHandlerOptions } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Envelop plugin for injecting the current user into the GraphQL Context,
|
|
6
|
+
* based on custom getCurrentUser function.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useRedwoodAuthContext: (getCurrentUser: GraphQLHandlerOptions["getCurrentUser"], authDecoder?: Decoder | Decoder[]) => Plugin<CedarGraphQLContext>;
|
|
9
|
+
//# sourceMappingURL=useRedwoodAuthContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRedwoodAuthContext.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodAuthContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAsB,OAAO,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,gBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EACvD,cAAc,OAAO,GAAG,OAAO,EAAE,KAChC,MAAM,CAAC,mBAAmB,CAyC5B,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getAuthenticationContext } from "@cedarjs/api";
|
|
2
|
+
const useRedwoodAuthContext = (getCurrentUser, authDecoder) => {
|
|
3
|
+
return {
|
|
4
|
+
async onContextBuilding({ context, extendContext }) {
|
|
5
|
+
let authContext = context.cedarContext?.serverAuthState;
|
|
6
|
+
try {
|
|
7
|
+
if (!authContext) {
|
|
8
|
+
const authEvent = getAuthEvent(context);
|
|
9
|
+
authContext = await getAuthenticationContext({
|
|
10
|
+
authDecoder,
|
|
11
|
+
event: authEvent,
|
|
12
|
+
context: context.requestContext
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Exception in getAuthenticationContext: ${error.message}`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
if (authContext) {
|
|
22
|
+
const currentUser = getCurrentUser ? await getCurrentUser(
|
|
23
|
+
authContext[0],
|
|
24
|
+
authContext[1],
|
|
25
|
+
authContext[2]
|
|
26
|
+
) : null;
|
|
27
|
+
if (currentUser) {
|
|
28
|
+
extendContext({ currentUser });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new Error(`Exception in getCurrentUser: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
function getAuthEvent(context) {
|
|
38
|
+
if (context.request) {
|
|
39
|
+
return context.request;
|
|
40
|
+
}
|
|
41
|
+
if (context.event) {
|
|
42
|
+
return context.event;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(
|
|
45
|
+
"GraphQL context contains neither a fetch-native Request nor a Lambda event. Please report this as a Cedar bug."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
useRedwoodAuthContext
|
|
50
|
+
};
|
|
@@ -54,9 +54,7 @@ export declare enum DirectiveType {
|
|
|
54
54
|
VALIDATOR = "VALIDATOR_DIRECTIVE",
|
|
55
55
|
TRANSFORMER = "TRANSFORMER_DIRECTIVE"
|
|
56
56
|
}
|
|
57
|
-
export type
|
|
58
|
-
/** @deprecated Use `CedarDirective` instead. */
|
|
59
|
-
export type RedwoodDirective = CedarDirective;
|
|
57
|
+
export type RedwoodDirective = ValidatorDirective | TransformerDirective;
|
|
60
58
|
export interface ValidatorDirective extends ValidatorDirectiveOptions {
|
|
61
59
|
schema: DocumentNode;
|
|
62
60
|
}
|
|
@@ -77,13 +75,9 @@ export type DirectivePluginOptions = ValidatorDirectiveOptions | TransformerDire
|
|
|
77
75
|
export declare function hasDirective(info: GraphQLResolveInfo): boolean;
|
|
78
76
|
export declare function getDirectiveByName(fieldConfig: GraphQLFieldConfig<any, any, any>, directiveName: string): null | DirectiveNode;
|
|
79
77
|
export declare function isPromise(value: any): value is Promise<unknown>;
|
|
80
|
-
export type
|
|
78
|
+
export type useRedwoodDirectiveReturn = Plugin<{
|
|
81
79
|
onResolvedValue: ValidatorDirectiveFunc | TransformerDirectiveFunc;
|
|
82
80
|
}>;
|
|
83
|
-
|
|
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;
|
|
81
|
+
export declare const useRedwoodDirective: (options: DirectivePluginOptions) => useRedwoodDirectiveReturn;
|
|
88
82
|
export {};
|
|
89
83
|
//# 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,S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GAC9B,SAAS,sBAAsB,KAC9B,yBAwBF,CAAA"}
|
|
@@ -107,7 +107,7 @@ function wrapAffectedResolvers(schema, options) {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
const
|
|
110
|
+
const useRedwoodDirective = (options) => {
|
|
111
111
|
const wasDirectiveApplied = /* @__PURE__ */ Symbol.for(`useRedwoodDirective.${options.name}}`);
|
|
112
112
|
return {
|
|
113
113
|
onSchemaChange({ schema, replaceSchema }) {
|
|
@@ -123,7 +123,6 @@ const useCedarDirective = (options) => {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
};
|
|
126
|
-
const useRedwoodDirective = useCedarDirective;
|
|
127
126
|
const _isValidator = (options) => {
|
|
128
127
|
return options.type === "VALIDATOR_DIRECTIVE" /* VALIDATOR */;
|
|
129
128
|
};
|
|
@@ -135,6 +134,5 @@ export {
|
|
|
135
134
|
getDirectiveByName,
|
|
136
135
|
hasDirective,
|
|
137
136
|
isPromise,
|
|
138
|
-
useCedarDirective,
|
|
139
137
|
useRedwoodDirective
|
|
140
138
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Plugin } from 'graphql-yoga';
|
|
2
|
+
import type { Logger } from '@cedarjs/api/logger';
|
|
3
|
+
import type { CedarGraphQLContext } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Converts RedwoodErrors to GraphQLErrors
|
|
6
|
+
*
|
|
7
|
+
* This is a workaround for the fact that graphql-yoga doesn't support custom error types.
|
|
8
|
+
*
|
|
9
|
+
* Yoga automatically masks unexpected errors and prevents leaking sensitive information to clients.
|
|
10
|
+
*
|
|
11
|
+
* Since RedwoodErrors (such as ServiceValidation errors) are expected,
|
|
12
|
+
* we need to convert them to GraphQLErrors so that they are not masked.
|
|
13
|
+
*
|
|
14
|
+
* See: https://the-guild.dev/graphql/yoga-server/docs/features/error-masking
|
|
15
|
+
*
|
|
16
|
+
* @param logger
|
|
17
|
+
* @returns ExecutionResult
|
|
18
|
+
*/
|
|
19
|
+
export declare const useRedwoodError: (logger: Logger) => Plugin<CedarGraphQLContext>;
|
|
20
|
+
//# sourceMappingURL=useRedwoodError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRedwoodError.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodError.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,eAAe,GAC1B,QAAQ,MAAM,KACb,MAAM,CAAC,mBAAmB,CAsC5B,CAAA"}
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
handleStreamOrSingleExecutionResult,
|
|
3
3
|
createGraphQLError
|
|
4
4
|
} from "graphql-yoga";
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
5
|
+
import { RedwoodError } from "@cedarjs/api";
|
|
6
|
+
const useRedwoodError = (logger) => {
|
|
7
7
|
return {
|
|
8
8
|
async onExecute() {
|
|
9
9
|
return {
|
|
@@ -12,10 +12,10 @@ const useCedarError = (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 RedwoodError) {
|
|
16
16
|
logger.debug(
|
|
17
17
|
{ custom: { name: error.originalError.name } },
|
|
18
|
-
"Converting
|
|
18
|
+
"Converting RedwoodError to GraphQLError"
|
|
19
19
|
);
|
|
20
20
|
return createGraphQLError(error.message, {
|
|
21
21
|
extensions: error.extensions
|
|
@@ -37,5 +37,5 @@ const useCedarError = (logger) => {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
useRedwoodError
|
|
41
41
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'graphql-yoga';
|
|
2
|
+
import type { CedarGraphQLContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* This Envelop plugin waits until the GraphQL context is done building and sets
|
|
5
|
+
* the CedarJS global context which can be imported with:
|
|
6
|
+
* `import { context } from '@cedarjs/context'`
|
|
7
|
+
*/
|
|
8
|
+
export declare const useRedwoodGlobalContextSetter: () => Plugin<CedarGraphQLContext>;
|
|
9
|
+
//# sourceMappingURL=useRedwoodGlobalContextSetter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRedwoodGlobalContextSetter.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodGlobalContextSetter.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,6BAA6B,QACpC,MAAM,CAAC,mBAAmB,CAM5B,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setContext } from "@cedarjs/context";
|
|
2
|
-
const
|
|
2
|
+
const useRedwoodGlobalContextSetter = () => ({
|
|
3
3
|
onContextBuilding() {
|
|
4
4
|
return ({ context }) => {
|
|
5
5
|
setContext(context);
|
|
@@ -7,5 +7,5 @@ const useCedarGlobalContextSetter = () => ({
|
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
useRedwoodGlobalContextSetter
|
|
11
11
|
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Plugin } from 'graphql-yoga';
|
|
2
|
+
import type { Logger, LevelWithSilent } from '@cedarjs/api/logger';
|
|
3
|
+
import type { CedarGraphQLContext } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options for request and response information to include in the log statements
|
|
6
|
+
* output by UseRedwoodLogger around the execution event
|
|
7
|
+
*
|
|
8
|
+
* @param level - Sets log level specific to GraphQL log output. Defaults to current logger level.
|
|
9
|
+
* @param data - Include response data sent to client.
|
|
10
|
+
* @param operationName - Include operation name.
|
|
11
|
+
* @param requestId - Include the event's requestId, or if none, generate a uuid as an identifier.
|
|
12
|
+
* @param query - Include the query. This is the query or mutation (with fields) made in the request.
|
|
13
|
+
* @param tracing - Include the tracing and timing information.
|
|
14
|
+
* @param userAgent - Include the browser (or client's) user agent.
|
|
15
|
+
* @param excludeOperations - Exclude the specified operations from being logged.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
type GraphQLLoggerOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Sets log level for GraphQL logging.
|
|
21
|
+
* This level setting can be different from the one used in api side logging.
|
|
22
|
+
* Defaults to the same level as the logger unless set here.
|
|
23
|
+
*
|
|
24
|
+
* Available log levels:
|
|
25
|
+
*
|
|
26
|
+
* - 'fatal'
|
|
27
|
+
* - 'error'
|
|
28
|
+
* - 'warn'
|
|
29
|
+
* - 'info'
|
|
30
|
+
* - 'debug'
|
|
31
|
+
* - 'trace'
|
|
32
|
+
* - 'silent'
|
|
33
|
+
*
|
|
34
|
+
* The logging level is a __minimum__ level. For instance if `logger.level` is `'info'` then all `'fatal'`, `'error'`, `'warn'`,
|
|
35
|
+
* and `'info'` logs will be enabled.
|
|
36
|
+
*
|
|
37
|
+
* You can pass `'silent'` to disable logging.
|
|
38
|
+
*
|
|
39
|
+
* @default level of the logger set in LoggerConfig
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
level?: LevelWithSilent | string;
|
|
43
|
+
/**
|
|
44
|
+
* @description Include response data sent to client.
|
|
45
|
+
*/
|
|
46
|
+
data?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* @description Include operation name.
|
|
49
|
+
*
|
|
50
|
+
* The operation name is a meaningful and explicit name for your operation. It is only required in multi-operation documents,
|
|
51
|
+
* but its use is encouraged because it is very helpful for debugging and server-side logging.
|
|
52
|
+
* When something goes wrong (you see errors either in your network logs, or in the logs of your GraphQL server)
|
|
53
|
+
* it is easier to identify a query in your codebase by name instead of trying to decipher the contents.
|
|
54
|
+
* Think of this just like a function name in your favorite programming language.
|
|
55
|
+
*
|
|
56
|
+
* @see https://graphql.org/learn/queries/#operation-name
|
|
57
|
+
*/
|
|
58
|
+
operationName?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @description Include the event's requestId, or if none, generate a uuid as an identifier.
|
|
61
|
+
*
|
|
62
|
+
* The requestId can be helpful when contacting your deployment provider to resolve issues when encountering errors or unexpected behavior.
|
|
63
|
+
*/
|
|
64
|
+
requestId?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* @description Include the query. This is the query or mutation (with fields) made in the request.
|
|
67
|
+
*/
|
|
68
|
+
query?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* @description Include the tracing and timing information.
|
|
71
|
+
*
|
|
72
|
+
* This will log various performance timings within the GraphQL event lifecycle (parsing, validating, executing, etc).
|
|
73
|
+
*/
|
|
74
|
+
tracing?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* @description Include the browser (or client's) user agent.
|
|
77
|
+
*
|
|
78
|
+
* This can be helpful to know what type of client made the request to resolve issues when encountering errors or unexpected behavior.
|
|
79
|
+
*/
|
|
80
|
+
userAgent?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* @description Exclude operation from the log output.
|
|
83
|
+
*
|
|
84
|
+
* This is useful when you want to filter out certain operations from the log output.
|
|
85
|
+
* For example `IntrospectionQuery` from GraphQL playground.
|
|
86
|
+
*/
|
|
87
|
+
excludeOperations?: string[];
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Configure the logger used by the GraphQL server.
|
|
91
|
+
*
|
|
92
|
+
* @param logger your logger
|
|
93
|
+
* @param options the GraphQLLoggerOptions such as tracing, operationName, etc
|
|
94
|
+
*/
|
|
95
|
+
export type LoggerConfig = {
|
|
96
|
+
logger: Logger;
|
|
97
|
+
options?: GraphQLLoggerOptions;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* This plugin logs every time an operation is being executed and
|
|
101
|
+
* when the execution of the operation is done.
|
|
102
|
+
*
|
|
103
|
+
* It adds information using a child logger from the context
|
|
104
|
+
* such as the operation name, request id, errors, and header info
|
|
105
|
+
* to help trace and diagnose issues.
|
|
106
|
+
*
|
|
107
|
+
* Tracing and timing information can be enabled via the
|
|
108
|
+
* GraphQLHandlerOptions traction option.
|
|
109
|
+
*
|
|
110
|
+
* @see https://www.envelop.dev/docs/plugins/lifecycle
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
export declare const useRedwoodLogger: (loggerConfig: LoggerConfig) => Plugin<CedarGraphQLContext>;
|
|
114
|
+
export {};
|
|
115
|
+
//# sourceMappingURL=useRedwoodLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRedwoodLogger.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodLogger.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,gBAAgB,GAC3B,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 useRedwoodLogger = (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 useCedarLogger = (loggerConfig) => {
|
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
130
|
export {
|
|
131
|
-
|
|
131
|
+
useRedwoodLogger
|
|
132
132
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Plugin } from '@envelop/core';
|
|
2
|
+
import * as opentelemetry from '@opentelemetry/api';
|
|
3
|
+
import type { RedwoodOpenTelemetryConfig } from '../types.js';
|
|
4
|
+
export declare enum AttributeName {
|
|
5
|
+
EXECUTION_ERROR = "graphql.execute.error",
|
|
6
|
+
EXECUTION_RESULT = "graphql.execute.result",
|
|
7
|
+
RESOLVER_EXCEPTION = "graphql.resolver.exception",
|
|
8
|
+
RESOLVER_FIELD_NAME = "graphql.resolver.fieldName",
|
|
9
|
+
RESOLVER_TYPE_NAME = "graphql.resolver.typeName",
|
|
10
|
+
RESOLVER_RESULT_TYPE = "graphql.resolver.resultType",
|
|
11
|
+
RESOLVER_ARGS = "graphql.resolver.args",
|
|
12
|
+
EXECUTION_OPERATION_NAME = "graphql.execute.operationName",
|
|
13
|
+
EXECUTION_OPERATION_DOCUMENT = "graphql.execute.document",
|
|
14
|
+
EXECUTION_VARIABLES = "graphql.execute.variables"
|
|
15
|
+
}
|
|
16
|
+
declare const tracingSpanSymbol = "OPEN_TELEMETRY_GRAPHQL";
|
|
17
|
+
type PluginContext = {
|
|
18
|
+
[tracingSpanSymbol]: opentelemetry.Span;
|
|
19
|
+
};
|
|
20
|
+
export declare const useRedwoodOpenTelemetry: (options: RedwoodOpenTelemetryConfig) => Plugin<PluginContext>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=useRedwoodOpenTelemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRedwoodOpenTelemetry.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodOpenTelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,eAAe,CAAA;AAKhE,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAGnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAE7D,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,uBAAuB,GAClC,SAAS,0BAA0B,KAClC,MAAM,CAAC,aAAa,CAgHtB,CAAA"}
|