@apollo/server
Advanced tools
Comparing version 4.9.1 to 4.9.2
@@ -216,4 +216,5 @@ "use strict"; | ||
else if (taggedServerListenersWithRenderLandingPage.length) { | ||
landingPage = await taggedServerListenersWithRenderLandingPage[0] | ||
.serverListener.renderLandingPage(); | ||
landingPage = | ||
await taggedServerListenersWithRenderLandingPage[0].serverListener | ||
.renderLandingPage(); | ||
} | ||
@@ -220,0 +221,0 @@ const toDisposeLast = this.maybeRegisterTerminationSignalHandlers(['SIGINT', 'SIGTERM'], startedInBackground); |
@@ -1,2 +0,2 @@ | ||
export declare const packageVersion = "4.9.1"; | ||
export declare const packageVersion = "4.9.2"; | ||
//# sourceMappingURL=packageVersion.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.packageVersion = void 0; | ||
exports.packageVersion = "4.9.1"; | ||
exports.packageVersion = "4.9.2"; | ||
//# sourceMappingURL=packageVersion.js.map |
@@ -22,3 +22,3 @@ "use strict"; | ||
}, | ||
async requestDidStart({ request: { http }, metrics, logger }) { | ||
async requestDidStart({ request: { http }, metrics }) { | ||
if (!enabled) { | ||
@@ -30,3 +30,2 @@ return; | ||
sendErrors: options.includeErrors, | ||
logger, | ||
}); | ||
@@ -33,0 +32,0 @@ if (http?.headers.get('apollo-federation-include-trace') !== 'ftv1') { |
import { GraphQLError, type GraphQLResolveInfo } from 'graphql'; | ||
import { Trace, google } from '@apollo/usage-reporting-protobuf'; | ||
import type { Logger } from '@apollo/utils.logger'; | ||
import type { SendErrorsOptions } from './usageReporting'; | ||
export declare class TraceTreeBuilder { | ||
private rootNode; | ||
private logger; | ||
trace: Trace; | ||
@@ -15,3 +13,2 @@ startHrTime?: [number, number]; | ||
maskedBy: string; | ||
logger: Logger; | ||
sendErrors?: SendErrorsOptions; | ||
@@ -18,0 +15,0 @@ }); |
@@ -21,3 +21,3 @@ "use strict"; | ||
]); | ||
const { logger, sendErrors, maskedBy } = options; | ||
const { sendErrors, maskedBy } = options; | ||
if (!sendErrors || 'masked' in sendErrors) { | ||
@@ -37,3 +37,2 @@ this.transformError = () => new graphql_1.GraphQLError('<masked>', { | ||
} | ||
this.logger = logger; | ||
} | ||
@@ -106,3 +105,7 @@ startTiming() { | ||
else { | ||
this.logger.warn(`Could not find node with path ${path.join('.')}; defaulting to put errors on root node.`); | ||
const responsePath = responsePathFromArray(path, this.rootNode); | ||
if (!responsePath) { | ||
throw internalError('addProtobufError called with invalid path!'); | ||
} | ||
node = this.newNode(responsePath); | ||
} | ||
@@ -170,2 +173,15 @@ } | ||
} | ||
function responsePathFromArray(path, node) { | ||
let responsePath; | ||
let nodePtr = node; | ||
for (const key of path) { | ||
nodePtr = nodePtr?.child?.find((child) => child.responseName === key); | ||
responsePath = { | ||
key, | ||
prev: responsePath, | ||
typename: nodePtr?.type ?? undefined, | ||
}; | ||
} | ||
return responsePath; | ||
} | ||
function errorToProtobufError(error) { | ||
@@ -172,0 +188,0 @@ return new usage_reporting_protobuf_1.Trace.Error({ |
@@ -229,3 +229,2 @@ "use strict"; | ||
sendErrors: options.sendErrors, | ||
logger, | ||
}); | ||
@@ -252,3 +251,4 @@ treeBuilder.startTiming(); | ||
} | ||
includeOperationInUsageReporting = await options.includeRequest(requestContext); | ||
includeOperationInUsageReporting = | ||
await options.includeRequest(requestContext); | ||
if (typeof includeOperationInUsageReporting !== 'boolean') { | ||
@@ -255,0 +255,0 @@ logger.warn("The 'includeRequest' async predicate function must return a boolean value."); |
@@ -187,4 +187,5 @@ import { isNodeLike } from '@apollo/utils.isnodelike'; | ||
else if (taggedServerListenersWithRenderLandingPage.length) { | ||
landingPage = await taggedServerListenersWithRenderLandingPage[0] | ||
.serverListener.renderLandingPage(); | ||
landingPage = | ||
await taggedServerListenersWithRenderLandingPage[0].serverListener | ||
.renderLandingPage(); | ||
} | ||
@@ -191,0 +192,0 @@ const toDisposeLast = this.maybeRegisterTerminationSignalHandlers(['SIGINT', 'SIGTERM'], startedInBackground); |
@@ -1,2 +0,2 @@ | ||
export declare const packageVersion = "4.9.1"; | ||
export declare const packageVersion = "4.9.2"; | ||
//# sourceMappingURL=packageVersion.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const packageVersion = "4.9.1"; | ||
export const packageVersion = "4.9.2"; | ||
//# sourceMappingURL=packageVersion.js.map |
@@ -19,3 +19,3 @@ import { Trace } from '@apollo/usage-reporting-protobuf'; | ||
}, | ||
async requestDidStart({ request: { http }, metrics, logger }) { | ||
async requestDidStart({ request: { http }, metrics }) { | ||
if (!enabled) { | ||
@@ -27,3 +27,2 @@ return; | ||
sendErrors: options.includeErrors, | ||
logger, | ||
}); | ||
@@ -30,0 +29,0 @@ if (http?.headers.get('apollo-federation-include-trace') !== 'ftv1') { |
import { GraphQLError, type GraphQLResolveInfo } from 'graphql'; | ||
import { Trace, google } from '@apollo/usage-reporting-protobuf'; | ||
import type { Logger } from '@apollo/utils.logger'; | ||
import type { SendErrorsOptions } from './usageReporting'; | ||
export declare class TraceTreeBuilder { | ||
private rootNode; | ||
private logger; | ||
trace: Trace; | ||
@@ -15,3 +13,2 @@ startHrTime?: [number, number]; | ||
maskedBy: string; | ||
logger: Logger; | ||
sendErrors?: SendErrorsOptions; | ||
@@ -18,0 +15,0 @@ }); |
@@ -18,3 +18,3 @@ import { GraphQLError, } from 'graphql'; | ||
]); | ||
const { logger, sendErrors, maskedBy } = options; | ||
const { sendErrors, maskedBy } = options; | ||
if (!sendErrors || 'masked' in sendErrors) { | ||
@@ -34,3 +34,2 @@ this.transformError = () => new GraphQLError('<masked>', { | ||
} | ||
this.logger = logger; | ||
} | ||
@@ -103,3 +102,7 @@ startTiming() { | ||
else { | ||
this.logger.warn(`Could not find node with path ${path.join('.')}; defaulting to put errors on root node.`); | ||
const responsePath = responsePathFromArray(path, this.rootNode); | ||
if (!responsePath) { | ||
throw internalError('addProtobufError called with invalid path!'); | ||
} | ||
node = this.newNode(responsePath); | ||
} | ||
@@ -166,2 +169,15 @@ } | ||
} | ||
function responsePathFromArray(path, node) { | ||
let responsePath; | ||
let nodePtr = node; | ||
for (const key of path) { | ||
nodePtr = nodePtr?.child?.find((child) => child.responseName === key); | ||
responsePath = { | ||
key, | ||
prev: responsePath, | ||
typename: nodePtr?.type ?? undefined, | ||
}; | ||
} | ||
return responsePath; | ||
} | ||
function errorToProtobufError(error) { | ||
@@ -168,0 +184,0 @@ return new Trace.Error({ |
@@ -223,3 +223,2 @@ import { Report, ReportHeader, Trace } from '@apollo/usage-reporting-protobuf'; | ||
sendErrors: options.sendErrors, | ||
logger, | ||
}); | ||
@@ -246,3 +245,4 @@ treeBuilder.startTiming(); | ||
} | ||
includeOperationInUsageReporting = await options.includeRequest(requestContext); | ||
includeOperationInUsageReporting = | ||
await options.includeRequest(requestContext); | ||
if (typeof includeOperationInUsageReporting !== 'boolean') { | ||
@@ -249,0 +249,0 @@ logger.warn("The 'includeRequest' async predicate function must return a boolean value."); |
{ | ||
"name": "@apollo/server", | ||
"version": "4.9.1", | ||
"version": "4.9.2", | ||
"description": "Core engine for Apollo GraphQL server", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -95,2 +95,8 @@ # `@apollo/server` | ||
If using Typescript you may also need to install additional type declaration packages as development dependencies to avoid common errors when importing the above packages (i.e. Could not find a declaration file for module '`cors`'): | ||
``` | ||
npm install --save-dev @types/cors @types/express @types/body-parser | ||
``` | ||
Then, write the following to `server.mjs`. (By using the `.mjs` extension, Node lets you use the `await` keyword at the top level.) | ||
@@ -97,0 +103,0 @@ |
@@ -483,4 +483,5 @@ import { isNodeLike } from '@apollo/utils.isnodelike'; | ||
} else if (taggedServerListenersWithRenderLandingPage.length) { | ||
landingPage = await taggedServerListenersWithRenderLandingPage[0] | ||
.serverListener.renderLandingPage!(); | ||
landingPage = | ||
await taggedServerListenersWithRenderLandingPage[0].serverListener | ||
.renderLandingPage!(); | ||
} | ||
@@ -487,0 +488,0 @@ |
@@ -1,1 +0,1 @@ | ||
export const packageVersion = "4.9.1"; | ||
export const packageVersion = "4.9.2"; |
@@ -69,3 +69,3 @@ import { Trace } from '@apollo/usage-reporting-protobuf'; | ||
}, | ||
async requestDidStart({ request: { http }, metrics, logger }) { | ||
async requestDidStart({ request: { http }, metrics }) { | ||
if (!enabled) { | ||
@@ -78,3 +78,2 @@ return; | ||
sendErrors: options.includeErrors, | ||
logger, | ||
}); | ||
@@ -81,0 +80,0 @@ |
@@ -9,3 +9,2 @@ // This class is a helper for ApolloServerPluginUsageReporting and | ||
import { Trace, google } from '@apollo/usage-reporting-protobuf'; | ||
import type { Logger } from '@apollo/utils.logger'; | ||
import type { SendErrorsOptions } from './usageReporting'; | ||
@@ -20,3 +19,2 @@ import { UnreachableCaseError } from '../utils/UnreachableCaseError.js'; | ||
private rootNode = new Trace.Node(); | ||
private logger: Logger; | ||
public trace = new Trace({ | ||
@@ -44,6 +42,5 @@ root: this.rootNode, | ||
maskedBy: string; | ||
logger: Logger; | ||
sendErrors?: SendErrorsOptions; | ||
}) { | ||
const { logger, sendErrors, maskedBy } = options; | ||
const { sendErrors, maskedBy } = options; | ||
if (!sendErrors || 'masked' in sendErrors) { | ||
@@ -61,3 +58,2 @@ this.transformError = () => | ||
} | ||
this.logger = logger; | ||
} | ||
@@ -163,7 +159,7 @@ | ||
} else { | ||
this.logger.warn( | ||
`Could not find node with path ${path.join( | ||
'.', | ||
)}; defaulting to put errors on root node.`, | ||
); | ||
const responsePath = responsePathFromArray(path, this.rootNode); | ||
if (!responsePath) { | ||
throw internalError('addProtobufError called with invalid path!'); | ||
} | ||
node = this.newNode(responsePath); | ||
} | ||
@@ -288,2 +284,19 @@ } | ||
function responsePathFromArray( | ||
path: ReadonlyArray<string | number>, | ||
node: Trace.Node, | ||
): ResponsePath | undefined { | ||
let responsePath: ResponsePath | undefined; | ||
let nodePtr: Trace.INode | undefined = node; | ||
for (const key of path) { | ||
nodePtr = nodePtr?.child?.find((child) => child.responseName === key); | ||
responsePath = { | ||
key, | ||
prev: responsePath, | ||
typename: nodePtr?.type ?? undefined, | ||
}; | ||
} | ||
return responsePath; | ||
} | ||
function errorToProtobufError(error: GraphQLError): Trace.Error { | ||
@@ -290,0 +303,0 @@ return new Trace.Error({ |
@@ -414,3 +414,2 @@ import { Report, ReportHeader, Trace } from '@apollo/usage-reporting-protobuf'; | ||
sendErrors: options.sendErrors, | ||
logger, | ||
}); | ||
@@ -456,5 +455,4 @@ treeBuilder.startTiming(); | ||
} | ||
includeOperationInUsageReporting = await options.includeRequest( | ||
requestContext, | ||
); | ||
includeOperationInUsageReporting = | ||
await options.includeRequest(requestContext); | ||
@@ -546,5 +544,4 @@ // Help the user understand they've returned an unexpected value, | ||
// subgraph and gateway). | ||
const rawWeight = await fieldLevelInstrumentation( | ||
requestContext, | ||
); | ||
const rawWeight = | ||
await fieldLevelInstrumentation(requestContext); | ||
treeBuilder.trace.fieldExecutionWeight = | ||
@@ -551,0 +548,0 @@ typeof rawWeight === 'number' ? rawWeight : rawWeight ? 1 : 0; |
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
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
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
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
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
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
1818917
31806
154