@neo4j/graphql
Version:
A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations
39 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentValidationError = void 0;
exports.assertValid = assertValid;
exports.createGraphQLError = createGraphQLError;
const graphql_1 = require("graphql");
class DocumentValidationError extends Error {
constructor(message, _path) {
super(message);
this.path = _path;
}
}
exports.DocumentValidationError = DocumentValidationError;
function assertValid(fn) {
let isValid = true;
let errorMsg, errorPath;
try {
fn();
}
catch (error) {
isValid = false;
errorMsg = error.message;
errorPath = error.path || [];
}
return { isValid, errorMsg, errorPath };
}
function createGraphQLError({ nodes, path, errorMsg, extensions, }) {
const errorOpts = {
nodes,
path,
source: undefined,
positions: undefined,
originalError: undefined,
extensions,
};
// TODO: replace constructor to use errorOpts when dropping support for GraphQL15
return new graphql_1.GraphQLError(errorMsg || "Error", errorOpts.nodes, errorOpts.source, errorOpts.positions, errorOpts.path, errorOpts.originalError, errorOpts.extensions);
}
//# sourceMappingURL=document-validation-error.js.map