Comparing version 15.9.0 to 15.10.0
@@ -1,40 +0,1 @@ | ||
import { SourceLocation } from '../language/location'; | ||
import { GraphQLError } from './GraphQLError'; | ||
/** | ||
* Given a GraphQLError, format it according to the rules described by the | ||
* Response Format, Errors section of the GraphQL Specification. | ||
*/ | ||
export function formatError(error: GraphQLError): GraphQLFormattedError; | ||
/** | ||
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors | ||
*/ | ||
export interface GraphQLFormattedError< | ||
TExtensions extends Record<string, any> = Record<string, any> | ||
> { | ||
/** | ||
* A short, human-readable summary of the problem that **SHOULD NOT** change | ||
* from occurrence to occurrence of the problem, except for purposes of | ||
* localization. | ||
*/ | ||
readonly message: string; | ||
/** | ||
* If an error can be associated to a particular point in the requested | ||
* GraphQL document, it should contain a list of locations. | ||
*/ | ||
readonly locations?: ReadonlyArray<SourceLocation>; | ||
/** | ||
* If an error can be associated to a particular field in the GraphQL result, | ||
* it _must_ contain an entry with the key `path` that details the path of | ||
* the response field which experienced the error. This allows clients to | ||
* identify whether a null result is intentional or caused by a runtime error. | ||
*/ | ||
readonly path?: ReadonlyArray<string | number>; | ||
/** | ||
* Reserved for implementors to extend the protocol however they see fit, | ||
* and hence there are no additional restrictions on its contents. | ||
*/ | ||
readonly extensions?: TExtensions; | ||
} | ||
export { formatError, GraphQLFormattedError } from './GraphQLError'; |
@@ -6,33 +6,15 @@ "use strict"; | ||
}); | ||
exports.formatError = formatError; | ||
Object.defineProperty(exports, "formatError", { | ||
enumerable: true, | ||
get: function get() { | ||
return _GraphQLError.formatError; | ||
} | ||
}); | ||
Object.defineProperty(exports, "GraphQLFormattedError", { | ||
enumerable: true, | ||
get: function get() { | ||
return _GraphQLError.GraphQLFormattedError; | ||
} | ||
}); | ||
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert.js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* Given a GraphQLError, format it according to the rules described by the | ||
* Response Format, Errors section of the GraphQL Specification. | ||
*/ | ||
function formatError(error) { | ||
var _error$message; | ||
error || (0, _devAssert.default)(0, 'Received null or undefined error.'); | ||
var message = (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : 'An unknown error occurred.'; | ||
var locations = error.locations; | ||
var path = error.path; | ||
var extensions = error.extensions; | ||
return extensions && Object.keys(extensions).length > 0 ? { | ||
message: message, | ||
locations: locations, | ||
path: path, | ||
extensions: extensions | ||
} : { | ||
message: message, | ||
locations: locations, | ||
path: path | ||
}; | ||
} | ||
/** | ||
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors | ||
*/ | ||
var _GraphQLError = require("./GraphQLError.js"); |
@@ -85,2 +85,6 @@ import { Maybe } from '../jsutils/Maybe'; | ||
readonly extensions: { [key: string]: any }; | ||
toString(): string; | ||
toJSON(): GraphQLFormattedError; | ||
} | ||
@@ -93,1 +97,38 @@ | ||
export function printError(error: GraphQLError): string; | ||
/** | ||
* Given a GraphQLError, format it according to the rules described by the | ||
* Response Format, Errors section of the GraphQL Specification. | ||
*/ | ||
export function formatError(error: GraphQLError): GraphQLFormattedError; | ||
/** | ||
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors | ||
*/ | ||
export interface GraphQLFormattedError< | ||
TExtensions extends Record<string, any> = Record<string, any> | ||
> { | ||
/** | ||
* A short, human-readable summary of the problem that **SHOULD NOT** change | ||
* from occurrence to occurrence of the problem, except for purposes of | ||
* localization. | ||
*/ | ||
readonly message: string; | ||
/** | ||
* If an error can be associated to a particular point in the requested | ||
* GraphQL document, it should contain a list of locations. | ||
*/ | ||
readonly locations?: ReadonlyArray<SourceLocation>; | ||
/** | ||
* If an error can be associated to a particular field in the GraphQL result, | ||
* it _must_ contain an entry with the key `path` that details the path of | ||
* the response field which experienced the error. This allows clients to | ||
* identify whether a null result is intentional or caused by a runtime error. | ||
*/ | ||
readonly path?: ReadonlyArray<string | number>; | ||
/** | ||
* Reserved for implementors to extend the protocol however they see fit, | ||
* and hence there are no additional restrictions on its contents. | ||
*/ | ||
readonly extensions?: TExtensions; | ||
} |
@@ -9,4 +9,7 @@ "use strict"; | ||
exports.printError = printError; | ||
exports.formatError = formatError; | ||
exports.GraphQLError = void 0; | ||
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert.js")); | ||
var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike.js")); | ||
@@ -210,2 +213,7 @@ | ||
return printError(this); | ||
} | ||
}, { | ||
key: "toJSON", | ||
value: function toJSON() { | ||
return formatError(this); | ||
} // FIXME: workaround to not break chai comparisons, should be remove in v16 | ||
@@ -255,1 +263,29 @@ // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet | ||
} | ||
/** | ||
* Given a GraphQLError, format it according to the rules described by the | ||
* Response Format, Errors section of the GraphQL Specification. | ||
*/ | ||
function formatError(error) { | ||
var _error$message; | ||
error || (0, _devAssert.default)(0, 'Received null or undefined error.'); | ||
var message = (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : 'An unknown error occurred.'; | ||
var locations = error.locations; | ||
var path = error.path; | ||
var extensions = error.extensions; | ||
return extensions && Object.keys(extensions).length > 0 ? { | ||
message: message, | ||
locations: locations, | ||
path: path, | ||
extensions: extensions | ||
} : { | ||
message: message, | ||
locations: locations, | ||
path: path | ||
}; | ||
} | ||
/** | ||
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors | ||
*/ |
{ | ||
"name": "graphql", | ||
"version": "15.9.0", | ||
"version": "15.10.0", | ||
"description": "A Query Language and Runtime which can target any service.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -16,3 +16,3 @@ "use strict"; | ||
*/ | ||
var version = '15.9.0'; | ||
var version = '15.10.0'; | ||
/** | ||
@@ -25,3 +25,3 @@ * An object containing the components of the GraphQL.js version string | ||
major: 15, | ||
minor: 9, | ||
minor: 10, | ||
patch: 0, | ||
@@ -28,0 +28,0 @@ preReleaseTag: null |
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
Unstable ownership
Supply chain riskA new collaborator has begun publishing package versions. Package stability and security risk may be elevated.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2132116
39022
1
1
1