express-graphql
Advanced tools
Comparing version 0.7.1 to 0.8.0
@@ -64,3 +64,5 @@ 'use strict'; | ||
var pretty = void 0; | ||
var formatErrorFn = void 0; | ||
var formatErrorFn = _graphql.formatError; | ||
var validateFn = _graphql.validate; | ||
var executeFn = _graphql.execute; | ||
var extensionsFn = void 0; | ||
@@ -105,3 +107,2 @@ var showGraphiQL = void 0; | ||
var graphiql = optionsData.graphiql; | ||
context = optionsData.context || request; | ||
@@ -156,3 +157,4 @@ | ||
// Validate AST, reporting any errors. | ||
var validationErrors = (0, _graphql.validate)(schema, documentAST, validationRules); | ||
var validationErrors = validateFn(schema, documentAST, validationRules); | ||
if (validationErrors.length > 0) { | ||
@@ -183,3 +185,11 @@ // Return 400: Bad Request if any validation errors exist. | ||
try { | ||
return (0, _graphql.execute)(schema, documentAST, rootValue, context, variables, operationName, fieldResolver); | ||
return executeFn({ | ||
schema: schema, | ||
document: documentAST, | ||
rootValue: rootValue, | ||
contextValue: context, | ||
variableValues: variables, | ||
operationName: operationName, | ||
fieldResolver: fieldResolver | ||
}); | ||
} catch (contextError) { | ||
@@ -223,3 +233,3 @@ // Return 400: Bad Request if any execution context errors exist. | ||
if (result && result.errors) { | ||
result.errors = result.errors.map(formatErrorFn || _graphql.formatError); | ||
result.errors = result.errors.map(formatErrorFn); | ||
} | ||
@@ -262,3 +272,10 @@ | ||
formatErrorFn = optionsData.formatError; | ||
if (optionsData.formatError) { | ||
// eslint-disable-next-line no-console | ||
console.warn('`formatError` is deprecated and replaced by `customFormatErrorFn`. It will be removed in version 1.0.0.'); | ||
} | ||
validateFn = optionsData.customValidateFn || validateFn; | ||
executeFn = optionsData.customExecuteFn || executeFn; | ||
formatErrorFn = optionsData.customFormatErrorFn || optionsData.formatError || formatErrorFn; | ||
extensionsFn = optionsData.extensions; | ||
@@ -265,0 +282,0 @@ pretty = optionsData.pretty; |
{ | ||
"name": "express-graphql", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"description": "Production ready GraphQL HTTP middleware.", | ||
@@ -65,3 +65,3 @@ "license": "BSD-3-Clause", | ||
"content-type": "^1.0.4", | ||
"http-errors": "^1.7.1", | ||
"http-errors": "^1.7.2", | ||
"raw-body": "^2.3.3" | ||
@@ -82,17 +82,17 @@ }, | ||
"connect": "3.6.6", | ||
"coveralls": "3.0.2", | ||
"eslint": "5.6.1", | ||
"eslint-plugin-flowtype": "2.50.3", | ||
"eslint-plugin-prettier": "3.0.0", | ||
"coveralls": "3.0.3", | ||
"eslint": "5.16.0", | ||
"eslint-plugin-flowtype": "3.5.1", | ||
"eslint-plugin-prettier": "3.0.1", | ||
"express": "4.16.4", | ||
"flow-bin": "0.83.0", | ||
"graphql": "14.0.2", | ||
"isparta": "4.1.0", | ||
"mocha": "5.2.0", | ||
"flow-bin": "0.96.0", | ||
"graphql": "14.2.1", | ||
"isparta": "4.1.1", | ||
"mocha": "6.0.2", | ||
"multer": "1.4.1", | ||
"prettier": "1.14.3", | ||
"prettier": "1.16.4", | ||
"restify": "4.3.2", | ||
"sane": "4.0.1", | ||
"sinon": "6.3.5", | ||
"supertest": "3.3.0" | ||
"sane": "4.1.0", | ||
"sinon": "7.3.1", | ||
"supertest": "4.0.2" | ||
}, | ||
@@ -99,0 +99,0 @@ "peerDependencies": { |
@@ -80,6 +80,2 @@ GraphQL HTTP Server Middleware | ||
* **`formatError`**: An optional function which will be used to format any | ||
errors produced by fulfilling a GraphQL operation. If no function is | ||
provided, GraphQL's default spec-compliant [`formatError`][] function will be used. | ||
* **`extensions`**: An optional function for adding additional metadata to the | ||
@@ -95,2 +91,15 @@ GraphQL response as a key-value object. The result will be added to | ||
* **`customValidateFn`**: An optional function which will be used to validate | ||
instead of default `validate` from `graphql-js`. | ||
* **`customExecuteFn`**: An optional function which will be used to execute | ||
instead of default `execute` from `graphql-js`. | ||
* **`customFormatErrorFn`**: An optional function which will be used to format any | ||
errors produced by fulfilling a GraphQL operation. If no function is | ||
provided, GraphQL's default spec-compliant [`formatError`][] function will be used. | ||
* **`formatError`**: is deprecated and replaced by `customFormatErrorFn`. It will be | ||
removed in version 1.0.0. | ||
In addition to an object defining each option, options can also be provided as | ||
@@ -293,6 +302,6 @@ a function (or async function) which returns this options object. This function | ||
During development, it's useful to get more information from errors, such as | ||
stack traces. Providing a function to `formatError` enables this: | ||
stack traces. Providing a function to `customFormatErrorFn` enables this: | ||
```js | ||
formatError: error => ({ | ||
customFormatErrorFn: error => ({ | ||
message: error.message, | ||
@@ -299,0 +308,0 @@ locations: error.locations, |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
70810
473
317
2
Updatedhttp-errors@^1.7.2