@cedarjs/graphql-server 0.5.1-next.0 → 0.6.0

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.
@@ -1,10 +1,9 @@
1
1
  import type { Plugin } from 'graphql-yoga';
2
2
  import type { RedwoodGraphQLContext } from '../types';
3
3
  /**
4
- * This Envelop plugin waits until the GraphQL context is done building and sets the
5
- * Redwood global context which can be imported with:
6
- * // import { context } from '@cedarjs/graphql-server'
7
- * @returns
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'`
8
7
  */
9
8
  export declare const useRedwoodGlobalContextSetter: () => Plugin<RedwoodGraphQLContext>;
10
9
  //# sourceMappingURL=useRedwoodGlobalContextSetter.d.ts.map
@@ -1 +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,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,QACpC,MAAM,CAAC,qBAAqB,CAM9B,CAAA"}
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,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,QACpC,MAAM,CAAC,qBAAqB,CAM9B,CAAA"}
@@ -24,8 +24,8 @@ module.exports = __toCommonJS(useRedwoodGlobalContextSetter_exports);
24
24
  var import_context = require("@cedarjs/context");
25
25
  const useRedwoodGlobalContextSetter = () => ({
26
26
  onContextBuilding() {
27
- return ({ context: redwoodGraphqlContext }) => {
28
- (0, import_context.setContext)(redwoodGraphqlContext);
27
+ return ({ context }) => {
28
+ (0, import_context.setContext)(context);
29
29
  };
30
30
  }
31
31
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useRedwoodTrustedDocuments.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodTrustedDocuments.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,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC9C,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;AAgCH,eAAO,MAAM,0BAA0B,YAC5B,6BAA6B,KACrC,MAAM,CAAC,qBAAqB,CA2B9B,CAAA"}
1
+ {"version":3,"file":"useRedwoodTrustedDocuments.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodTrustedDocuments.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,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC9C,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;AAoEH,eAAO,MAAM,0BAA0B,YAC5B,6BAA6B,KACrC,MAAM,CAAC,qBAAqB,CA8B9B,CAAA"}
@@ -23,6 +23,8 @@ __export(useRedwoodTrustedDocuments_exports, {
23
23
  module.exports = __toCommonJS(useRedwoodTrustedDocuments_exports);
24
24
  var import_plugin_persisted_operations = require("@graphql-yoga/plugin-persisted-operations");
25
25
  const REDWOOD__AUTH_GET_CURRENT_USER_QUERY = '{"query":"query __REDWOOD__AUTH_GET_CURRENT_USER { redwood { currentUser } }"}';
26
+ const CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION = '{"query":"mutation { resyncMailRenderers }"}';
27
+ const CEDAR__STUDIO_TEMPLATE_MUTATION = '{"query":"mutation { resyncMailTemplate }"}';
26
28
  const allowRedwoodAuthCurrentUserQuery = async (request) => {
27
29
  const headers = request.headers;
28
30
  const hasContentType = headers.get("content-type") === "application/json";
@@ -33,6 +35,17 @@ const allowRedwoodAuthCurrentUserQuery = async (request) => {
33
35
  const hasAllowedQuery = query === REDWOOD__AUTH_GET_CURRENT_USER_QUERY;
34
36
  return hasAllowedHeaders && hasAllowedQuery;
35
37
  };
38
+ const allowCedarStudioResyncMailMutations = async (request) => {
39
+ const isLocalDevelopment = process.env.NODE_ENV === "development";
40
+ if (!isLocalDevelopment) {
41
+ return false;
42
+ }
43
+ const headers = request.headers;
44
+ const hasContentType = headers.get("content-type") === "application/json";
45
+ const query = await request.text();
46
+ const isAllowedQuery = query === CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION || query === CEDAR__STUDIO_TEMPLATE_MUTATION;
47
+ return hasContentType && isAllowedQuery;
48
+ };
36
49
  const useRedwoodTrustedDocuments = (options) => {
37
50
  return (0, import_plugin_persisted_operations.usePersistedOperations)({
38
51
  ...options,
@@ -57,7 +70,7 @@ const useRedwoodTrustedDocuments = (options) => {
57
70
  }
58
71
  }
59
72
  }
60
- return allowRedwoodAuthCurrentUserQuery(request);
73
+ return allowRedwoodAuthCurrentUserQuery(request) || allowCedarStudioResyncMailMutations(request);
61
74
  }
62
75
  });
63
76
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/graphql-server",
3
- "version": "0.5.1-next.0+9c48e99f3",
3
+ "version": "0.6.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@babel/runtime-corejs3": "7.27.6",
26
- "@cedarjs/api": "0.5.1-next.0+9c48e99f3",
27
- "@cedarjs/context": "0.5.1-next.0+9c48e99f3",
26
+ "@cedarjs/api": "0.6.0",
27
+ "@cedarjs/context": "0.6.0",
28
28
  "@envelop/core": "5.0.2",
29
29
  "@envelop/depth-limit": "4.0.0",
30
30
  "@envelop/disable-introspection": "6.0.0",
@@ -47,11 +47,11 @@
47
47
  "devDependencies": {
48
48
  "@babel/cli": "7.27.2",
49
49
  "@babel/core": "^7.26.10",
50
- "@cedarjs/framework-tools": "0.5.1-next.1",
51
- "@cedarjs/project-config": "0.5.1-next.0+9c48e99f3",
52
- "@cedarjs/realtime": "0.5.1-next.0+9c48e99f3",
50
+ "@cedarjs/framework-tools": "0.6.0",
51
+ "@cedarjs/project-config": "0.6.0",
52
+ "@cedarjs/realtime": "0.6.0",
53
53
  "@envelop/types": "5.0.0",
54
- "@types/aws-lambda": "8.10.145",
54
+ "@types/aws-lambda": "8.10.152",
55
55
  "@types/jsonwebtoken": "9.0.10",
56
56
  "@types/lodash": "4.17.20",
57
57
  "@types/uuid": "10.0.0",
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "9c48e99f37468ae011bc39c5d405044ccef0e77c"
68
+ "gitHead": "dbb79eb24110276fc52803bb3874acd62b76f7c8"
69
69
  }