Initial Sample.

This commit is contained in:
2024-06-03 20:23:50 +05:30
parent ef2b65f673
commit 5269ec3c66
2575 changed files with 282312 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
require('../utilities/globals');
var utilities = require('../utilities');
var PROTOCOL_ERRORS_SYMBOL = Symbol();
function graphQLResultHasProtocolErrors(result) {
if (result.extensions) {
return Array.isArray(result.extensions[PROTOCOL_ERRORS_SYMBOL]);
}
return false;
}
function isApolloError(err) {
return err.hasOwnProperty("graphQLErrors");
}
var generateErrorMessage = function (err) {
var errors = tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], err.graphQLErrors, true), err.clientErrors, true), err.protocolErrors, true);
if (err.networkError)
errors.push(err.networkError);
return (errors
.map(function (err) {
return (utilities.isNonNullObject(err) && err.message) || "Error message not found.";
})
.join("\n"));
};
var ApolloError = (function (_super) {
tslib.__extends(ApolloError, _super);
function ApolloError(_a) {
var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
var _this = _super.call(this, errorMessage) || this;
_this.name = "ApolloError";
_this.graphQLErrors = graphQLErrors || [];
_this.protocolErrors = protocolErrors || [];
_this.clientErrors = clientErrors || [];
_this.networkError = networkError || null;
_this.message = errorMessage || generateErrorMessage(_this);
_this.extraInfo = extraInfo;
_this.__proto__ = ApolloError.prototype;
return _this;
}
return ApolloError;
}(Error));
exports.ApolloError = ApolloError;
exports.PROTOCOL_ERRORS_SYMBOL = PROTOCOL_ERRORS_SYMBOL;
exports.graphQLResultHasProtocolErrors = graphQLResultHasProtocolErrors;
exports.isApolloError = isApolloError;
//# sourceMappingURL=errors.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.cjs","sources":["index.js"],"sourcesContent":["import { __extends, __spreadArray } from \"tslib\";\nimport \"../utilities/globals/index.js\";\nimport { isNonNullObject } from \"../utilities/index.js\";\n// This Symbol allows us to pass transport-specific errors from the link chain\n// into QueryManager/client internals without risking a naming collision within\n// extensions (which implementers can use as they see fit).\nexport var PROTOCOL_ERRORS_SYMBOL = Symbol();\nexport function graphQLResultHasProtocolErrors(result) {\n if (result.extensions) {\n return Array.isArray(result.extensions[PROTOCOL_ERRORS_SYMBOL]);\n }\n return false;\n}\nexport function isApolloError(err) {\n return err.hasOwnProperty(\"graphQLErrors\");\n}\n// Sets the error message on this error according to the\n// the GraphQL and network errors that are present.\n// If the error message has already been set through the\n// constructor or otherwise, this function is a nop.\nvar generateErrorMessage = function (err) {\n var errors = __spreadArray(__spreadArray(__spreadArray([], err.graphQLErrors, true), err.clientErrors, true), err.protocolErrors, true);\n if (err.networkError)\n errors.push(err.networkError);\n return (errors\n // The rest of the code sometimes unsafely types non-Error objects as GraphQLErrors\n .map(function (err) {\n return (isNonNullObject(err) && err.message) || \"Error message not found.\";\n })\n .join(\"\\n\"));\n};\nvar ApolloError = /** @class */ (function (_super) {\n __extends(ApolloError, _super);\n // Constructs an instance of ApolloError given a GraphQLError\n // or a network error. Note that one of these has to be a valid\n // value or the constructed error will be meaningless.\n function ApolloError(_a) {\n var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;\n var _this = _super.call(this, errorMessage) || this;\n _this.name = \"ApolloError\";\n _this.graphQLErrors = graphQLErrors || [];\n _this.protocolErrors = protocolErrors || [];\n _this.clientErrors = clientErrors || [];\n _this.networkError = networkError || null;\n _this.message = errorMessage || generateErrorMessage(_this);\n _this.extraInfo = extraInfo;\n // We're not using `Object.setPrototypeOf` here as it isn't fully\n // supported on Android (see issue #3236).\n _this.__proto__ = ApolloError.prototype;\n return _this;\n }\n return ApolloError;\n}(Error));\nexport { ApolloError };\n//# sourceMappingURL=index.js.map"],"names":["__spreadArray","isNonNullObject","__extends"],"mappings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AAE,CAAC,YAAY,EAAE,YAAY,GAAG,EAAE,CAAC,YAAY,EAAE,YAAY,GAAG,EAAE,CAAC,YAAY,EAAE,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC;AAC3M,QAAQ,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,IAAI,CAAC;AAC5D,QAAQ,KAAK,CAAC,IAAI,GAAG,aAAa,CAAC;AACnC,QAAQ,KAAK,CAAC,aAAa,GAAG,aAAa,IAAI,EAAE,CAAC;AAClD,QAAQ,KAAK,CAAC,cAAc,GAAG,cAAc,IAAI,EAAE,CAAC;AACpD,QAAQ,KAAK,CAAC,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;AAChD,QAAQ,KAAK,CAAC,YAAY,GAAG,YAAY,IAAI,IAAI,CAAC;AAClD,QAAQ,KAAK,CAAC,OAAO,GAAG,YAAY,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACpE,QAAQ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AAGpC,QAAQ,KAAK,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;AAChD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC,KAAK,CAAC;;;;;;;"}

View File

