WIP - add extractor, generate snippet_data
This commit is contained in:
30
node_modules/express-graphql/LICENSE
generated
vendored
Normal file
30
node_modules/express-graphql/LICENSE
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
BSD License
|
||||
|
||||
For GraphQL software
|
||||
|
||||
Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
11
node_modules/express-graphql/PATENTS
generated
vendored
Normal file
11
node_modules/express-graphql/PATENTS
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the GraphQL software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. (“Facebook”) hereby grants to each recipient of the Software (“you”) a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (subject to the termination provision below) license under any Necessary Claims, to make, have made, use, sell, offer to sell, import, and otherwise transfer the Software. For avoidance of doubt, no license is granted under Facebook’s rights in any patent claims that are infringed by (i) modifications to the Software made by you or any third party or (ii) the Software in combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice, if you (or any of your subsidiaries, corporate affiliates or agents) initiate directly or indirectly, or take a direct financial interest in, any Patent Assertion: (i) against Facebook or any of its subsidiaries or corporate affiliates, (ii) against any party if such Patent Assertion arises in whole or in part from any software, technology, product or service of Facebook or any of its subsidiaries or corporate affiliates, or (iii) against any party relating to the Software. Notwithstanding the foregoing, if Facebook or any of its subsidiaries or corporate affiliates files a lawsuit alleging patent infringement against you in the first instance, and you respond by filing a patent infringement counterclaim in that lawsuit against that party that is unrelated to the Software, the license granted hereunder will not terminate under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A “Necessary Claim” is a claim of a patent owned by Facebook that is necessarily infringed by the Software standing alone.
|
||||
|
||||
A “Patent Assertion” is any lawsuit or other action alleging direct, indirect, or contributory infringement or inducement to infringe any patent, including a cross-claim or counterclaim.
|
||||
307
node_modules/express-graphql/README.md
generated
vendored
Normal file
307
node_modules/express-graphql/README.md
generated
vendored
Normal file
@ -0,0 +1,307 @@
|
||||
GraphQL HTTP Server Middleware
|
||||
==============================
|
||||
|
||||
[](https://travis-ci.org/graphql/express-graphql)
|
||||
[](https://coveralls.io/github/graphql/express-graphql?branch=master)
|
||||
|
||||
Create a GraphQL HTTP server with any HTTP web framework that supports connect styled middleware, including [Connect](https://github.com/senchalabs/connect) itself, [Express](http://expressjs.com) and [Restify](http://restify.com/).
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install --save express-graphql
|
||||
```
|
||||
|
||||
|
||||
## Simple Setup
|
||||
|
||||
Just mount `express-graphql` as a route handler:
|
||||
|
||||
```js
|
||||
const express = require('express');
|
||||
const graphqlHTTP = require('express-graphql');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use('/graphql', graphqlHTTP({
|
||||
schema: MyGraphQLSchema,
|
||||
graphiql: true
|
||||
}));
|
||||
|
||||
app.listen(4000);
|
||||
```
|
||||
|
||||
|
||||
## Setup with Restify
|
||||
|
||||
Use `.get` or `.post` (or both) rather than `.use` to configure your route handler. If you want to show GraphiQL in the browser, set `graphiql: true` on your `.get` handler.
|
||||
|
||||
```js
|
||||
const restify = require('restify');
|
||||
const graphqlHTTP = require('express-graphql');
|
||||
|
||||
const app = restify.createServer();
|
||||
|
||||
app.post('/graphql', graphqlHTTP({
|
||||
schema: MyGraphQLSchema,
|
||||
graphiql: false
|
||||
}));
|
||||
|
||||
app.get('/graphql', graphqlHTTP({
|
||||
schema: MyGraphQLSchema,
|
||||
graphiql: true
|
||||
}));
|
||||
|
||||
app.listen(4000);
|
||||
```
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
The `graphqlHTTP` function accepts the following options:
|
||||
|
||||
* **`schema`**: A `GraphQLSchema` instance from [`GraphQL.js`][].
|
||||
A `schema` *must* be provided.
|
||||
|
||||
* **`graphiql`**: If `true`, presents [GraphiQL][] when the GraphQL endpoint is
|
||||
loaded in a browser. We recommend that you set
|
||||
`graphiql` to `true` when your app is in development, because it's
|
||||
quite useful. You may or may not want it in production.
|
||||
|
||||
* **`rootValue`**: A value to pass as the `rootValue` to the `graphql()`
|
||||
function from [`GraphQL.js/src/execute.js`](https://github.com/graphql/graphql-js/blob/master/src/execution/execute.js#L119).
|
||||
|
||||
* **`context`**: A value to pass as the `context` to the `graphql()`
|
||||
function from [`GraphQL.js/src/execute.js`](https://github.com/graphql/graphql-js/blob/master/src/execution/execute.js#L120). If `context` is not provided, the
|
||||
`request` object is passed as the context.
|
||||
|
||||
* **`pretty`**: If `true`, any JSON response will be pretty-printed.
|
||||
|
||||
* **`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
|
||||
GraphQL response as a key-value object. The result will be added to
|
||||
`"extensions"` field in the resulting JSON. This is often a useful place to
|
||||
add development time metadata such as the runtime of a query or the amount
|
||||
of resources consumed. This may be an async function. The function is
|
||||
given one object as an argument: `{ document, variables, operationName, result, context }`.
|
||||
|
||||
* **`validationRules`**: Optional additional validation rules queries must
|
||||
satisfy in addition to those defined by the GraphQL spec.
|
||||
|
||||
In addition to an object defining each option, options can also be provided as
|
||||
a function (or async function) which returns this options object. This function
|
||||
is provided the arguments `(request, response, graphQLParams)` and is called
|
||||
after the request has been parsed.
|
||||
|
||||
The `graphQLParams` is provided as the object `{ query, variables, operationName, raw }`.
|
||||
|
||||
```js
|
||||
app.use('/graphql', graphqlHTTP(async (request, response, graphQLParams) => ({
|
||||
schema: MyGraphQLSchema,
|
||||
rootValue: await someFunctionToGetRootValue(request),
|
||||
graphiql: true
|
||||
})));
|
||||
```
|
||||
|
||||
|
||||
## HTTP Usage
|
||||
|
||||
Once installed at a path, `express-graphql` will accept requests with
|
||||
the parameters:
|
||||
|
||||
* **`query`**: A string GraphQL document to be executed.
|
||||
|
||||
* **`variables`**: The runtime values to use for any GraphQL query variables
|
||||
as a JSON object.
|
||||
|
||||
* **`operationName`**: If the provided `query` contains multiple named
|
||||
operations, this specifies which operation should be executed. If not
|
||||
provided, a 400 error will be returned if the `query` contains multiple
|
||||
named operations.
|
||||
|
||||
* **`raw`**: If the `graphiql` option is enabled and the `raw` parameter is
|
||||
provided raw JSON will always be returned instead of GraphiQL even when
|
||||
loaded from a browser.
|
||||
|
||||
GraphQL will first look for each parameter in the URL's query-string:
|
||||
|
||||
```
|
||||
/graphql?query=query+getUser($id:ID){user(id:$id){name}}&variables={"id":"4"}
|
||||
```
|
||||
|
||||
If not found in the query-string, it will look in the POST request body.
|
||||
|
||||
If a previous middleware has already parsed the POST body, the `request.body`
|
||||
value will be used. Use [`multer`][] or a similar middleware to add support
|
||||
for `multipart/form-data` content, which may be useful for GraphQL mutations
|
||||
involving uploading files. See an [example using multer](https://github.com/graphql/express-graphql/blob/304b24b993c8f16fffff8d23b0fa4088e690874b/src/__tests__/http-test.js#L674-L741).
|
||||
|
||||
If the POST body has not yet been parsed, express-graphql will interpret it
|
||||
depending on the provided *Content-Type* header.
|
||||
|
||||
* **`application/json`**: the POST body will be parsed as a JSON
|
||||
object of parameters.
|
||||
|
||||
* **`application/x-www-form-urlencoded`**: this POST body will be
|
||||
parsed as a url-encoded string of key-value pairs.
|
||||
|
||||
* **`application/graphql`**: The POST body will be parsed as GraphQL
|
||||
query string, which provides the `query` parameter.
|
||||
|
||||
|
||||
## Combining with Other Express Middleware
|
||||
|
||||
By default, the express request is passed as the GraphQL `context`.
|
||||
Since most express middleware operates by adding extra data to the
|
||||
request object, this means you can use most express middleware just by inserting it before `graphqlHTTP` is mounted. This covers scenarios such as authenticating the user, handling file uploads, or mounting GraphQL on a dynamic endpoint.
|
||||
|
||||
This example uses [`express-session`][] to provide GraphQL with the currently logged-in session.
|
||||
|
||||
```js
|
||||
const session = require('express-session');
|
||||
const graphqlHTTP = require('express-graphql');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}));
|
||||
|
||||
app.use('/graphql', graphqlHTTP({
|
||||
schema: MySessionAwareGraphQLSchema,
|
||||
graphiql: true
|
||||
}));
|
||||
```
|
||||
|
||||
Then in your type definitions, you can access the request via the third "context" argument in your `resolve` function:
|
||||
|
||||
```js
|
||||
new GraphQLObjectType({
|
||||
name: 'MyType',
|
||||
fields: {
|
||||
myField: {
|
||||
type: GraphQLString,
|
||||
resolve(parentValue, args, request) {
|
||||
// use `request.session` here
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## Providing Extensions
|
||||
|
||||
The GraphQL response allows for adding additional information in a response to
|
||||
a GraphQL query via a field in the response called `"extensions"`. This is added
|
||||
by providing an `extensions` function when using `graphqlHTTP`. The function
|
||||
must return a JSON-serializable Object.
|
||||
|
||||
When called, this is provided an argument which you can use to get information
|
||||
about the GraphQL request:
|
||||
|
||||
`{ document, variables, operationName, result, context }`
|
||||
|
||||
This example illustrates adding the amount of time consumed by running the
|
||||
provided query, which could perhaps be used by your development tools.
|
||||
|
||||
```js
|
||||
const graphqlHTTP = require('express-graphql');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}));
|
||||
|
||||
const extensions = ({ document, variables, operationName, result, context }) => {
|
||||
return {
|
||||
runTime: Date.now() - context.startTime
|
||||
}
|
||||
}
|
||||
|
||||
app.use('/graphql', graphqlHTTP(request => {
|
||||
return {
|
||||
schema: MyGraphQLSchema,
|
||||
context: { startTime: Date.now() },
|
||||
graphiql: true,
|
||||
extensions
|
||||
};
|
||||
}));
|
||||
```
|
||||
|
||||
When querying this endpoint, it would include this information in the result,
|
||||
for example:
|
||||
|
||||
```js
|
||||
{
|
||||
"data": { ... }
|
||||
"extensions": {
|
||||
"runTime": 135
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Additional Validation Rules
|
||||
|
||||
GraphQL's [validation phase](https://facebook.github.io/graphql/#sec-Validation) checks the query to ensure that it can be successfully executed against the schema. The `validationRules` option allows for additional rules to be run during this phase. Rules are applied to each node in an AST representing the query using the Visitor pattern.
|
||||
|
||||
A validation rule is a function which returns a visitor for one or more node Types. Below is an example of a validation preventing the specific fieldname `metadata` from being queried. For more examples see the [`specifiedRules`](https://github.com/graphql/graphql-js/tree/master/src/validation/rules) in the [graphql-js](https://github.com/graphql/graphql-js) package.
|
||||
|
||||
```js
|
||||
import { GraphQLError } from 'graphql';
|
||||
|
||||
export function DisallowMetadataQueries(context) {
|
||||
return {
|
||||
Field(node) {
|
||||
const fieldName = node.name.value;
|
||||
|
||||
if (fieldName === "metadata") {
|
||||
context.reportError(
|
||||
new GraphQLError(
|
||||
`Validation: Requesting the field ${fieldName} is not allowed`,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Other Exports
|
||||
|
||||
**`getGraphQLParams(request: Request): Promise<GraphQLParams>`**
|
||||
|
||||
Given an HTTP Request, this returns a Promise for the parameters relevant to
|
||||
running a GraphQL request. This function is used internally to handle the
|
||||
incoming request, you may use it directly for building other similar services.
|
||||
|
||||
```js
|
||||
const graphqlHTTP = require('express-graphql');
|
||||
|
||||
graphqlHTTP.getGraphQLParams(request).then(params => {
|
||||
// do something...
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Debugging Tips
|
||||
|
||||
During development, it's useful to get more information from errors, such as
|
||||
stack traces. Providing a function to `formatError` enables this:
|
||||
|
||||
```js
|
||||
formatError: error => ({
|
||||
message: error.message,
|
||||
locations: error.locations,
|
||||
stack: error.stack ? error.stack.split('\n') : [],
|
||||
path: error.path
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
[`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
|
||||
329
node_modules/express-graphql/dist/index.js
generated
vendored
Normal file
329
node_modules/express-graphql/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,329 @@
|
||||
'use strict';
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* strict
|
||||
*/
|
||||
|
||||
var _accepts = require('accepts');
|
||||
|
||||
var _accepts2 = _interopRequireDefault(_accepts);
|
||||
|
||||
var _graphql = require('graphql');
|
||||
|
||||
var _httpErrors = require('http-errors');
|
||||
|
||||
var _httpErrors2 = _interopRequireDefault(_httpErrors);
|
||||
|
||||
var _url = require('url');
|
||||
|
||||
var _url2 = _interopRequireDefault(_url);
|
||||
|
||||
var _parseBody = require('./parseBody');
|
||||
|
||||
var _renderGraphiQL = require('./renderGraphiQL');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Middleware for express; takes an options object or function as input to
|
||||
* configure behavior, and returns an express middleware.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Used to configure the graphqlHTTP middleware by providing a schema
|
||||
* and other configuration options.
|
||||
*
|
||||
* Options can be provided as an Object, a Promise for an Object, or a Function
|
||||
* that returns an Object or a Promise for an Object.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* All information about a GraphQL request.
|
||||
*/
|
||||
module.exports = graphqlHTTP;
|
||||
function graphqlHTTP(options) {
|
||||
if (!options) {
|
||||
throw new Error('GraphQL middleware requires options.');
|
||||
}
|
||||
|
||||
return function graphqlMiddleware(request, response) {
|
||||
// Higher scoped variables are referred to at various stages in the
|
||||
// asynchronous state machine below.
|
||||
var context = void 0;
|
||||
var params = void 0;
|
||||
var pretty = void 0;
|
||||
var formatErrorFn = void 0;
|
||||
var extensionsFn = void 0;
|
||||
var showGraphiQL = void 0;
|
||||
var query = void 0;
|
||||
|
||||
var documentAST = void 0;
|
||||
var variables = void 0;
|
||||
var operationName = void 0;
|
||||
|
||||
// Promises are used as a mechanism for capturing any thrown errors during
|
||||
// the asynchronous process below.
|
||||
|
||||
// Parse the Request to get GraphQL request parameters.
|
||||
return getGraphQLParams(request).then(function (graphQLParams) {
|
||||
params = graphQLParams;
|
||||
// Then, resolve the Options to get OptionsData.
|
||||
return resolveOptions(params);
|
||||
}, function (error) {
|
||||
// When we failed to parse the GraphQL parameters, we still need to get
|
||||
// the options object, so make an options call to resolve just that.
|
||||
var dummyParams = {
|
||||
query: null,
|
||||
variables: null,
|
||||
operationName: null,
|
||||
raw: null
|
||||
};
|
||||
return resolveOptions(dummyParams).then(function () {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
}).then(function (optionsData) {
|
||||
// Assert that schema is required.
|
||||
if (!optionsData.schema) {
|
||||
throw new Error('GraphQL middleware options must contain a schema.');
|
||||
}
|
||||
|
||||
// Collect information from the options data object.
|
||||
var schema = optionsData.schema;
|
||||
var rootValue = optionsData.rootValue;
|
||||
var fieldResolver = optionsData.fieldResolver;
|
||||
var graphiql = optionsData.graphiql;
|
||||
|
||||
context = optionsData.context || request;
|
||||
|
||||
var validationRules = _graphql.specifiedRules;
|
||||
if (optionsData.validationRules) {
|
||||
validationRules = validationRules.concat(optionsData.validationRules);
|
||||
}
|
||||
|
||||
// GraphQL HTTP only supports GET and POST methods.
|
||||
if (request.method !== 'GET' && request.method !== 'POST') {
|
||||
response.setHeader('Allow', 'GET, POST');
|
||||
throw (0, _httpErrors2.default)(405, 'GraphQL only supports GET and POST requests.');
|
||||
}
|
||||
|
||||
// Get GraphQL params from the request and POST body data.
|
||||
query = params.query;
|
||||
variables = params.variables;
|
||||
operationName = params.operationName;
|
||||
showGraphiQL = graphiql && canDisplayGraphiQL(request, params);
|
||||
|
||||
// If there is no query, but GraphiQL will be displayed, do not produce
|
||||
// a result, otherwise return a 400: Bad Request.
|
||||
if (!query) {
|
||||
if (showGraphiQL) {
|
||||
return null;
|
||||
}
|
||||
throw (0, _httpErrors2.default)(400, 'Must provide query string.');
|
||||
}
|
||||
|
||||
// Validate Schema
|
||||
var schemaValidationErrors = (0, _graphql.validateSchema)(schema);
|
||||
if (schemaValidationErrors.length > 0) {
|
||||
// Return 500: Internal Server Error if invalid schema.
|
||||
response.statusCode = 500;
|
||||
return { errors: schemaValidationErrors };
|
||||
}
|
||||
|
||||
// GraphQL source.
|
||||
var source = new _graphql.Source(query, 'GraphQL request');
|
||||
|
||||
// Parse source to AST, reporting any syntax error.
|
||||
try {
|
||||
documentAST = (0, _graphql.parse)(source);
|
||||
} catch (syntaxError) {
|
||||
// Return 400: Bad Request if any syntax errors errors exist.
|
||||
response.statusCode = 400;
|
||||
return { errors: [syntaxError] };
|
||||
}
|
||||
|
||||
// Validate AST, reporting any errors.
|
||||
var validationErrors = (0, _graphql.validate)(schema, documentAST, validationRules);
|
||||
if (validationErrors.length > 0) {
|
||||
// Return 400: Bad Request if any validation errors exist.
|
||||
response.statusCode = 400;
|
||||
return { errors: validationErrors };
|
||||
}
|
||||
|
||||
// Only query operations are allowed on GET requests.
|
||||
if (request.method === 'GET') {
|
||||
// Determine if this GET request will perform a non-query.
|
||||
var operationAST = (0, _graphql.getOperationAST)(documentAST, operationName);
|
||||
if (operationAST && operationAST.operation !== 'query') {
|
||||
// If GraphiQL can be shown, do not perform this query, but
|
||||
// provide it to GraphiQL so that the requester may perform it
|
||||
// themselves if desired.
|
||||
if (showGraphiQL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Otherwise, report a 405: Method Not Allowed error.
|
||||
response.setHeader('Allow', 'POST');
|
||||
throw (0, _httpErrors2.default)(405, 'Can only perform a ' + operationAST.operation + ' operation ' + 'from a POST request.');
|
||||
}
|
||||
}
|
||||
// Perform the execution, reporting any errors creating the context.
|
||||
try {
|
||||
return (0, _graphql.execute)(schema, documentAST, rootValue, context, variables, operationName, fieldResolver);
|
||||
} catch (contextError) {
|
||||
// Return 400: Bad Request if any execution context errors exist.
|
||||
response.statusCode = 400;
|
||||
return { errors: [contextError] };
|
||||
}
|
||||
}).then(function (result) {
|
||||
// Collect and apply any metadata extensions if a function was provided.
|
||||
// http://facebook.github.io/graphql/#sec-Response-Format
|
||||
if (result && extensionsFn) {
|
||||
return Promise.resolve(extensionsFn({
|
||||
document: documentAST,
|
||||
variables: variables,
|
||||
operationName: operationName,
|
||||
result: result,
|
||||
context: context
|
||||
})).then(function (extensions) {
|
||||
if (extensions && (typeof extensions === 'undefined' ? 'undefined' : _typeof(extensions)) === 'object') {
|
||||
result.extensions = extensions;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}).catch(function (error) {
|
||||
// If an error was caught, report the httpError status, or 500.
|
||||
response.statusCode = error.status || 500;
|
||||
return { errors: [error] };
|
||||
}).then(function (result) {
|
||||
// If no data was included in the result, that indicates a runtime query
|
||||
// error, indicate as such with a generic status code.
|
||||
// Note: Information about the error itself will still be contained in
|
||||
// the resulting JSON payload.
|
||||
// http://facebook.github.io/graphql/#sec-Data
|
||||
if (response.statusCode === 200 && result && !result.data) {
|
||||
response.statusCode = 500;
|
||||
}
|
||||
// Format any encountered errors.
|
||||
if (result && result.errors) {
|
||||
result.errors = result.errors.map(formatErrorFn || _graphql.formatError);
|
||||
}
|
||||
|
||||
// If allowed to show GraphiQL, present it instead of JSON.
|
||||
if (showGraphiQL) {
|
||||
var payload = (0, _renderGraphiQL.renderGraphiQL)({
|
||||
query: query,
|
||||
variables: variables,
|
||||
operationName: operationName,
|
||||
result: result
|
||||
});
|
||||
return sendResponse(response, 'text/html', payload);
|
||||
}
|
||||
|
||||
// At this point, result is guaranteed to exist, as the only scenario
|
||||
// where it will not is when showGraphiQL is true.
|
||||
if (!result) {
|
||||
throw (0, _httpErrors2.default)(500, 'Internal Error');
|
||||
}
|
||||
|
||||
// If "pretty" JSON isn't requested, and the server provides a
|
||||
// response.json method (express), use that directly.
|
||||
// Otherwise use the simplified sendResponse method.
|
||||
if (!pretty && typeof response.json === 'function') {
|
||||
response.json(result);
|
||||
} else {
|
||||
var _payload = JSON.stringify(result, null, pretty ? 2 : 0);
|
||||
sendResponse(response, 'application/json', _payload);
|
||||
}
|
||||
});
|
||||
|
||||
function resolveOptions(requestParams) {
|
||||
return Promise.resolve(typeof options === 'function' ? options(request, response, requestParams) : options).then(function (optionsData) {
|
||||
// Assert that optionsData is in fact an Object.
|
||||
if (!optionsData || (typeof optionsData === 'undefined' ? 'undefined' : _typeof(optionsData)) !== 'object') {
|
||||
throw new Error('GraphQL middleware option function must return an options object ' + 'or a promise which will be resolved to an options object.');
|
||||
}
|
||||
|
||||
formatErrorFn = optionsData.formatError;
|
||||
extensionsFn = optionsData.extensions;
|
||||
pretty = optionsData.pretty;
|
||||
return optionsData;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Provided a "Request" provided by express or connect (typically a node style
|
||||
* HTTPClientRequest), Promise the GraphQL request parameters.
|
||||
*/
|
||||
module.exports.getGraphQLParams = getGraphQLParams;
|
||||
function getGraphQLParams(request) {
|
||||
return (0, _parseBody.parseBody)(request).then(function (bodyData) {
|
||||
var urlData = request.url && _url2.default.parse(request.url, true).query || {};
|
||||
return parseGraphQLParams(urlData, bodyData);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the GraphQL params from the request.
|
||||
*/
|
||||
function parseGraphQLParams(urlData, bodyData) {
|
||||
// GraphQL Query string.
|
||||
var query = urlData.query || bodyData.query;
|
||||
if (typeof query !== 'string') {
|
||||
query = null;
|
||||
}
|
||||
|
||||
// Parse the variables if needed.
|
||||
var variables = urlData.variables || bodyData.variables;
|
||||
if (variables && typeof variables === 'string') {
|
||||
try {
|
||||
variables = JSON.parse(variables);
|
||||
} catch (error) {
|
||||
throw (0, _httpErrors2.default)(400, 'Variables are invalid JSON.');
|
||||
}
|
||||
} else if ((typeof variables === 'undefined' ? 'undefined' : _typeof(variables)) !== 'object') {
|
||||
variables = null;
|
||||
}
|
||||
|
||||
// Name of GraphQL operation to execute.
|
||||
var operationName = urlData.operationName || bodyData.operationName;
|
||||
if (typeof operationName !== 'string') {
|
||||
operationName = null;
|
||||
}
|
||||
|
||||
var raw = urlData.raw !== undefined || bodyData.raw !== undefined;
|
||||
|
||||
return { query: query, variables: variables, operationName: operationName, raw: raw };
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine if GraphiQL can be displayed.
|
||||
*/
|
||||
function canDisplayGraphiQL(request, params) {
|
||||
// If `raw` exists, GraphiQL mode is not enabled.
|
||||
// Allowed to show GraphiQL if not requested as raw and this request
|
||||
// prefers HTML over JSON.
|
||||
return !params.raw && (0, _accepts2.default)(request).types(['json', 'html']) === 'html';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for sending a response using only the core Node server APIs.
|
||||
*/
|
||||
function sendResponse(response, type, data) {
|
||||
var chunk = new Buffer(data, 'utf8');
|
||||
response.setHeader('Content-Type', type + '; charset=utf-8');
|
||||
response.setHeader('Content-Length', String(chunk.length));
|
||||
response.end(chunk);
|
||||
}
|
||||
465
node_modules/express-graphql/dist/index.js.flow
generated
vendored
Normal file
465
node_modules/express-graphql/dist/index.js.flow
generated
vendored
Normal file
@ -0,0 +1,465 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
import accepts from 'accepts';
|
||||
import {
|
||||
Source,
|
||||
validateSchema,
|
||||
parse,
|
||||
validate,
|
||||
execute,
|
||||
formatError,
|
||||
getOperationAST,
|
||||
specifiedRules,
|
||||
} from 'graphql';
|
||||
import httpError from 'http-errors';
|
||||
import url from 'url';
|
||||
|
||||
import { parseBody } from './parseBody';
|
||||
import { renderGraphiQL } from './renderGraphiQL';
|
||||
|
||||
import type {
|
||||
DocumentNode,
|
||||
GraphQLError,
|
||||
GraphQLSchema,
|
||||
GraphQLFieldResolver,
|
||||
ValidationContext,
|
||||
ASTVisitor,
|
||||
} from 'graphql';
|
||||
import type { $Request, $Response } from 'express';
|
||||
|
||||
/**
|
||||
* Used to configure the graphqlHTTP middleware by providing a schema
|
||||
* and other configuration options.
|
||||
*
|
||||
* Options can be provided as an Object, a Promise for an Object, or a Function
|
||||
* that returns an Object or a Promise for an Object.
|
||||
*/
|
||||
export type Options =
|
||||
| ((
|
||||
request: $Request,
|
||||
response: $Response,
|
||||
params?: GraphQLParams,
|
||||
) => OptionsResult)
|
||||
| OptionsResult;
|
||||
export type OptionsResult = OptionsData | Promise<OptionsData>;
|
||||
export type OptionsData = {
|
||||
/**
|
||||
* A GraphQL schema from graphql-js.
|
||||
*/
|
||||
schema: GraphQLSchema,
|
||||
|
||||
/**
|
||||
* A value to pass as the context to this middleware.
|
||||
*/
|
||||
context?: ?mixed,
|
||||
|
||||
/**
|
||||
* An object to pass as the rootValue to the graphql() function.
|
||||
*/
|
||||
rootValue?: ?mixed,
|
||||
|
||||
/**
|
||||
* A boolean to configure whether the output should be pretty-printed.
|
||||
*/
|
||||
pretty?: ?boolean,
|
||||
|
||||
/**
|
||||
* 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?: ?(error: GraphQLError) => mixed,
|
||||
|
||||
/**
|
||||
* An optional array of validation rules that will be applied on the document
|
||||
* in additional to those defined by the GraphQL spec.
|
||||
*/
|
||||
validationRules?: ?Array<(ValidationContext) => ASTVisitor>,
|
||||
|
||||
/**
|
||||
* An optional function for adding additional metadata to the GraphQL response
|
||||
* as a key-value object. The result will be added to "extensions" field in
|
||||
* the resulting JSON. This is often a useful place to add development time
|
||||
* info such as the runtime of a query or the amount of resources consumed.
|
||||
*
|
||||
* Information about the request is provided to be used.
|
||||
*
|
||||
* This function may be async.
|
||||
*/
|
||||
extensions?: ?(info: RequestInfo) => { [key: string]: mixed },
|
||||
|
||||
/**
|
||||
* A boolean to optionally enable GraphiQL mode.
|
||||
*/
|
||||
graphiql?: ?boolean,
|
||||
|
||||
/**
|
||||
* A resolver function to use when one is not provided by the schema.
|
||||
* If not provided, the default field resolver is used (which looks for a
|
||||
* value or method on the source value with the field's name).
|
||||
*/
|
||||
fieldResolver?: ?GraphQLFieldResolver<any, any>,
|
||||
};
|
||||
|
||||
/**
|
||||
* All information about a GraphQL request.
|
||||
*/
|
||||
export type RequestInfo = {
|
||||
/**
|
||||
* The parsed GraphQL document.
|
||||
*/
|
||||
document: ?DocumentNode,
|
||||
|
||||
/**
|
||||
* The variable values used at runtime.
|
||||
*/
|
||||
variables: ?{ [name: string]: mixed },
|
||||
|
||||
/**
|
||||
* The (optional) operation name requested.
|
||||
*/
|
||||
operationName: ?string,
|
||||
|
||||
/**
|
||||
* The result of executing the operation.
|
||||
*/
|
||||
result: ?mixed,
|
||||
|
||||
/**
|
||||
* A value to pass as the context to the graphql() function.
|
||||
*/
|
||||
context?: ?mixed,
|
||||
};
|
||||
|
||||
type Middleware = (request: $Request, response: $Response) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Middleware for express; takes an options object or function as input to
|
||||
* configure behavior, and returns an express middleware.
|
||||
*/
|
||||
module.exports = graphqlHTTP;
|
||||
function graphqlHTTP(options: Options): Middleware {
|
||||
if (!options) {
|
||||
throw new Error('GraphQL middleware requires options.');
|
||||
}
|
||||
|
||||
return function graphqlMiddleware(request: $Request, response: $Response) {
|
||||
// Higher scoped variables are referred to at various stages in the
|
||||
// asynchronous state machine below.
|
||||
let context;
|
||||
let params;
|
||||
let pretty;
|
||||
let formatErrorFn;
|
||||
let extensionsFn;
|
||||
let showGraphiQL;
|
||||
let query;
|
||||
|
||||
let documentAST;
|
||||
let variables;
|
||||
let operationName;
|
||||
|
||||
// Promises are used as a mechanism for capturing any thrown errors during
|
||||
// the asynchronous process below.
|
||||
|
||||
// Parse the Request to get GraphQL request parameters.
|
||||
return getGraphQLParams(request)
|
||||
.then(
|
||||
graphQLParams => {
|
||||
params = graphQLParams;
|
||||
// Then, resolve the Options to get OptionsData.
|
||||
return resolveOptions(params);
|
||||
},
|
||||
error => {
|
||||
// When we failed to parse the GraphQL parameters, we still need to get
|
||||
// the options object, so make an options call to resolve just that.
|
||||
const dummyParams = {
|
||||
query: null,
|
||||
variables: null,
|
||||
operationName: null,
|
||||
raw: null,
|
||||
};
|
||||
return resolveOptions(dummyParams).then(() => Promise.reject(error));
|
||||
},
|
||||
)
|
||||
.then(optionsData => {
|
||||
// Assert that schema is required.
|
||||
if (!optionsData.schema) {
|
||||
throw new Error('GraphQL middleware options must contain a schema.');
|
||||
}
|
||||
|
||||
// Collect information from the options data object.
|
||||
const schema = optionsData.schema;
|
||||
const rootValue = optionsData.rootValue;
|
||||
const fieldResolver = optionsData.fieldResolver;
|
||||
const graphiql = optionsData.graphiql;
|
||||
|
||||
context = optionsData.context || request;
|
||||
|
||||
let validationRules = specifiedRules;
|
||||
if (optionsData.validationRules) {
|
||||
validationRules = validationRules.concat(optionsData.validationRules);
|
||||
}
|
||||
|
||||
// GraphQL HTTP only supports GET and POST methods.
|
||||
if (request.method !== 'GET' && request.method !== 'POST') {
|
||||
response.setHeader('Allow', 'GET, POST');
|
||||
throw httpError(405, 'GraphQL only supports GET and POST requests.');
|
||||
}
|
||||
|
||||
// Get GraphQL params from the request and POST body data.
|
||||
query = params.query;
|
||||
variables = params.variables;
|
||||
operationName = params.operationName;
|
||||
showGraphiQL = graphiql && canDisplayGraphiQL(request, params);
|
||||
|
||||
// If there is no query, but GraphiQL will be displayed, do not produce
|
||||
// a result, otherwise return a 400: Bad Request.
|
||||
if (!query) {
|
||||
if (showGraphiQL) {
|
||||
return null;
|
||||
}
|
||||
throw httpError(400, 'Must provide query string.');
|
||||
}
|
||||
|
||||
// Validate Schema
|
||||
const schemaValidationErrors = validateSchema(schema);
|
||||
if (schemaValidationErrors.length > 0) {
|
||||
// Return 500: Internal Server Error if invalid schema.
|
||||
response.statusCode = 500;
|
||||
return { errors: schemaValidationErrors };
|
||||
}
|
||||
|
||||
// GraphQL source.
|
||||
const source = new Source(query, 'GraphQL request');
|
||||
|
||||
// Parse source to AST, reporting any syntax error.
|
||||
try {
|
||||
documentAST = parse(source);
|
||||
} catch (syntaxError) {
|
||||
// Return 400: Bad Request if any syntax errors errors exist.
|
||||
response.statusCode = 400;
|
||||
return { errors: [syntaxError] };
|
||||
}
|
||||
|
||||
// Validate AST, reporting any errors.
|
||||
const validationErrors = validate(schema, documentAST, validationRules);
|
||||
if (validationErrors.length > 0) {
|
||||
// Return 400: Bad Request if any validation errors exist.
|
||||
response.statusCode = 400;
|
||||
return { errors: validationErrors };
|
||||
}
|
||||
|
||||
// Only query operations are allowed on GET requests.
|
||||
if (request.method === 'GET') {
|
||||
// Determine if this GET request will perform a non-query.
|
||||
const operationAST = getOperationAST(documentAST, operationName);
|
||||
if (operationAST && operationAST.operation !== 'query') {
|
||||
// If GraphiQL can be shown, do not perform this query, but
|
||||
// provide it to GraphiQL so that the requester may perform it
|
||||
// themselves if desired.
|
||||
if (showGraphiQL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Otherwise, report a 405: Method Not Allowed error.
|
||||
response.setHeader('Allow', 'POST');
|
||||
throw httpError(
|
||||
405,
|
||||
`Can only perform a ${operationAST.operation} operation ` +
|
||||
'from a POST request.',
|
||||
);
|
||||
}
|
||||
}
|
||||
// Perform the execution, reporting any errors creating the context.
|
||||
try {
|
||||
return execute(
|
||||
schema,
|
||||
documentAST,
|
||||
rootValue,
|
||||
context,
|
||||
variables,
|
||||
operationName,
|
||||
fieldResolver,
|
||||
);
|
||||
} catch (contextError) {
|
||||
// Return 400: Bad Request if any execution context errors exist.
|
||||
response.statusCode = 400;
|
||||
return { errors: [contextError] };
|
||||
}
|
||||
})
|
||||
.then(result => {
|
||||
// Collect and apply any metadata extensions if a function was provided.
|
||||
// http://facebook.github.io/graphql/#sec-Response-Format
|
||||
if (result && extensionsFn) {
|
||||
return Promise.resolve(
|
||||
extensionsFn({
|
||||
document: documentAST,
|
||||
variables,
|
||||
operationName,
|
||||
result,
|
||||
context,
|
||||
}),
|
||||
).then(extensions => {
|
||||
if (extensions && typeof extensions === 'object') {
|
||||
(result: any).extensions = extensions;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
return result;
|
||||
})
|
||||
.catch(error => {
|
||||
// If an error was caught, report the httpError status, or 500.
|
||||
response.statusCode = error.status || 500;
|
||||
return { errors: [error] };
|
||||
})
|
||||
.then(result => {
|
||||
// If no data was included in the result, that indicates a runtime query
|
||||
// error, indicate as such with a generic status code.
|
||||
// Note: Information about the error itself will still be contained in
|
||||
// the resulting JSON payload.
|
||||
// http://facebook.github.io/graphql/#sec-Data
|
||||
if (response.statusCode === 200 && result && !result.data) {
|
||||
response.statusCode = 500;
|
||||
}
|
||||
// Format any encountered errors.
|
||||
if (result && result.errors) {
|
||||
(result: any).errors = result.errors.map(
|
||||
formatErrorFn || formatError,
|
||||
);
|
||||
}
|
||||
|
||||
// If allowed to show GraphiQL, present it instead of JSON.
|
||||
if (showGraphiQL) {
|
||||
const payload = renderGraphiQL({
|
||||
query,
|
||||
variables,
|
||||
operationName,
|
||||
result,
|
||||
});
|
||||
return sendResponse(response, 'text/html', payload);
|
||||
}
|
||||
|
||||
// At this point, result is guaranteed to exist, as the only scenario
|
||||
// where it will not is when showGraphiQL is true.
|
||||
if (!result) {
|
||||
throw httpError(500, 'Internal Error');
|
||||
}
|
||||
|
||||
// If "pretty" JSON isn't requested, and the server provides a
|
||||
// response.json method (express), use that directly.
|
||||
// Otherwise use the simplified sendResponse method.
|
||||
if (!pretty && typeof response.json === 'function') {
|
||||
response.json(result);
|
||||
} else {
|
||||
const payload = JSON.stringify(result, null, pretty ? 2 : 0);
|
||||
sendResponse(response, 'application/json', payload);
|
||||
}
|
||||
});
|
||||
|
||||
function resolveOptions(requestParams) {
|
||||
return Promise.resolve(
|
||||
typeof options === 'function'
|
||||
? options(request, response, requestParams)
|
||||
: options,
|
||||
).then(optionsData => {
|
||||
// Assert that optionsData is in fact an Object.
|
||||
if (!optionsData || typeof optionsData !== 'object') {
|
||||
throw new Error(
|
||||
'GraphQL middleware option function must return an options object ' +
|
||||
'or a promise which will be resolved to an options object.',
|
||||
);
|
||||
}
|
||||
|
||||
formatErrorFn = optionsData.formatError;
|
||||
extensionsFn = optionsData.extensions;
|
||||
pretty = optionsData.pretty;
|
||||
return optionsData;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export type GraphQLParams = {
|
||||
query: ?string,
|
||||
variables: ?{ [name: string]: mixed },
|
||||
operationName: ?string,
|
||||
raw: ?boolean,
|
||||
};
|
||||
|
||||
/**
|
||||
* Provided a "Request" provided by express or connect (typically a node style
|
||||
* HTTPClientRequest), Promise the GraphQL request parameters.
|
||||
*/
|
||||
module.exports.getGraphQLParams = getGraphQLParams;
|
||||
function getGraphQLParams(request: $Request): Promise<GraphQLParams> {
|
||||
return parseBody(request).then(bodyData => {
|
||||
const urlData = (request.url && url.parse(request.url, true).query) || {};
|
||||
return parseGraphQLParams(urlData, bodyData);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the GraphQL params from the request.
|
||||
*/
|
||||
function parseGraphQLParams(
|
||||
urlData: { [param: string]: mixed },
|
||||
bodyData: { [param: string]: mixed },
|
||||
): GraphQLParams {
|
||||
// GraphQL Query string.
|
||||
let query = urlData.query || bodyData.query;
|
||||
if (typeof query !== 'string') {
|
||||
query = null;
|
||||
}
|
||||
|
||||
// Parse the variables if needed.
|
||||
let variables = urlData.variables || bodyData.variables;
|
||||
if (variables && typeof variables === 'string') {
|
||||
try {
|
||||
variables = JSON.parse(variables);
|
||||
} catch (error) {
|
||||
throw httpError(400, 'Variables are invalid JSON.');
|
||||
}
|
||||
} else if (typeof variables !== 'object') {
|
||||
variables = null;
|
||||
}
|
||||
|
||||
// Name of GraphQL operation to execute.
|
||||
let operationName = urlData.operationName || bodyData.operationName;
|
||||
if (typeof operationName !== 'string') {
|
||||
operationName = null;
|
||||
}
|
||||
|
||||
const raw = urlData.raw !== undefined || bodyData.raw !== undefined;
|
||||
|
||||
return { query, variables, operationName, raw };
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine if GraphiQL can be displayed.
|
||||
*/
|
||||
function canDisplayGraphiQL(request: $Request, params: GraphQLParams): boolean {
|
||||
// If `raw` exists, GraphiQL mode is not enabled.
|
||||
// Allowed to show GraphiQL if not requested as raw and this request
|
||||
// prefers HTML over JSON.
|
||||
return !params.raw && accepts(request).types(['json', 'html']) === 'html';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for sending a response using only the core Node server APIs.
|
||||
*/
|
||||
function sendResponse(response: $Response, type: string, data: string): void {
|
||||
const chunk = new Buffer(data, 'utf8');
|
||||
response.setHeader('Content-Type', type + '; charset=utf-8');
|
||||
response.setHeader('Content-Length', String(chunk.length));
|
||||
response.end(chunk);
|
||||
}
|
||||
162
node_modules/express-graphql/dist/parseBody.js
generated
vendored
Normal file
162
node_modules/express-graphql/dist/parseBody.js
generated
vendored
Normal file
@ -0,0 +1,162 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* strict
|
||||
*/
|
||||
|
||||
exports.parseBody = parseBody;
|
||||
|
||||
var _contentType = require('content-type');
|
||||
|
||||
var _contentType2 = _interopRequireDefault(_contentType);
|
||||
|
||||
var _rawBody = require('raw-body');
|
||||
|
||||
var _rawBody2 = _interopRequireDefault(_rawBody);
|
||||
|
||||
var _httpErrors = require('http-errors');
|
||||
|
||||
var _httpErrors2 = _interopRequireDefault(_httpErrors);
|
||||
|
||||
var _querystring = require('querystring');
|
||||
|
||||
var _querystring2 = _interopRequireDefault(_querystring);
|
||||
|
||||
var _zlib = require('zlib');
|
||||
|
||||
var _zlib2 = _interopRequireDefault(_zlib);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Provided a "Request" provided by express or connect (typically a node style
|
||||
* HTTPClientRequest), Promise the body data contained.
|
||||
*/
|
||||
function parseBody(req) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var body = req.body;
|
||||
|
||||
// If express has already parsed a body as a keyed object, use it.
|
||||
if ((typeof body === 'undefined' ? 'undefined' : _typeof(body)) === 'object' && !(body instanceof Buffer)) {
|
||||
return resolve(body);
|
||||
}
|
||||
|
||||
// Skip requests without content types.
|
||||
if (req.headers['content-type'] === undefined) {
|
||||
return resolve({});
|
||||
}
|
||||
|
||||
var typeInfo = _contentType2.default.parse(req);
|
||||
|
||||
// If express has already parsed a body as a string, and the content-type
|
||||
// was application/graphql, parse the string body.
|
||||
if (typeof body === 'string' && typeInfo.type === 'application/graphql') {
|
||||
return resolve(graphqlParser(body));
|
||||
}
|
||||
|
||||
// Already parsed body we didn't recognise? Parse nothing.
|
||||
if (body) {
|
||||
return resolve({});
|
||||
}
|
||||
|
||||
// Use the correct body parser based on Content-Type header.
|
||||
switch (typeInfo.type) {
|
||||
case 'application/graphql':
|
||||
return read(req, typeInfo, graphqlParser, resolve, reject);
|
||||
case 'application/json':
|
||||
return read(req, typeInfo, jsonEncodedParser, resolve, reject);
|
||||
case 'application/x-www-form-urlencoded':
|
||||
return read(req, typeInfo, urlEncodedParser, resolve, reject);
|
||||
}
|
||||
|
||||
// If no Content-Type header matches, parse nothing.
|
||||
return resolve({});
|
||||
});
|
||||
}
|
||||
|
||||
function jsonEncodedParser(body) {
|
||||
if (jsonObjRegex.test(body)) {
|
||||
/* eslint-disable no-empty */
|
||||
try {
|
||||
return JSON.parse(body);
|
||||
} catch (error) {}
|
||||
// Do nothing
|
||||
|
||||
/* eslint-enable no-empty */
|
||||
}
|
||||
throw (0, _httpErrors2.default)(400, 'POST body sent invalid JSON.');
|
||||
}
|
||||
|
||||
function urlEncodedParser(body) {
|
||||
return _querystring2.default.parse(body);
|
||||
}
|
||||
|
||||
function graphqlParser(body) {
|
||||
return { query: body };
|
||||
}
|
||||
|
||||
/**
|
||||
* RegExp to match an Object-opening brace "{" as the first non-space
|
||||
* in a string. Allowed whitespace is defined in RFC 7159:
|
||||
*
|
||||
* x20 Space
|
||||
* x09 Horizontal tab
|
||||
* x0A Line feed or New line
|
||||
* x0D Carriage return
|
||||
*/
|
||||
var jsonObjRegex = /^[\x20\x09\x0a\x0d]*\{/;
|
||||
|
||||
// Read and parse a request body.
|
||||
function read(req, typeInfo, parseFn, resolve, reject) {
|
||||
var charset = (typeInfo.parameters.charset || 'utf-8').toLowerCase();
|
||||
|
||||
// Assert charset encoding per JSON RFC 7159 sec 8.1
|
||||
if (charset.slice(0, 4) !== 'utf-') {
|
||||
throw (0, _httpErrors2.default)(415, 'Unsupported charset "' + charset.toUpperCase() + '".');
|
||||
}
|
||||
|
||||
// Get content-encoding (e.g. gzip)
|
||||
var contentEncoding = req.headers['content-encoding'];
|
||||
var encoding = typeof contentEncoding === 'string' ? contentEncoding.toLowerCase() : 'identity';
|
||||
var length = encoding === 'identity' ? req.headers['content-length'] : null;
|
||||
var limit = 100 * 1024; // 100kb
|
||||
var stream = decompressed(req, encoding);
|
||||
|
||||
// Read body from stream.
|
||||
(0, _rawBody2.default)(stream, { encoding: charset, length: length, limit: limit }, function (err, body) {
|
||||
if (err) {
|
||||
return reject(err.type === 'encoding.unsupported' ? (0, _httpErrors2.default)(415, 'Unsupported charset "' + charset.toUpperCase() + '".') : (0, _httpErrors2.default)(400, 'Invalid body: ' + err.message + '.'));
|
||||
}
|
||||
|
||||
try {
|
||||
// Decode and parse body.
|
||||
return resolve(parseFn(body));
|
||||
} catch (error) {
|
||||
return reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Return a decompressed stream, given an encoding.
|
||||
function decompressed(req, encoding) {
|
||||
switch (encoding) {
|
||||
case 'identity':
|
||||
return req;
|
||||
case 'deflate':
|
||||
return req.pipe(_zlib2.default.createInflate());
|
||||
case 'gzip':
|
||||
return req.pipe(_zlib2.default.createGunzip());
|
||||
}
|
||||
throw (0, _httpErrors2.default)(415, 'Unsupported content-encoding "' + encoding + '".');
|
||||
}
|
||||
147
node_modules/express-graphql/dist/parseBody.js.flow
generated
vendored
Normal file
147
node_modules/express-graphql/dist/parseBody.js.flow
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
import contentType from 'content-type';
|
||||
import getBody from 'raw-body';
|
||||
import httpError from 'http-errors';
|
||||
import querystring from 'querystring';
|
||||
import zlib from 'zlib';
|
||||
|
||||
import type { $Request } from 'express';
|
||||
|
||||
/**
|
||||
* Provided a "Request" provided by express or connect (typically a node style
|
||||
* HTTPClientRequest), Promise the body data contained.
|
||||
*/
|
||||
export function parseBody(req: $Request): Promise<{ [param: string]: mixed }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const body = req.body;
|
||||
|
||||
// If express has already parsed a body as a keyed object, use it.
|
||||
if (typeof body === 'object' && !(body instanceof Buffer)) {
|
||||
return resolve((body: any));
|
||||
}
|
||||
|
||||
// Skip requests without content types.
|
||||
if (req.headers['content-type'] === undefined) {
|
||||
return resolve({});
|
||||
}
|
||||
|
||||
const typeInfo = contentType.parse(req);
|
||||
|
||||
// If express has already parsed a body as a string, and the content-type
|
||||
// was application/graphql, parse the string body.
|
||||
if (typeof body === 'string' && typeInfo.type === 'application/graphql') {
|
||||
return resolve(graphqlParser(body));
|
||||
}
|
||||
|
||||
// Already parsed body we didn't recognise? Parse nothing.
|
||||
if (body) {
|
||||
return resolve({});
|
||||
}
|
||||
|
||||
// Use the correct body parser based on Content-Type header.
|
||||
switch (typeInfo.type) {
|
||||
case 'application/graphql':
|
||||
return read(req, typeInfo, graphqlParser, resolve, reject);
|
||||
case 'application/json':
|
||||
return read(req, typeInfo, jsonEncodedParser, resolve, reject);
|
||||
case 'application/x-www-form-urlencoded':
|
||||
return read(req, typeInfo, urlEncodedParser, resolve, reject);
|
||||
}
|
||||
|
||||
// If no Content-Type header matches, parse nothing.
|
||||
return resolve({});
|
||||
});
|
||||
}
|
||||
|
||||
function jsonEncodedParser(body) {
|
||||
if (jsonObjRegex.test(body)) {
|
||||
/* eslint-disable no-empty */
|
||||
try {
|
||||
return JSON.parse(body);
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
/* eslint-enable no-empty */
|
||||
}
|
||||
throw httpError(400, 'POST body sent invalid JSON.');
|
||||
}
|
||||
|
||||
function urlEncodedParser(body) {
|
||||
return querystring.parse(body);
|
||||
}
|
||||
|
||||
function graphqlParser(body) {
|
||||
return { query: body };
|
||||
}
|
||||
|
||||
/**
|
||||
* RegExp to match an Object-opening brace "{" as the first non-space
|
||||
* in a string. Allowed whitespace is defined in RFC 7159:
|
||||
*
|
||||
* x20 Space
|
||||
* x09 Horizontal tab
|
||||
* x0A Line feed or New line
|
||||
* x0D Carriage return
|
||||
*/
|
||||
const jsonObjRegex = /^[\x20\x09\x0a\x0d]*\{/;
|
||||
|
||||
// Read and parse a request body.
|
||||
function read(req, typeInfo, parseFn, resolve, reject) {
|
||||
const charset = (typeInfo.parameters.charset || 'utf-8').toLowerCase();
|
||||
|
||||
// Assert charset encoding per JSON RFC 7159 sec 8.1
|
||||
if (charset.slice(0, 4) !== 'utf-') {
|
||||
throw httpError(415, `Unsupported charset "${charset.toUpperCase()}".`);
|
||||
}
|
||||
|
||||
// Get content-encoding (e.g. gzip)
|
||||
const contentEncoding = req.headers['content-encoding'];
|
||||
const encoding =
|
||||
typeof contentEncoding === 'string'
|
||||
? contentEncoding.toLowerCase()
|
||||
: 'identity';
|
||||
const length = encoding === 'identity' ? req.headers['content-length'] : null;
|
||||
const limit = 100 * 1024; // 100kb
|
||||
const stream = decompressed(req, encoding);
|
||||
|
||||
// Read body from stream.
|
||||
getBody(stream, { encoding: charset, length, limit }, (err, body) => {
|
||||
if (err) {
|
||||
return reject(
|
||||
err.type === 'encoding.unsupported'
|
||||
? httpError(415, `Unsupported charset "${charset.toUpperCase()}".`)
|
||||
: httpError(400, `Invalid body: ${err.message}.`),
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
// Decode and parse body.
|
||||
return resolve(parseFn(body));
|
||||
} catch (error) {
|
||||
return reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Return a decompressed stream, given an encoding.
|
||||
function decompressed(req, encoding) {
|
||||
switch (encoding) {
|
||||
case 'identity':
|
||||
return req;
|
||||
case 'deflate':
|
||||
return req.pipe(zlib.createInflate());
|
||||
case 'gzip':
|
||||
return req.pipe(zlib.createGunzip());
|
||||
}
|
||||
throw httpError(415, `Unsupported content-encoding "${encoding}".`);
|
||||
}
|
||||
42
node_modules/express-graphql/dist/renderGraphiQL.js
generated
vendored
Normal file
42
node_modules/express-graphql/dist/renderGraphiQL.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.renderGraphiQL = renderGraphiQL;
|
||||
|
||||
|
||||
// Current latest version of GraphiQL.
|
||||
var GRAPHIQL_VERSION = '0.12.0';
|
||||
|
||||
// Ensures string values are safe to be used within a <script> tag.
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* strict
|
||||
*/
|
||||
|
||||
function safeSerialize(data) {
|
||||
return data ? JSON.stringify(data).replace(/\//g, '\\/') : 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* When express-graphql receives a request which does not Accept JSON, but does
|
||||
* Accept HTML, it may present GraphiQL, the in-browser GraphQL explorer IDE.
|
||||
*
|
||||
* When shown, it will be pre-populated with the result of having executed the
|
||||
* requested query.
|
||||
*/
|
||||
function renderGraphiQL(data) {
|
||||
var queryString = data.query;
|
||||
var variablesString = data.variables ? JSON.stringify(data.variables, null, 2) : null;
|
||||
var resultString = data.result ? JSON.stringify(data.result, null, 2) : null;
|
||||
var operationName = data.operationName;
|
||||
|
||||
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 <meta charset="utf-8" />\n <title>GraphiQL</title>\n <meta name="robots" content="noindex" />\n <meta name="referrer" content="origin" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n body {\n margin: 0;\n overflow: hidden;\n }\n #graphiql {\n height: 100vh;\n }\n </style>\n <link href="//cdn.jsdelivr.net/npm/graphiql@' + GRAPHIQL_VERSION + '/graphiql.css" rel="stylesheet" />\n <script src="//cdn.jsdelivr.net/es6-promise/4.0.5/es6-promise.auto.min.js"></script>\n <script src="//cdn.jsdelivr.net/fetch/0.9.0/fetch.min.js"></script>\n <script src="//cdn.jsdelivr.net/react/15.4.2/react.min.js"></script>\n <script src="//cdn.jsdelivr.net/react/15.4.2/react-dom.min.js"></script>\n <script src="//cdn.jsdelivr.net/npm/graphiql@' + GRAPHIQL_VERSION + '/graphiql.min.js"></script>\n</head>\n<body>\n <div id="graphiql">Loading...</div>\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).filter(function (key) {\n return Boolean(params[key]);\n }).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 onEditOperationName(newOperationName) {\n parameters.operationName = newOperationName;\n updateURL();\n }\n\n function updateURL() {\n history.replaceState(null, null, locationQuery(parameters));\n }\n\n // Render <GraphiQL /> into the body.\n ReactDOM.render(\n React.createElement(GraphiQL, {\n fetcher: graphQLFetcher,\n onEditQuery: onEditQuery,\n onEditVariables: onEditVariables,\n onEditOperationName: onEditOperationName,\n query: ' + safeSerialize(queryString) + ',\n response: ' + safeSerialize(resultString) + ',\n variables: ' + safeSerialize(variablesString) + ',\n operationName: ' + safeSerialize(operationName) + ',\n }),\n document.getElementById(\'graphiql\')\n );\n </script>\n</body>\n</html>';
|
||||
}
|
||||
167
node_modules/express-graphql/dist/renderGraphiQL.js.flow
generated
vendored
Normal file
167
node_modules/express-graphql/dist/renderGraphiQL.js.flow
generated
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
type GraphiQLData = {
|
||||
query: ?string,
|
||||
variables: ?{ [name: string]: mixed },
|
||||
operationName: ?string,
|
||||
result?: mixed,
|
||||
};
|
||||
|
||||
// Current latest version of GraphiQL.
|
||||
const GRAPHIQL_VERSION = '0.12.0';
|
||||
|
||||
// Ensures string values are safe to be used within a <script> tag.
|
||||
function safeSerialize(data) {
|
||||
return data ? JSON.stringify(data).replace(/\//g, '\\/') : 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* When express-graphql receives a request which does not Accept JSON, but does
|
||||
* Accept HTML, it may present GraphiQL, the in-browser GraphQL explorer IDE.
|
||||
*
|
||||
* When shown, it will be pre-populated with the result of having executed the
|
||||
* requested query.
|
||||
*/
|
||||
export function renderGraphiQL(data: GraphiQLData): string {
|
||||
const queryString = data.query;
|
||||
const variablesString = data.variables
|
||||
? JSON.stringify(data.variables, null, 2)
|
||||
: null;
|
||||
const resultString = data.result
|
||||
? JSON.stringify(data.result, null, 2)
|
||||
: null;
|
||||
const operationName = data.operationName;
|
||||
|
||||
return `<!--
|
||||
The request to this GraphQL server provided the header "Accept: text/html"
|
||||
and as a result has been presented GraphiQL - an in-browser IDE for
|
||||
exploring GraphQL.
|
||||
|
||||
If you wish to receive JSON, provide the header "Accept: application/json" or
|
||||
add "&raw" to the end of the URL within a browser.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>GraphiQL</title>
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta name="referrer" content="origin" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
#graphiql {
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
||||
<link href="//cdn.jsdelivr.net/npm/graphiql@${GRAPHIQL_VERSION}/graphiql.css" rel="stylesheet" />
|
||||
<script src="//cdn.jsdelivr.net/es6-promise/4.0.5/es6-promise.auto.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/fetch/0.9.0/fetch.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/react/15.4.2/react.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/react/15.4.2/react-dom.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/graphiql@${GRAPHIQL_VERSION}/graphiql.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="graphiql">Loading...</div>
|
||||
<script>
|
||||
// Collect the URL parameters
|
||||
var parameters = {};
|
||||
window.location.search.substr(1).split('&').forEach(function (entry) {
|
||||
var eq = entry.indexOf('=');
|
||||
if (eq >= 0) {
|
||||
parameters[decodeURIComponent(entry.slice(0, eq))] =
|
||||
decodeURIComponent(entry.slice(eq + 1));
|
||||
}
|
||||
});
|
||||
|
||||
// Produce a Location query string from a parameter object.
|
||||
function locationQuery(params) {
|
||||
return '?' + Object.keys(params).filter(function (key) {
|
||||
return Boolean(params[key]);
|
||||
}).map(function (key) {
|
||||
return encodeURIComponent(key) + '=' +
|
||||
encodeURIComponent(params[key]);
|
||||
}).join('&');
|
||||
}
|
||||
|
||||
// Derive a fetch URL from the current URL, sans the GraphQL parameters.
|
||||
var graphqlParamNames = {
|
||||
query: true,
|
||||
variables: true,
|
||||
operationName: true
|
||||
};
|
||||
|
||||
var otherParams = {};
|
||||
for (var k in parameters) {
|
||||
if (parameters.hasOwnProperty(k) && graphqlParamNames[k] !== true) {
|
||||
otherParams[k] = parameters[k];
|
||||
}
|
||||
}
|
||||
var fetchURL = locationQuery(otherParams);
|
||||
|
||||
// Defines a GraphQL fetcher using the fetch API.
|
||||
function graphQLFetcher(graphQLParams) {
|
||||
return fetch(fetchURL, {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(graphQLParams),
|
||||
credentials: 'include',
|
||||
}).then(function (response) {
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
|
||||
// When the query and variables string is edited, update the URL bar so
|
||||
// that it can be easily shared.
|
||||
function onEditQuery(newQuery) {
|
||||
parameters.query = newQuery;
|
||||
updateURL();
|
||||
}
|
||||
|
||||
function onEditVariables(newVariables) {
|
||||
parameters.variables = newVariables;
|
||||
updateURL();
|
||||
}
|
||||
|
||||
function onEditOperationName(newOperationName) {
|
||||
parameters.operationName = newOperationName;
|
||||
updateURL();
|
||||
}
|
||||
|
||||
function updateURL() {
|
||||
history.replaceState(null, null, locationQuery(parameters));
|
||||
}
|
||||
|
||||
// Render <GraphiQL /> into the body.
|
||||
ReactDOM.render(
|
||||
React.createElement(GraphiQL, {
|
||||
fetcher: graphQLFetcher,
|
||||
onEditQuery: onEditQuery,
|
||||
onEditVariables: onEditVariables,
|
||||
onEditOperationName: onEditOperationName,
|
||||
query: ${safeSerialize(queryString)},
|
||||
response: ${safeSerialize(resultString)},
|
||||
variables: ${safeSerialize(variablesString)},
|
||||
operationName: ${safeSerialize(operationName)},
|
||||
}),
|
||||
document.getElementById('graphiql')
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
126
node_modules/express-graphql/package.json
generated
vendored
Normal file
126
node_modules/express-graphql/package.json
generated
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
{
|
||||
"_from": "express-graphql@^0.7.1",
|
||||
"_id": "express-graphql@0.7.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-YpheAqTbSKpb5h57rV2yu2dPNUBi4FvZDspZ5iEV3ov34PBRgnM4lEBkv60+vZRJ6SweYL14N8AGYdov7g6ooQ==",
|
||||
"_location": "/express-graphql",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "express-graphql@^0.7.1",
|
||||
"name": "express-graphql",
|
||||
"escapedName": "express-graphql",
|
||||
"rawSpec": "^0.7.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.7.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gatsby"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/express-graphql/-/express-graphql-0.7.1.tgz",
|
||||
"_shasum": "6c7712ee966c3aba1930e064ea4c8181e56fd3ef",
|
||||
"_spec": "express-graphql@^0.7.1",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/gatsby",
|
||||
"babel": {
|
||||
"presets": [
|
||||
"es2015"
|
||||
],
|
||||
"plugins": [
|
||||
"transform-class-properties",
|
||||
"transform-flow-strip-types"
|
||||
]
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/graphql/express-graphql/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"accepts": "^1.3.5",
|
||||
"content-type": "^1.0.4",
|
||||
"http-errors": "^1.7.1",
|
||||
"raw-body": "^2.3.3"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Production ready GraphQL HTTP middleware.",
|
||||
"devDependencies": {
|
||||
"babel-cli": "6.26.0",
|
||||
"babel-eslint": "10.0.1",
|
||||
"babel-plugin-transform-async-to-generator": "6.24.1",
|
||||
"babel-plugin-transform-class-properties": "6.24.1",
|
||||
"babel-plugin-transform-flow-strip-types": "6.22.0",
|
||||
"babel-plugin-transform-runtime": "6.23.0",
|
||||
"babel-preset-es2015": "6.24.1",
|
||||
"babel-register": "6.26.0",
|
||||
"babel-runtime": "6.26.0",
|
||||
"body-parser": "1.18.3",
|
||||
"chai": "4.2.0",
|
||||
"connect": "3.6.6",
|
||||
"coveralls": "3.0.2",
|
||||
"eslint": "5.6.1",
|
||||
"eslint-plugin-flowtype": "2.50.3",
|
||||
"eslint-plugin-prettier": "3.0.0",
|
||||
"express": "4.16.4",
|
||||
"flow-bin": "0.83.0",
|
||||
"graphql": "14.0.2",
|
||||
"isparta": "4.1.0",
|
||||
"mocha": "5.2.0",
|
||||
"multer": "1.4.1",
|
||||
"prettier": "1.14.3",
|
||||
"restify": "4.3.2",
|
||||
"sane": "4.0.1",
|
||||
"sinon": "6.3.5",
|
||||
"supertest": "3.3.0"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "./dist"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.x"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"README.md",
|
||||
"LICENSE",
|
||||
"PATENTS"
|
||||
],
|
||||
"homepage": "https://github.com/graphql/express-graphql#readme",
|
||||
"keywords": [
|
||||
"express",
|
||||
"restify",
|
||||
"connect",
|
||||
"http",
|
||||
"graphql",
|
||||
"middleware",
|
||||
"api"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "dist/index.js",
|
||||
"name": "express-graphql",
|
||||
"options": {
|
||||
"mocha": "--require resources/mocha-bootload src/**/__tests__/**/*.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/graphql/express-graphql.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -rf dist/* && babel src --ignore __tests__ --out-dir dist && npm run build:flow",
|
||||
"build:flow": "find ./src -name '*.js' -not -path '*/__tests__*' | while read filepath; do cp $filepath `echo $filepath | sed 's/\\/src\\//\\/dist\\//g'`.flow; done",
|
||||
"check": "flow check",
|
||||
"cover": "babel-node node_modules/.bin/isparta cover --root src --report html node_modules/.bin/_mocha -- $npm_package_options_mocha",
|
||||
"cover:lcov": "babel-node node_modules/.bin/isparta cover --root src --report lcovonly node_modules/.bin/_mocha -- $npm_package_options_mocha",
|
||||
"lint": "eslint src",
|
||||
"prepublish": ". ./resources/prepublish.sh",
|
||||
"prettier": "prettier --write 'src/**/*.js'",
|
||||
"preversion": "npm test",
|
||||
"start": "babel-node examples/index.js",
|
||||
"test": "npm run lint && npm run check && npm run testonly",
|
||||
"testonly": "mocha $npm_package_options_mocha",
|
||||
"watch": "node resources/watch.js"
|
||||
},
|
||||
"version": "0.7.1"
|
||||
}
|
||||
Reference in New Issue
Block a user