@envelop/core 2.1.1-alpha-698c9eb.0 → 2.1.1-alpha-60d043b.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.
package/index.js CHANGED
@@ -1199,12 +1199,15 @@ const useMaskedErrors = (opts) => {
1199
1199
  };
1200
1200
  };
1201
1201
 
1202
- const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => () => {
1202
+ const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => ctx => {
1203
+ const rootQueryType = ctx.getSchema().getQueryType();
1203
1204
  return {
1204
1205
  Field(field) {
1205
- if (!field.name.value.startsWith('__')) {
1206
+ if (ctx.getParentType() === rootQueryType && !field.name.value.startsWith('__')) {
1206
1207
  onNonIntrospectionField();
1208
+ return graphql.BREAK;
1207
1209
  }
1210
+ return undefined;
1208
1211
  },
1209
1212
  };
1210
1213
  };
package/index.mjs CHANGED
@@ -1195,12 +1195,15 @@ const useMaskedErrors = (opts) => {
1195
1195
  };
1196
1196
  };
1197
1197
 
1198
- const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => () => {
1198
+ const OnNonIntrospectionFieldReachedValidationRule = (onNonIntrospectionField) => ctx => {
1199
+ const rootQueryType = ctx.getSchema().getQueryType();
1199
1200
  return {
1200
1201
  Field(field) {
1201
- if (!field.name.value.startsWith('__')) {
1202
+ if (ctx.getParentType() === rootQueryType && !field.name.value.startsWith('__')) {
1202
1203
  onNonIntrospectionField();
1204
+ return BREAK;
1203
1205
  }
1206
+ return undefined;
1204
1207
  },
1205
1208
  };
1206
1209
  };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@envelop/core",
3
- "version": "2.1.1-alpha-698c9eb.0",
3
+ "version": "2.1.1-alpha-60d043b.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.0.1-alpha-698c9eb.0"
9
+ "@envelop/types": "2.0.0"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
@@ -1,4 +1,4 @@
1
1
  import { Plugin, DefaultContext } from '@envelop/types';
2
2
  import { GraphQLError } from 'graphql';
3
3
  export declare type ErrorHandler = (errors: readonly GraphQLError[], context: Readonly<DefaultContext>) => void;
4
- export declare const useErrorHandler: <ContextType>(errorHandler: ErrorHandler) => Plugin<ContextType, ContextType>;
4
+ export declare const useErrorHandler: <ContextType>(errorHandler: ErrorHandler) => Plugin<ContextType>;
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from '@envelop/types';
2
2
  export declare type ContextFactoryFn<TResult = unknown, TCurrent = unknown> = (currentContext: TCurrent) => TResult | Promise<TResult>;
3
3
  declare type UnwrapAsync<T> = T extends Promise<infer U> ? U : T;
4
- export declare const useExtendContext: <TContextFactory extends (...args: any[]) => any>(contextFactory: TContextFactory) => Plugin<UnwrapAsync<ReturnType<TContextFactory>>, UnwrapAsync<ReturnType<TContextFactory>>>;
4
+ export declare const useExtendContext: <TContextFactory extends (...args: any[]) => any>(contextFactory: TContextFactory) => Plugin<UnwrapAsync<ReturnType<TContextFactory>>>;
5
5
  export {};
package/utils.d.ts CHANGED
@@ -28,6 +28,6 @@ export declare function isAsyncIterable<TType>(maybeAsyncIterable: unknown): may
28
28
  * @param fn The handler to be executed on each result
29
29
  * @returns a subscription for streamed results, or undefined in case of an non-async
30
30
  */
31
- export declare function handleStreamOrSingleExecutionResult<TInputContext = DefaultContext, TOutputContext = TInputContext>(payload: OnExecuteDoneEventPayload<TInputContext, TOutputContext>, fn: OnExecuteDoneHookResultOnNextHook<TInputContext, TOutputContext>): void | OnExecuteDoneHookResult<TInputContext, TOutputContext>;
31
+ export declare function handleStreamOrSingleExecutionResult<ContextType = DefaultContext>(payload: OnExecuteDoneEventPayload<ContextType>, fn: OnExecuteDoneHookResultOnNextHook<ContextType>): void | OnExecuteDoneHookResult<ContextType>;
32
32
  export declare function finalAsyncIterator<TInput>(source: AsyncIterable<TInput>, onFinal: () => void): AsyncGenerator<TInput>;
33
33
  export declare function errorAsyncIterator<TInput>(source: AsyncIterable<TInput>, onError: (err: unknown) => void): AsyncGenerator<TInput>;