@@ -0,0 +1,51 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
require('../utilities/globals');
var utilities = require('../utilities');
var PROTOCOL_ERRORS_SYMBOL = Symbol();
function graphQLResultHasProtocolErrors(result) {
if (result.extensions) {
return Array.isArray(result.extensions[PROTOCOL_ERRORS_SYMBOL]);
}
return false;
}
function isApolloError(err) {
return err.hasOwnProperty("graphQLErrors");
}
var generateErrorMessage = function (err) {
var errors = tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], err.graphQLErrors, true), err.clientErrors, true), err.protocolErrors, true);
if (err.networkError)
errors.push(err.networkError);
return (errors
.map(function (err) {
return (utilities.isNonNullObject(err) && err.message) || "Error message not found.";
})
.join("\n"));
};
var ApolloError = (function (_super) {
tslib.__extends(ApolloError, _super);
function ApolloError(_a) {
var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
var _this = _super.call(this, errorMessage) || this;
_this.name = "ApolloError";
_this.graphQLErrors = graphQLErrors || [];
_this.protocolErrors = protocolErrors || [];
_this.clientErrors = clientErrors || [];
_this.networkError = networkError || null;
_this.message = errorMessage || generateErrorMessage(_this);
_this.extraInfo = extraInfo;
_this.__proto__ = ApolloError.prototype;
return _this;
}
return ApolloError;
}(Error));
exports.ApolloError = ApolloError;
exports.PROTOCOL_ERRORS_SYMBOL = PROTOCOL_ERRORS_SYMBOL;
exports.graphQLResultHasProtocolErrors = graphQLResultHasProtocolErrors;
exports.isApolloError = isApolloError;
//# sourceMappingURL=errors.cjs.map

View File

@@ -0,0 +1,39 @@
import "../utilities/globals/index.js";
import type { GraphQLError, GraphQLErrorExtensions } from "graphql";
import type { ServerParseError } from "../link/http/index.js";
import type { ServerError } from "../link/utils/index.js";
import type { FetchResult } from "../link/core/index.js";
export declare const PROTOCOL_ERRORS_SYMBOL: unique symbol;
type FetchResultWithSymbolExtensions<T> = FetchResult<T> & {
extensions: Record<string | symbol, any>;
};
export interface ApolloErrorOptions {
graphQLErrors?: ReadonlyArray<GraphQLError>;
protocolErrors?: ReadonlyArray<{
message: string;
extensions?: GraphQLErrorExtensions[];
}>;
clientErrors?: ReadonlyArray<Error>;
networkError?: Error | ServerParseError | ServerError | null;
errorMessage?: string;
extraInfo?: any;
}
export declare function graphQLResultHasProtocolErrors<T>(result: FetchResult<T>): result is FetchResultWithSymbolExtensions<T>;
export declare function isApolloError(err: Error): err is ApolloError;
export type GraphQLErrors = ReadonlyArray<GraphQLError>;
export type NetworkError = Error | ServerParseError | ServerError | null;
export declare class ApolloError extends Error {
name: string;
message: string;
graphQLErrors: GraphQLErrors;
protocolErrors: ReadonlyArray<{
message: string;
extensions?: GraphQLErrorExtensions[];
}>;
clientErrors: ReadonlyArray<Error>;
networkError: Error | ServerParseError | ServerError | null;
extraInfo: any;
constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions);
}
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,55 @@
import { __extends, __spreadArray } from "tslib";
import "../utilities/globals/index.js";
import { isNonNullObject } from "../utilities/index.js";
// This Symbol allows us to pass transport-specific errors from the link chain
// into QueryManager/client internals without risking a naming collision within
// extensions (which implementers can use as they see fit).
export var PROTOCOL_ERRORS_SYMBOL = Symbol();
export function graphQLResultHasProtocolErrors(result) {
if (result.extensions) {
return Array.isArray(result.extensions[PROTOCOL_ERRORS_SYMBOL]);
}
return false;
}
export function isApolloError(err) {
return err.hasOwnProperty("graphQLErrors");
}
// Sets the error message on this error according to the
// the GraphQL and network errors that are present.
// If the error message has already been set through the
// constructor or otherwise, this function is a nop.
var generateErrorMessage = function (err) {
var errors = __spreadArray(__spreadArray(__spreadArray([], err.graphQLErrors, true), err.clientErrors, true), err.protocolErrors, true);
if (err.networkError)
errors.push(err.networkError);
return (errors
// The rest of the code sometimes unsafely types non-Error objects as GraphQLErrors
.map(function (err) {
return (isNonNullObject(err) && err.message) || "Error message not found.";
})
.join("\n"));
};
var ApolloError = /** @class */ (function (_super) {
__extends(ApolloError, _super);
// Constructs an instance of ApolloError given a GraphQLError
// or a network error. Note that one of these has to be a valid
// value or the constructed error will be meaningless.
function ApolloError(_a) {
var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
var _this = _super.call(this, errorMessage) || this;
_this.name = "ApolloError";
_this.graphQLErrors = graphQLErrors || [];
_this.protocolErrors = protocolErrors || [];
_this.clientErrors = clientErrors || [];
_this.networkError = networkError || null;
_this.message = errorMessage || generateErrorMessage(_this);
_this.extraInfo = extraInfo;
// We're not using `Object.setPrototypeOf` here as it isn't fully
// supported on Android (see issue #3236).
_this.__proto__ = ApolloError.prototype;
return _this;
}
return ApolloError;
}(Error));
export { ApolloError };
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
{
"name": "@apollo/client/errors",
"type": "module",
"main": "errors.cjs",
"module": "index.js",
"types": "index.d.ts",
"sideEffects": false
}