apollo-server-errors
Advanced tools
Comparing version 3.0.0-alpha.3 to 3.0.0-alpha.4
@@ -1,11 +0,11 @@ | ||
import { GraphQLError, GraphQLFormattedError } from 'graphql'; | ||
import { ASTNode, GraphQLError, GraphQLFormattedError, Source, SourceLocation } from 'graphql'; | ||
export declare class ApolloError extends Error implements GraphQLError { | ||
extensions: Record<string, any>; | ||
readonly name: any; | ||
readonly locations: any; | ||
readonly path: any; | ||
readonly source: any; | ||
readonly positions: any; | ||
readonly nodes: any; | ||
originalError: any; | ||
readonly name: string; | ||
readonly locations: ReadonlyArray<SourceLocation> | undefined; | ||
readonly path: ReadonlyArray<string | number> | undefined; | ||
readonly source: Source | undefined; | ||
readonly positions: ReadonlyArray<number> | undefined; | ||
readonly nodes: ReadonlyArray<ASTNode> | undefined; | ||
originalError: Error | null | undefined; | ||
[key: string]: any; | ||
@@ -21,3 +21,3 @@ constructor(message: string, code?: string, extensions?: Record<string, any>); | ||
code?: string; | ||
errorClass?: typeof ApolloError; | ||
errorClass?: new (message: string) => ApolloError; | ||
} | ||
@@ -24,0 +24,0 @@ export declare function fromGraphQLError(error: GraphQLError, options?: ErrorOptions): ApolloError; |
@@ -90,4 +90,4 @@ "use strict"; | ||
: new ApolloError(error.message); | ||
Object.keys(error).forEach(key => { | ||
copy[key] = error[key]; | ||
Object.entries(error).forEach(([key, value]) => { | ||
copy[key] = value; | ||
}); | ||
@@ -167,3 +167,3 @@ copy.extensions = { | ||
const enrichedErrors = errors.map(error => enrichError(error, debug)); | ||
const makePrintable = error => { | ||
const makePrintable = (error) => { | ||
if (error instanceof Error) { | ||
@@ -170,0 +170,0 @@ const graphQLError = error; |
{ | ||
"name": "apollo-server-errors", | ||
"version": "3.0.0-alpha.3", | ||
"version": "3.0.0-alpha.4", | ||
"author": "Apollo <opensource@apollographql.com>", | ||
@@ -18,3 +18,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=12.0 <15.0" | ||
"node": ">=12.0" | ||
}, | ||
@@ -24,3 +24,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "15b90eec22523e32e00d97a51b28cbfba3f39c78" | ||
"gitHead": "97073f33d30f2d682655eb0e4dce1d7d43721807" | ||
} |
@@ -1,12 +0,12 @@ | ||
import { GraphQLError, GraphQLFormattedError } from 'graphql'; | ||
import { ASTNode, GraphQLError, GraphQLFormattedError, Source, SourceLocation } from 'graphql'; | ||
export class ApolloError extends Error implements GraphQLError { | ||
public extensions: Record<string, any>; | ||
readonly name; | ||
readonly locations; | ||
readonly path; | ||
readonly source; | ||
readonly positions; | ||
readonly nodes; | ||
public originalError; | ||
readonly name!: string; | ||
readonly locations: ReadonlyArray<SourceLocation> | undefined; | ||
readonly path: ReadonlyArray<string | number> | undefined; | ||
readonly source: Source | undefined; | ||
readonly positions: ReadonlyArray<number> | undefined; | ||
readonly nodes: ReadonlyArray<ASTNode> | undefined; | ||
public originalError: Error | null | undefined; | ||
@@ -137,3 +137,5 @@ [key: string]: any; | ||
code?: string; | ||
errorClass?: typeof ApolloError; | ||
// This declaration means it takes any "class" that has a constructor that | ||
// takes a single string, and should be invoked via the `new` operator. | ||
errorClass?: new (message: string) => ApolloError; | ||
} | ||
@@ -148,4 +150,4 @@ | ||
// copy enumerable keys | ||
Object.keys(error).forEach(key => { | ||
copy[key] = error[key]; | ||
Object.entries(error).forEach(([key, value]) => { | ||
copy[key] = value; | ||
}); | ||
@@ -168,3 +170,3 @@ | ||
Object.getOwnPropertyNames(error).forEach(key => { | ||
Object.defineProperty(copy.originalError, key, { value: error[key] }); | ||
Object.defineProperty(copy.originalError, key, { value: (error as any)[key] }); | ||
}); | ||
@@ -268,3 +270,3 @@ | ||
const enrichedErrors = errors.map(error => enrichError(error, debug)); | ||
const makePrintable = error => { | ||
const makePrintable = (error: GraphQLFormattedError) => { | ||
if (error instanceof Error) { | ||
@@ -271,0 +273,0 @@ // Error defines its `message` and other fields as non-enumerable, meaning JSON.stringigfy does not print them. |
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
294512
10
571