@envelop/core 2.2.0-alpha-4f3adf1.0 → 2.3.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.
Files changed (3) hide show
  1. package/index.js +8 -3
  2. package/index.mjs +8 -3
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -486,8 +486,9 @@ function createEnvelopOrchestrator(plugins) {
486
486
  const customContextFactory = beforeCallbacks.context.length
487
487
  ? initialContext => async (orchestratorCtx) => {
488
488
  const afterCalls = [];
489
+ // In order to have access to the "last working" context object we keep this outside of the try block:
490
+ let context = orchestratorCtx ? { ...initialContext, ...orchestratorCtx } : initialContext;
489
491
  try {
490
- let context = orchestratorCtx ? { ...initialContext, ...orchestratorCtx } : initialContext;
491
492
  let isBreakingContextBuilding = false;
492
493
  for (const onContext of beforeCallbacks.context) {
493
494
  const afterHookResult = await onContext({
@@ -520,6 +521,7 @@ function createEnvelopOrchestrator(plugins) {
520
521
  let error = err;
521
522
  for (const errorCb of contextErrorHandlers) {
522
523
  errorCb({
524
+ context,
523
525
  error,
524
526
  setError: err => {
525
527
  error = err;
@@ -1225,12 +1227,15 @@ const useMaskedErrors = (opts) => {
1225
1227
  };
1226
1228
  };
1227
1229
 
1228
- const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => () => {
1230
+ const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => ctx => {
1231
+ const rootQueryType = ctx.getSchema().getQueryType();
1229
1232
  return {
1230
1233
  Field(field) {
1231
- if (!field.name.value.startsWith('__')) {
1234
+ if (ctx.getParentType() === rootQueryType && !field.name.value.startsWith('__')) {
1232
1235
  onNonIntrospectionField();
1236
+ return graphql.BREAK;
1233
1237
  }
1238
+ return undefined;
1234
1239
  },
1235
1240
  };
1236
1241
  };
package/index.mjs CHANGED
@@ -482,8 +482,9 @@ function createEnvelopOrchestrator(plugins) {
482
482
  const customContextFactory = beforeCallbacks.context.length
483
483
  ? initialContext => async (orchestratorCtx) => {
484
484
  const afterCalls = [];
485
+ // In order to have access to the "last working" context object we keep this outside of the try block:
486
+ let context = orchestratorCtx ? { ...initialContext, ...orchestratorCtx } : initialContext;
485
487
  try {
486
- let context = orchestratorCtx ? { ...initialContext, ...orchestratorCtx } : initialContext;
487
488
  let isBreakingContextBuilding = false;
488
489
  for (const onContext of beforeCallbacks.context) {
489
490
  const afterHookResult = await onContext({
@@ -516,6 +517,7 @@ function createEnvelopOrchestrator(plugins) {
516
517
  let error = err;
517
518
  for (const errorCb of contextErrorHandlers) {
518
519
  errorCb({
520
+ context,
519
521
  error,
520
522
  setError: err => {
521
523
  error = err;
@@ -1221,12 +1223,15 @@ const useMaskedErrors = (opts) => {
1221
1223
  };
1222
1224
  };
1223
1225
 
1224
- const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => () => {
1226
+ const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => ctx => {
1227
+ const rootQueryType = ctx.getSchema().getQueryType();
1225
1228
  return {
1226
1229
  Field(field) {
1227
- if (!field.name.value.startsWith('__')) {
1230
+ if (ctx.getParentType() === rootQueryType && !field.name.value.startsWith('__')) {
1228
1231
  onNonIntrospectionField();
1232
+ return BREAK;
1229
1233
  }
1234
+ return undefined;
1230
1235
  },
1231
1236
  };
1232
1237
  };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@envelop/core",
3
- "version": "2.2.0-alpha-4f3adf1.0",
3
+ "version": "2.3.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
7
7
  },
8
8
  "dependencies": {
9
- "@envelop/types": "2.1.0-alpha-4f3adf1.0"
9
+ "@envelop/types": "2.2.0"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",