@envelop/prometheus
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
import { Plugin } from '@envelop/types'; | ||
import { Plugin } from '@envelop/core'; | ||
import { createHistogram, createCounter, FillLabelsFnParams, createSummary } from './utils'; | ||
@@ -3,0 +3,0 @@ import { PrometheusTracingPluginConfig } from './config'; |
30
index.js
@@ -5,17 +5,6 @@ 'use strict'; | ||
const core = require('@envelop/core'); | ||
const graphql = require('graphql'); | ||
const promClient = require('prom-client'); | ||
const graphql = require('graphql'); | ||
/** | ||
* Returns true if the provided object implements the AsyncIterator protocol via | ||
* implementing a `Symbol.asyncIterator` method. | ||
* | ||
* Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts | ||
*/ | ||
function isAsyncIterable(maybeAsyncIterable) { | ||
return (maybeAsyncIterable != null && | ||
typeof maybeAsyncIterable === 'object' && | ||
typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function'); | ||
} | ||
function shouldTraceFieldResolver(info, whitelist) { | ||
@@ -93,13 +82,2 @@ if (!whitelist) { | ||
/** | ||
* This enum is used only internally in order to create nominal type for the disabled plugin | ||
*/ | ||
var EnableIfBranded; | ||
(function (EnableIfBranded) { | ||
EnableIfBranded[EnableIfBranded["DisabledPlugin"] = 0] = "DisabledPlugin"; | ||
})(EnableIfBranded || (EnableIfBranded = {})); | ||
function isIntrospectionOperationString(operation) { | ||
return (typeof operation === 'string' ? operation : operation.body).indexOf('__schema') !== -1; | ||
} | ||
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */ | ||
@@ -227,3 +205,3 @@ const promPluginContext = Symbol('promPluginContext'); | ||
const onParse = ({ context, extendContext, params }) => { | ||
if (config.skipIntrospection && isIntrospectionOperationString(params.source)) { | ||
if (config.skipIntrospection && core.isIntrospectionOperationString(params.source)) { | ||
return; | ||
@@ -309,3 +287,3 @@ } | ||
} | ||
if (errorsCounter && !isAsyncIterable(result) && result.errors && result.errors.length > 0) { | ||
if (errorsCounter && !core.isAsyncIterable(result) && result.errors && result.errors.length > 0) { | ||
for (const error of result.errors) { | ||
@@ -312,0 +290,0 @@ errorsCounter.counter |
{ | ||
"name": "@envelop/prometheus", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"sideEffects": false, | ||
"peerDependencies": { | ||
"@envelop/core": "^1.6.1", | ||
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0", | ||
@@ -7,0 +8,0 @@ "prom-client": "^13 || ^14.0.0" |
import { GraphQLError, DocumentNode, OperationDefinitionNode, GraphQLResolveInfo, TypeInfo, ASTNode } from 'graphql'; | ||
import { AfterParseEventPayload } from '@envelop/types'; | ||
import { AfterParseEventPayload } from '@envelop/core'; | ||
import { PrometheusTracingPluginConfig } from './config'; | ||
@@ -4,0 +4,0 @@ import { Counter, Histogram, Summary } from 'prom-client'; |
Sorry, the diff of this file is not supported yet
38315
-4.01%3
50%719
-5.27%