@envelop/core 2.2.0-alpha-8667975.0 → 2.3.1
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/index.js +14 -3
- package/index.mjs +14 -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,21 @@ const useMaskedErrors = (opts) => {
|
|
|
1225
1227
|
};
|
|
1226
1228
|
};
|
|
1227
1229
|
|
|
1228
|
-
const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) =>
|
|
1230
|
+
const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => ctx => {
|
|
1231
|
+
const rootQueryType = ctx.getSchema().getQueryType();
|
|
1232
|
+
const rootMutationType = ctx.getSchema().getMutationType();
|
|
1233
|
+
const rootSubscriptionType = ctx.getSchema().getSubscriptionType();
|
|
1229
1234
|
return {
|
|
1230
1235
|
Field(field) {
|
|
1231
|
-
|
|
1236
|
+
const parentType = ctx.getParentType();
|
|
1237
|
+
const isQuery = parentType === rootQueryType;
|
|
1238
|
+
const isMutation = parentType === rootMutationType;
|
|
1239
|
+
const isSubscription = parentType === rootSubscriptionType;
|
|
1240
|
+
if ((isQuery && !field.name.value.startsWith('__')) || isMutation || isSubscription) {
|
|
1232
1241
|
onNonIntrospectionField();
|
|
1242
|
+
return graphql.BREAK;
|
|
1233
1243
|
}
|
|
1244
|
+
return undefined;
|
|
1234
1245
|
},
|
|
1235
1246
|
};
|
|
1236
1247
|
};
|
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,21 @@ const useMaskedErrors = (opts) => {
|
|
|
1221
1223
|
};
|
|
1222
1224
|
};
|
|
1223
1225
|
|
|
1224
|
-
const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) =>
|
|
1226
|
+
const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => ctx => {
|
|
1227
|
+
const rootQueryType = ctx.getSchema().getQueryType();
|
|
1228
|
+
const rootMutationType = ctx.getSchema().getMutationType();
|
|
1229
|
+
const rootSubscriptionType = ctx.getSchema().getSubscriptionType();
|
|
1225
1230
|
return {
|
|
1226
1231
|
Field(field) {
|
|
1227
|
-
|
|
1232
|
+
const parentType = ctx.getParentType();
|
|
1233
|
+
const isQuery = parentType === rootQueryType;
|
|
1234
|
+
const isMutation = parentType === rootMutationType;
|
|
1235
|
+
const isSubscription = parentType === rootSubscriptionType;
|
|
1236
|
+
if ((isQuery && !field.name.value.startsWith('__')) || isMutation || isSubscription) {
|
|
1228
1237
|
onNonIntrospectionField();
|
|
1238
|
+
return BREAK;
|
|
1229
1239
|
}
|
|
1240
|
+
return undefined;
|
|
1230
1241
|
},
|
|
1231
1242
|
};
|
|
1232
1243
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
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.
|
|
9
|
+
"@envelop/types": "2.2.0"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|