@envelop/core
Advanced tools
Comparing version 0.4.0-alpha-83ddba8.0 to 0.4.0-alpha-f2ae2b7.0
30
index.js
@@ -517,2 +517,3 @@ 'use strict'; | ||
const envelopIsIntrospectionSymbol = Symbol('ENVELOP_IS_INTROSPECTION'); | ||
function isOperationDefinition(def) { | ||
@@ -563,3 +564,13 @@ return def.kind === graphql.Kind.OPERATION_DEFINITION; | ||
return { | ||
onParse({ extendContext, params }) { | ||
if (options.skipIntrospection && isIntrospectionOperationString(params.source)) { | ||
extendContext({ | ||
[envelopIsIntrospectionSymbol]: true, | ||
}); | ||
} | ||
}, | ||
onExecute({ args }) { | ||
if (args.contextValue[envelopIsIntrospectionSymbol]) { | ||
return; | ||
} | ||
options.logFn('execute-start', { args }); | ||
@@ -573,2 +584,5 @@ return { | ||
onSubscribe({ args }) { | ||
if (args.contextValue[envelopIsIntrospectionSymbol]) { | ||
return; | ||
} | ||
options.logFn('subscribe-start', { args }); | ||
@@ -586,3 +600,2 @@ return { | ||
const NS_TO_MS$1 = 1e6; | ||
const ignoreTimingSymbol = Symbol('ENVELOP_USE_TIMING_PLUGIN_IGNORE'); | ||
const DEFAULT_OPTIONS$1 = { | ||
@@ -614,3 +627,3 @@ onExecutionMeasurement: (args, timing) => console.log(`Operation execution "${args.operationName}" done in ${timing.ms}ms`), | ||
result.onContextBuilding = ({ context }) => { | ||
if (context[ignoreTimingSymbol]) { | ||
if (context[envelopIsIntrospectionSymbol]) { | ||
return; | ||
@@ -628,3 +641,3 @@ } | ||
extendContext({ | ||
[ignoreTimingSymbol]: true, | ||
[envelopIsIntrospectionSymbol]: true, | ||
}); | ||
@@ -641,3 +654,3 @@ return; | ||
result.onValidate = ({ params, context }) => { | ||
if (context[ignoreTimingSymbol]) { | ||
if (context[envelopIsIntrospectionSymbol]) { | ||
return; | ||
@@ -654,3 +667,3 @@ } | ||
result.onExecute = ({ args }) => { | ||
if (args.contextValue[ignoreTimingSymbol]) { | ||
if (args.contextValue[envelopIsIntrospectionSymbol]) { | ||
return; | ||
@@ -674,3 +687,3 @@ } | ||
result.onExecute = ({ args }) => { | ||
if (args.contextValue[ignoreTimingSymbol]) { | ||
if (args.contextValue[envelopIsIntrospectionSymbol]) { | ||
return; | ||
@@ -690,3 +703,3 @@ } | ||
result.onSubscribe = ({ args }) => { | ||
if (args.contextValue[ignoreTimingSymbol]) { | ||
if (args.contextValue[envelopIsIntrospectionSymbol]) { | ||
return; | ||
@@ -710,3 +723,3 @@ } | ||
result.onSubscribe = ({ args }) => { | ||
if (args.contextValue[ignoreTimingSymbol]) { | ||
if (args.contextValue[envelopIsIntrospectionSymbol]) { | ||
return; | ||
@@ -803,2 +816,3 @@ } | ||
exports.envelop = envelop; | ||
exports.envelopIsIntrospectionSymbol = envelopIsIntrospectionSymbol; | ||
exports.formatError = formatError; | ||
@@ -805,0 +819,0 @@ exports.isIntrospectionDocument = isIntrospectionDocument; |
{ | ||
"name": "@envelop/core", | ||
"version": "0.4.0-alpha-83ddba8.0", | ||
"version": "0.4.0-alpha-f2ae2b7.0", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
import { Plugin } from '@envelop/types'; | ||
import { envelopIsIntrospectionSymbol } from '..'; | ||
declare type LoggerPluginOptions = { | ||
logFn: typeof console.log; | ||
skipIntrospection?: boolean; | ||
}; | ||
export declare const useLogger: (rawOptions?: LoggerPluginOptions) => Plugin; | ||
declare type InternalPluginContext = { | ||
[envelopIsIntrospectionSymbol]?: true; | ||
}; | ||
export declare const useLogger: (rawOptions?: LoggerPluginOptions) => Plugin<InternalPluginContext>; | ||
export {}; |
import { Plugin } from '@envelop/types'; | ||
import { DocumentNode, ExecutionArgs, GraphQLResolveInfo, Source, SubscriptionArgs } from 'graphql'; | ||
import { envelopIsIntrospectionSymbol } from '..'; | ||
export declare type ResultTiming = { | ||
@@ -7,3 +8,2 @@ ms: number; | ||
}; | ||
declare const ignoreTimingSymbol: unique symbol; | ||
export declare type TimingPluginOptions = { | ||
@@ -19,5 +19,5 @@ skipIntrospection?: boolean; | ||
declare type InternalPluginContext = { | ||
[ignoreTimingSymbol]?: true; | ||
[envelopIsIntrospectionSymbol]?: true; | ||
}; | ||
export declare const useTiming: (rawOptions?: TimingPluginOptions | undefined) => Plugin<InternalPluginContext>; | ||
export {}; |
import { ASTNode, DocumentNode, OperationDefinitionNode, Source } from 'graphql'; | ||
export declare const envelopIsIntrospectionSymbol: unique symbol; | ||
export declare function isOperationDefinition(def: ASTNode): def is OperationDefinitionNode; | ||
@@ -3,0 +4,0 @@ export declare function isIntrospectionOperation(operation: OperationDefinitionNode): boolean; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186334
1684