Socket
Socket
Sign inDemoInstall

express-graphql

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-graphql - npm Package Compare versions

Comparing version 0.4.5 to 0.4.6

34

dist/index.js

@@ -24,2 +24,4 @@

var _graphql = require('graphql');
var _httpErrors = require('http-errors');

@@ -29,12 +31,2 @@

var _graphqlError = require('graphql/error');
var _graphqlExecution = require('graphql/execution');
var _graphqlLanguage = require('graphql/language');
var _graphqlValidation = require('graphql/validation');
var _graphqlUtilitiesGetOperationAST = require('graphql/utilities/getOperationAST');
var _parseBody = require('./parseBody');

@@ -61,2 +53,3 @@

var graphiql = undefined;
var formatErrorFn = undefined;
var showGraphiQL = undefined;

@@ -77,2 +70,3 @@ var query = undefined;

graphiql = optionsObj.graphiql;
formatErrorFn = optionsObj.formatError;

@@ -112,3 +106,3 @@ // GraphQL HTTP only supports GET and POST methods.

// GraphQL source.
var source = new _graphqlLanguage.Source(query, 'GraphQL request');
var source = new _graphql.Source(query, 'GraphQL request');

@@ -118,3 +112,3 @@ // Parse source to AST, reporting any syntax error.

