Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql

Package Overview
Dependencies
Maintainers
10
Versions
270
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql - npm Package Compare versions

Comparing version 15.9.0 to 15.10.0

41

error/formatError.d.ts

@@ -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';

44

error/formatError.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc