Socket
Socket
Sign inDemoInstall

@graphiql/toolkit

Package Overview
Dependencies
Maintainers
2
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphiql/toolkit - npm Package Compare versions

Comparing version 1.0.0-next.1 to 1.0.0-next.2

LICENSE

6

CHANGELOG.md
# @graphiql/toolkit
## 0.6.1
### Patch Changes
- [#2535](https://github.com/graphql/graphiql/pull/2535) [`ea732ea8`](https://github.com/graphql/graphiql/commit/ea732ea8e12272c998f1467af8b3b88b6b508e12) Thanks [@thomasheyenbrock](https://github.com/thomasheyenbrock)! - Fix error formatting for websocket requests and make error formatting more generic in general
## 0.6.0

@@ -4,0 +10,0 @@

10

dist/create-fetcher/lib.js

@@ -130,13 +130,7 @@ "use strict";

return wsClient.subscribe(graphQLParams, __assign(__assign({}, sink), { error: function (err) {
if (err instanceof Error) {
sink.error(err);
}
else if (err instanceof CloseEvent) {
if (err instanceof CloseEvent) {
sink.error(new Error("Socket closed with event ".concat(err.code, " ").concat(err.reason || '').trim()));
}
else {
sink.error(new Error(err.map(function (_a) {
var message = _a.message;
return message;
}).join(', ')));
sink.error(err);
}

@@ -143,0 +137,0 @@ } }));

@@ -1,6 +0,3 @@

import { GraphQLError } from 'graphql';
declare type GenericError = Error | readonly Error[] | string | readonly string[] | GraphQLError | readonly GraphQLError[];
export declare function formatError(error: GenericError): string;
export declare function formatError(error: unknown): string;
export declare function formatResult(result: any): string;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -15,11 +15,9 @@ "use strict";

exports.formatResult = exports.formatError = void 0;
var graphql_1 = require("graphql");
function stringify(obj) {
return JSON.stringify(obj, null, 2);
}
var formatSingleError = function (error) { return (__assign(__assign({}, error), { message: error.message, stack: error.stack })); };
function formatSingleError(error) {
return __assign(__assign({}, error), { message: error.message, stack: error.stack });
}
function handleSingleError(error) {
if (error instanceof graphql_1.GraphQLError) {
return error.toString();
}
if (error instanceof Error) {

@@ -36,3 +34,3 @@ return formatSingleError(error);

}
return stringify({ errors: handleSingleError(error) });
return stringify({ errors: [handleSingleError(error)] });
}

@@ -39,0 +37,0 @@ exports.formatError = formatError;

2

dist/storage/base.d.ts

@@ -5,2 +5,3 @@ export declare type Storage = {

setItem(key: string, value: string): void;
clear(): void;
length: number;

@@ -16,3 +17,4 @@ };

};
clear(): void;
}
//# sourceMappingURL=base.d.ts.map

@@ -56,2 +56,7 @@ "use strict";

};
StorageAPI.prototype.clear = function () {
if (this.storage) {
this.storage.clear();
}
};
return StorageAPI;

@@ -58,0 +63,0 @@ }());

@@ -77,10 +77,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

export const createWebsocketsFetcherFromClient = (wsClient) => (graphQLParams) => makeAsyncIterableIteratorFromSink(sink => wsClient.subscribe(graphQLParams, Object.assign(Object.assign({}, sink), { error: err => {
if (err instanceof Error) {
sink.error(err);
}
else if (err instanceof CloseEvent) {
if (err instanceof CloseEvent) {
sink.error(new Error(`Socket closed with event ${err.code} ${err.reason || ''}`.trim()));
}
else {
sink.error(new Error(err.map(({ message }) => message).join(', ')));
sink.error(err);
}

@@ -87,0 +84,0 @@ } })));

@@ -1,6 +0,3 @@

import { GraphQLError } from 'graphql';
declare type GenericError = Error | readonly Error[] | string | readonly string[] | GraphQLError | readonly GraphQLError[];
export declare function formatError(error: GenericError): string;
export declare function formatError(error: unknown): string;
export declare function formatResult(result: any): string;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -1,10 +0,8 @@

import { GraphQLError } from 'graphql';
function stringify(obj) {
return JSON.stringify(obj, null, 2);
}
const formatSingleError = (error) => (Object.assign(Object.assign({}, error), { message: error.message, stack: error.stack }));
function formatSingleError(error) {
return Object.assign(Object.assign({}, error), { message: error.message, stack: error.stack });
}
function handleSingleError(error) {
if (error instanceof GraphQLError) {
return error.toString();
}
if (error instanceof Error) {

@@ -18,6 +16,6 @@ return formatSingleError(error);

return stringify({
errors: error.map((e) => handleSingleError(e)),
errors: error.map(e => handleSingleError(e)),
});
}
return stringify({ errors: handleSingleError(error) });
return stringify({ errors: [handleSingleError(error)] });
}

@@ -24,0 +22,0 @@ export function formatResult(result) {

@@ -5,2 +5,3 @@ export declare type Storage = {

setItem(key: string, value: string): void;
clear(): void;
length: number;

@@ -16,3 +17,4 @@ };

};
clear(): void;
}
//# sourceMappingURL=base.d.ts.map

@@ -53,4 +53,9 @@ function isQuotaError(storage, e) {

}
clear() {
if (this.storage) {
this.storage.clear();
}
}
}
const STORAGE_NAMESPACE = 'graphiql';
//# sourceMappingURL=base.js.map
{
"name": "@graphiql/toolkit",
"version": "1.0.0-next.1",
"version": "1.0.0-next.2",
"description": "Utility to build a fetcher for GraphiQL",

@@ -5,0 +5,0 @@ "contributors": [

@@ -1,2 +0,2 @@

import { DocumentNode, visit, GraphQLError } from 'graphql';
import { DocumentNode, visit } from 'graphql';
import { meros } from 'meros';

@@ -118,5 +118,3 @@ import {

error: err => {
if (err instanceof Error) {
sink.error(err);
} else if (err instanceof CloseEvent) {
if (err instanceof CloseEvent) {
sink.error(

@@ -128,7 +126,3 @@ new Error(

} else {
sink.error(
new Error(
(err as GraphQLError[]).map(({ message }) => message).join(', '),
),
);
sink.error(err);
}

@@ -135,0 +129,0 @@ },

@@ -1,3 +0,1 @@

import { GraphQLError, GraphQLFormattedError } from 'graphql';
function stringify(obj: unknown): string {

@@ -7,17 +5,12 @@ return JSON.stringify(obj, null, 2);

const formatSingleError = (error: Error): Error => ({
...error,
// Raise these details even if they're non-enumerable
message: error.message,
stack: error.stack,
});
function formatSingleError(error: Error): Error {
return {
...error,
// Raise these details even if they're non-enumerable
message: error.message,
stack: error.stack,
};
}
type InputError = Error | GraphQLError | string;
function handleSingleError(
error: InputError,
): GraphQLFormattedError | Error | string {
if (error instanceof GraphQLError) {
return error.toString();
}
function handleSingleError(error: unknown) {
if (error instanceof Error) {

@@ -29,18 +22,9 @@ return formatSingleError(error);

type GenericError =
| Error
| readonly Error[]
| string
| readonly string[]
| GraphQLError
| readonly GraphQLError[];
export function formatError(error: GenericError): string {
export function formatError(error: unknown): string {
if (Array.isArray(error)) {
return stringify({
errors: error.map((e: InputError) => handleSingleError(e)),
errors: error.map(e => handleSingleError(e)),
});
}
// @ts-ignore
return stringify({ errors: handleSingleError(error) });
return stringify({ errors: [handleSingleError(error)] });
}

@@ -47,0 +31,0 @@

@@ -5,2 +5,3 @@ export type Storage = {

setItem(key: string, value: string): void;
clear(): void;
length: number;

@@ -81,4 +82,10 @@ };

}
clear() {
if (this.storage) {
this.storage.clear();
}
}
}
const STORAGE_NAMESPACE = 'graphiql';

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

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