try {
documentAST = (0, _graphqlLanguage.parse)(source);
documentAST = (0, _graphql.parse)(source);
} catch (syntaxError) {

@@ -127,3 +121,3 @@ // Return 400: Bad Request if any syntax errors errors exist.

// Validate AST, reporting any errors.
var validationErrors = (0, _graphqlValidation.validate)(schema, documentAST);
var validationErrors = (0, _graphql.validate)(schema, documentAST);
if (validationErrors.length > 0) {

@@ -138,3 +132,3 @@ // Return 400: Bad Request if any validation errors exist.

// Determine if this GET request will perform a non-query.
var operationAST = (0, _graphqlUtilitiesGetOperationAST.getOperationAST)(documentAST, operationName);
var operationAST = (0, _graphql.getOperationAST)(documentAST, operationName);
if (operationAST && operationAST.operation !== 'query') {

@@ -156,3 +150,3 @@ // If GraphiQL can be shown, do not perform this query, but

try {
return (0, _graphqlExecution.execute)(schema, documentAST, rootValue, variables, operationName);
return (0, _graphql.execute)(schema, documentAST, rootValue, variables, operationName);
} catch (contextError) {

@@ -170,3 +164,3 @@ // Return 400: Bad Request if any execution context errors exist.

if (result && result.errors) {
result.errors = result.errors.map(_graphqlError.formatError);
result.errors = result.errors.map(formatErrorFn || _graphql.formatError);
}

@@ -251,3 +245,9 @@

/**
* A boolean to optionally enable GraphiQL mode
* 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.
*/
/**
* A boolean to optionally enable GraphiQL mode.
*/

@@ -19,3 +19,3 @@

// Current latest version of GraphiQL.
var GRAPHIQL_VERSION = '0.4.4';
var GRAPHIQL_VERSION = '0.4.7';

@@ -36,3 +36,3 @@ /**

/* eslint-disable max-len */
return '<!--\nThe request to this GraphQL server provided the header "Accept: text/html"\nand as a result has been presented GraphiQL - an in-browser IDE for\nexploring GraphQL.\n\nIf you wish to receive JSON, provide the header "Accept: application/json" or\nadd "&raw" to the end of the URL within a browser.\n-->\n<!DOCTYPE html>\n<html>\n<head>\n <link href="//cdn.jsdelivr.net/graphiql/' + GRAPHIQL_VERSION + '/graphiql.css" rel="stylesheet" />\n <script src="//cdn.jsdelivr.net/fetch/0.9.0/fetch.min.js"></script>\n <script src="//cdn.jsdelivr.net/react/0.14.2/react.min.js"></script>\n <script src="//cdn.jsdelivr.net/react/0.14.2/react-dom.min.js"></script>\n <script src="//cdn.jsdelivr.net/graphiql/' + GRAPHIQL_VERSION + '/graphiql.min.js"></script>\n</head>\n<body>\n <script>\n // Collect the URL parameters\n var parameters = {};\n window.location.search.substr(1).split(\'&\').forEach(function (entry) {\n var eq = entry.indexOf(\'=\');\n if (eq >= 0) {\n parameters[decodeURIComponent(entry.slice(0, eq))] =\n decodeURIComponent(entry.slice(eq + 1));\n }\n });\n\n // Produce a Location query string from a parameter object.\n function locationQuery(params) {\n return \'?\' + Object.keys(params).map(function (key) {\n return encodeURIComponent(key) + \'=\' +\n encodeURIComponent(params[key]);\n }).join(\'&\');\n }\n\n // Derive a fetch URL from the current URL, sans the GraphQL parameters.\n var graphqlParamNames = {\n query: true,\n variables: true,\n operationName: true\n };\n\n var otherParams = {};\n for (var k in parameters) {\n if (parameters.hasOwnProperty(k) && graphqlParamNames[k] !== true) {\n otherParams[k] = parameters[k];\n }\n }\n var fetchURL = locationQuery(otherParams);\n\n // Defines a GraphQL fetcher using the fetch API.\n function graphQLFetcher(graphQLParams) {\n return fetch(fetchURL, {\n method: \'post\',\n headers: {\n \'Accept\': \'application/json\',\n \'Content-Type\': \'application/json\'\n },\n body: JSON.stringify(graphQLParams),\n credentials: \'include\',\n }).then(function (response) {\n return response.json();\n });\n }\n\n // When the query and variables string is edited, update the URL bar so\n // that it can be easily shared.\n function onEditQuery(newQuery) {\n parameters.query = newQuery;\n updateURL();\n }\n\n function onEditVariables(newVariables) {\n parameters.variables = newVariables;\n updateURL();\n }\n\n function updateURL() {\n history.replaceState(null, null, locationQuery(parameters));\n }\n\n // Render <GraphiQL /> into the body.\n React.render(\n React.createElement(GraphiQL, {\n fetcher: graphQLFetcher,\n onEditQuery: onEditQuery,\n onEditVariables: onEditVariables,\n query: ' + JSON.stringify(queryString) + ',\n response: ' + JSON.stringify(resultString) + ',\n variables: ' + JSON.stringify(variablesString) + '\n }),\n document.body\n );\n </script>\n</body>\n</html>';
return '<!--\nThe request to this GraphQL server provided the header "Accept: text/html"\nand as a result has been presented GraphiQL - an in-browser IDE for\nexploring GraphQL.\n\nIf you wish to receive JSON, provide the header "Accept: application/json" or\nadd "&raw" to the end of the URL within a browser.\n-->\n<!DOCTYPE html>\n<html>\n<head>\n <link href="//cdn.jsdelivr.net/graphiql/' + GRAPHIQL_VERSION + '/graphiql.css" rel="stylesheet" />\n <script src="//cdn.jsdelivr.net/fetch/1.0.0/fetch.min.js"></script>\n <script src="//cdn.jsdelivr.net/react/0.14.7/react.min.js"></script>\n <script src="//cdn.jsdelivr.net/react/0.14.7/react-dom.min.js"></script>\n <script src="//cdn.jsdelivr.net/graphiql/' + GRAPHIQL_VERSION + '/graphiql.min.js"></script>\n</head>\n<body>\n <script>\n // Collect the URL parameters\n var parameters = {};\n window.location.search.substr(1).split(\'&\').forEach(function (entry) {\n var eq = entry.indexOf(\'=\');\n if (eq >= 0) {\n parameters[decodeURIComponent(entry.slice(0, eq))] =\n decodeURIComponent(entry.slice(eq + 1));\n }\n });\n\n // Produce a Location query string from a parameter object.\n function locationQuery(params) {\n return \'?\' + Object.keys(params).map(function (key) {\n return encodeURIComponent(key) + \'=\' +\n encodeURIComponent(params[key]);\n }).join(\'&\');\n }\n\n // Derive a fetch URL from the current URL, sans the GraphQL parameters.\n var graphqlParamNames = {\n query: true,\n variables: true,\n operationName: true\n };\n\n var otherParams = {};\n for (var k in parameters) {\n if (parameters.hasOwnProperty(k) && graphqlParamNames[k] !== true) {\n otherParams[k] = parameters[k];\n }\n }\n var fetchURL = locationQuery(otherParams);\n\n // Defines a GraphQL fetcher using the fetch API.\n function graphQLFetcher(graphQLParams) {\n return fetch(fetchURL, {\n method: \'post\',\n headers: {\n \'Accept\': \'application/json\',\n \'Content-Type\': \'application/json\'\n },\n body: JSON.stringify(graphQLParams),\n credentials: \'include\',\n }).then(function (response) {\n return response.text();\n }).then(function (responseBody) {\n try {\n return JSON.parse(responseBody);\n } catch (error) {\n return responseBody;\n }\n });\n }\n\n // When the query and variables string is edited, update the URL bar so\n // that it can be easily shared.\n function onEditQuery(newQuery) {\n parameters.query = newQuery;\n updateURL();\n }\n\n function onEditVariables(newVariables) {\n parameters.variables = newVariables;\n updateURL();\n }\n\n function updateURL() {\n history.replaceState(null, null, locationQuery(parameters));\n }\n\n // Render <GraphiQL /> into the body.\n React.render(\n React.createElement(GraphiQL, {\n fetcher: graphQLFetcher,\n onEditQuery: onEditQuery,\n onEditVariables: onEditVariables,\n query: ' + JSON.stringify(queryString) + ',\n response: ' + JSON.stringify(resultString) + ',\n variables: ' + JSON.stringify(variablesString) + '\n }),\n document.body\n );\n </script>\n</body>\n</html>';
}
{
"name": "express-graphql",
"version": "0.4.5",
"version": "0.4.6",
"description": "Create a GraphQL HTTP server with Express.",

@@ -54,3 +54,3 @@ "contributors": [

"peerDependencies": {
"graphql": "^0.4.8"
"graphql": "^0.4.16"
},

@@ -60,3 +60,3 @@ "devDependencies": {

"babel-core": "5.8.22",
"babel-eslint": "4.0.10",
"babel-eslint": "4.1.8",
"babel-runtime": "5.8.20",

@@ -70,4 +70,4 @@ "body-parser": "^1.14.0",

"express3": "*",
"flow-bin": "0.18.1",
"graphql": "0.4.8",
"flow-bin": "0.21.0",
"graphql": "0.4.16",
"isparta": "3.0.3",

@@ -74,0 +74,0 @@ "mocha": "2.2.5",

@@ -36,2 +36,7 @@ GraphQL Express 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. *To enable stack traces, provide the function: `error => error`.*
* **`graphiql`**: If `true`, may present [GraphiQL][] when loaded directly

@@ -128,4 +133,5 @@ from a browser (a useful tool for debugging and exploration).

[`graphql-js`]: https://github.com/graphql/graphql-js
[`formatError`]: https://github.com/graphql/graphql-js/blob/master/src/error/formatError.js
[GraphiQL]: https://github.com/graphql/graphiql
[`multer`]: https://github.com/expressjs/multer
[`express-session`]: https://github.com/expressjs/session
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