config.graphiql-subscriptions-fetcher.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-router Show documentation
Show all versions of graphql-router Show documentation
A route handler for GraphQL endpoint
The newest version!
var GraphiQLSubscriptionsFetcher =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 37);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _GraphQLError = __webpack_require__(13);
Object.defineProperty(exports, 'GraphQLError', {
enumerable: true,
get: function get() {
return _GraphQLError.GraphQLError;
}
});
var _syntaxError = __webpack_require__(40);
Object.defineProperty(exports, 'syntaxError', {
enumerable: true,
get: function get() {
return _syntaxError.syntaxError;
}
});
var _locatedError = __webpack_require__(39);
Object.defineProperty(exports, 'locatedError', {
enumerable: true,
get: function get() {
return _locatedError.locatedError;
}
});
var _formatError = __webpack_require__(38);
Object.defineProperty(exports, 'formatError', {
enumerable: true,
get: function get() {
return _formatError.formatError;
}
});
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GraphQLNonNull = exports.GraphQLList = exports.GraphQLInputObjectType = exports.GraphQLEnumType = exports.GraphQLUnionType = exports.GraphQLInterfaceType = exports.GraphQLObjectType = exports.GraphQLScalarType = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.isType = isType;
exports.assertType = assertType;
exports.isInputType = isInputType;
exports.assertInputType = assertInputType;
exports.isOutputType = isOutputType;
exports.assertOutputType = assertOutputType;
exports.isLeafType = isLeafType;
exports.assertLeafType = assertLeafType;
exports.isCompositeType = isCompositeType;
exports.assertCompositeType = assertCompositeType;
exports.isAbstractType = isAbstractType;
exports.assertAbstractType = assertAbstractType;
exports.getNullableType = getNullableType;
exports.isNamedType = isNamedType;
exports.assertNamedType = assertNamedType;
exports.getNamedType = getNamedType;
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _isNullish = __webpack_require__(6);
var _isNullish2 = _interopRequireDefault(_isNullish);
var _kinds = __webpack_require__(2);
var _assertValidName = __webpack_require__(28);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2015, 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.
*/
// Predicates & Assertions
/**
* These are all of the possible kinds of types.
*/
function isType(type) {
return type instanceof GraphQLScalarType || type instanceof GraphQLObjectType || type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType || type instanceof GraphQLEnumType || type instanceof GraphQLInputObjectType || type instanceof GraphQLList || type instanceof GraphQLNonNull;
}
function assertType(type) {
(0, _invariant2.default)(isType(type), 'Expected ' + String(type) + ' to be a GraphQL type.');
return type;
}
/**
* These types may be used as input types for arguments and directives.
*/
function isInputType(type) {
var namedType = getNamedType(type);
return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLEnumType || namedType instanceof GraphQLInputObjectType;
}
function assertInputType(type) {
(0, _invariant2.default)(isInputType(type), 'Expected ' + String(type) + ' to be a GraphQL input type.');
return type;
}
/**
* These types may be used as output types as the result of fields.
*/
function isOutputType(type) {
var namedType = getNamedType(type);
return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLObjectType || namedType instanceof GraphQLInterfaceType || namedType instanceof GraphQLUnionType || namedType instanceof GraphQLEnumType;
}
function assertOutputType(type) {
(0, _invariant2.default)(isOutputType(type), 'Expected ' + String(type) + ' to be a GraphQL output type.');
return type;
}
/**
* These types may describe types which may be leaf values.
*/
function isLeafType(type) {
var namedType = getNamedType(type);
return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLEnumType;
}
function assertLeafType(type) {
(0, _invariant2.default)(isLeafType(type), 'Expected ' + String(type) + ' to be a GraphQL leaf type.');
return type;
}
/**
* These types may describe the parent context of a selection set.
*/
function isCompositeType(type) {
return type instanceof GraphQLObjectType || type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType;
}
function assertCompositeType(type) {
(0, _invariant2.default)(isCompositeType(type), 'Expected ' + String(type) + ' to be a GraphQL composite type.');
return type;
}
/**
* These types may describe the parent context of a selection set.
*/
function isAbstractType(type) {
return type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType;
}
function assertAbstractType(type) {
(0, _invariant2.default)(isAbstractType(type), 'Expected ' + String(type) + ' to be a GraphQL abstract type.');
return type;
}
/**
* These types can all accept null as a value.
*/
function getNullableType(type) {
return type instanceof GraphQLNonNull ? type.ofType : type;
}
/**
* These named types do not include modifiers like List or NonNull.
*/
function isNamedType(type) {
return type instanceof GraphQLScalarType || type instanceof GraphQLObjectType || type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType || type instanceof GraphQLEnumType || type instanceof GraphQLInputObjectType;
}
function assertNamedType(type) {
(0, _invariant2.default)(isNamedType(type), 'Expected ' + String(type) + ' to be a GraphQL named type.');
return type;
}
function getNamedType(type) {
var unmodifiedType = type;
while (unmodifiedType instanceof GraphQLList || unmodifiedType instanceof GraphQLNonNull) {
unmodifiedType = unmodifiedType.ofType;
}
return unmodifiedType;
}
/**
* Used while defining GraphQL types to allow for circular references in
* otherwise immutable type definitions.
*/
function resolveThunk(thunk) {
return typeof thunk === 'function' ? thunk() : thunk;
}
/**
* Scalar Type Definition
*
* The leaf values of any request and input values to arguments are
* Scalars (or Enums) and are defined with a name and a series of functions
* used to parse input from ast or variables and to ensure validity.
*
* Example:
*
* const OddType = new GraphQLScalarType({
* name: 'Odd',
* serialize(value) {
* return value % 2 === 1 ? value : null;
* }
* });
*
*/
var GraphQLScalarType = exports.GraphQLScalarType = function () {
function GraphQLScalarType(config) {
_classCallCheck(this, GraphQLScalarType);
(0, _assertValidName.assertValidName)(config.name);
this.name = config.name;
this.description = config.description;
(0, _invariant2.default)(typeof config.serialize === 'function', this.name + ' must provide "serialize" function. If this custom Scalar ' + 'is also used as an input type, ensure "parseValue" and "parseLiteral" ' + 'functions are also provided.');
if (config.parseValue || config.parseLiteral) {
(0, _invariant2.default)(typeof config.parseValue === 'function' && typeof config.parseLiteral === 'function', this.name + ' must provide both "parseValue" and "parseLiteral" ' + 'functions.');
}
this._scalarConfig = config;
}
// Serializes an internal value to include in a response.
GraphQLScalarType.prototype.serialize = function serialize(value) {
var serializer = this._scalarConfig.serialize;
return serializer(value);
};
// Parses an externally provided value to use as an input.
GraphQLScalarType.prototype.parseValue = function parseValue(value) {
var parser = this._scalarConfig.parseValue;
return parser ? parser(value) : null;
};
// Parses an externally provided literal value to use as an input.
GraphQLScalarType.prototype.parseLiteral = function parseLiteral(valueNode) {
var parser = this._scalarConfig.parseLiteral;
return parser ? parser(valueNode) : null;
};
GraphQLScalarType.prototype.toString = function toString() {
return this.name;
};
return GraphQLScalarType;
}();
// Also provide toJSON and inspect aliases for toString.
GraphQLScalarType.prototype.toJSON = GraphQLScalarType.prototype.inspect = GraphQLScalarType.prototype.toString;
/**
* Object Type Definition
*
* Almost all of the GraphQL types you define will be object types. Object types
* have a name, but most importantly describe their fields.
*
* Example:
*
* const AddressType = new GraphQLObjectType({
* name: 'Address',
* fields: {
* street: { type: GraphQLString },
* number: { type: GraphQLInt },
* formatted: {
* type: GraphQLString,
* resolve(obj) {
* return obj.number + ' ' + obj.street
* }
* }
* }
* });
*
* When two types need to refer to each other, or a type needs to refer to
* itself in a field, you can use a function expression (aka a closure or a
* thunk) to supply the fields lazily.
*
* Example:
*
* const PersonType = new GraphQLObjectType({
* name: 'Person',
* fields: () => ({
* name: { type: GraphQLString },
* bestFriend: { type: PersonType },
* })
* });
*
*/
var GraphQLObjectType = exports.GraphQLObjectType = function () {
function GraphQLObjectType(config) {
_classCallCheck(this, GraphQLObjectType);
(0, _assertValidName.assertValidName)(config.name, config.isIntrospection);
this.name = config.name;
this.description = config.description;
if (config.isTypeOf) {
(0, _invariant2.default)(typeof config.isTypeOf === 'function', this.name + ' must provide "isTypeOf" as a function.');
}
this.isTypeOf = config.isTypeOf;
this._typeConfig = config;
}
GraphQLObjectType.prototype.getFields = function getFields() {
return this._fields || (this._fields = defineFieldMap(this, this._typeConfig.fields));
};
GraphQLObjectType.prototype.getInterfaces = function getInterfaces() {
return this._interfaces || (this._interfaces = defineInterfaces(this, this._typeConfig.interfaces));
};
GraphQLObjectType.prototype.toString = function toString() {
return this.name;
};
return GraphQLObjectType;
}();
// Also provide toJSON and inspect aliases for toString.
GraphQLObjectType.prototype.toJSON = GraphQLObjectType.prototype.inspect = GraphQLObjectType.prototype.toString;
function defineInterfaces(type, interfacesThunk) {
var interfaces = resolveThunk(interfacesThunk);
if (!interfaces) {
return [];
}
(0, _invariant2.default)(Array.isArray(interfaces), type.name + ' interfaces must be an Array or a function which returns ' + 'an Array.');
interfaces.forEach(function (iface) {
(0, _invariant2.default)(iface instanceof GraphQLInterfaceType, type.name + ' may only implement Interface types, it cannot ' + ('implement: ' + String(iface) + '.'));
if (typeof iface.resolveType !== 'function') {
(0, _invariant2.default)(typeof type.isTypeOf === 'function', 'Interface Type ' + iface.name + ' does not provide a "resolveType" ' + ('function and implementing Type ' + type.name + ' does not provide a ') + '"isTypeOf" function. There is no way to resolve this implementing ' + 'type during execution.');
}
});
return interfaces;
}
function defineFieldMap(type, fieldsThunk) {
var fieldMap = resolveThunk(fieldsThunk);
(0, _invariant2.default)(isPlainObj(fieldMap), type.name + ' fields must be an object with field names as keys or a ' + 'function which returns such an object.');
var fieldNames = Object.keys(fieldMap);
(0, _invariant2.default)(fieldNames.length > 0, type.name + ' fields must be an object with field names as keys or a ' + 'function which returns such an object.');
var resultFieldMap = {};
fieldNames.forEach(function (fieldName) {
(0, _assertValidName.assertValidName)(fieldName);
var fieldConfig = fieldMap[fieldName];
(0, _invariant2.default)(!fieldConfig.hasOwnProperty('isDeprecated'), type.name + '.' + fieldName + ' should provide "deprecationReason" instead ' + 'of "isDeprecated".');
var field = _extends({}, fieldConfig, {
isDeprecated: Boolean(fieldConfig.deprecationReason),
name: fieldName
});
(0, _invariant2.default)(isOutputType(field.type), type.name + '.' + fieldName + ' field type must be Output Type but ' + ('got: ' + String(field.type) + '.'));
(0, _invariant2.default)(isValidResolver(field.resolve), type.name + '.' + fieldName + ' field resolver must be a function if ' + ('provided, but got: ' + String(field.resolve) + '.'));
var argsConfig = fieldConfig.args;
if (!argsConfig) {
field.args = [];
} else {
(0, _invariant2.default)(isPlainObj(argsConfig), type.name + '.' + fieldName + ' args must be an object with argument ' + 'names as keys.');
field.args = Object.keys(argsConfig).map(function (argName) {
(0, _assertValidName.assertValidName)(argName);
var arg = argsConfig[argName];
(0, _invariant2.default)(isInputType(arg.type), type.name + '.' + fieldName + '(' + argName + ':) argument type must be ' + ('Input Type but got: ' + String(arg.type) + '.'));
return {
name: argName,
description: arg.description === undefined ? null : arg.description,
type: arg.type,
defaultValue: arg.defaultValue
};
});
}
resultFieldMap[fieldName] = field;
});
return resultFieldMap;
}
function isPlainObj(obj) {
return obj && typeof obj === 'object' && !Array.isArray(obj);
}
// If a resolver is defined, it must be a function.
function isValidResolver(resolver) {
return resolver == null || typeof resolver === 'function';
}
/**
* Interface Type Definition
*
* When a field can return one of a heterogeneous set of types, a Interface type
* is used to describe what types are possible, what fields are in common across
* all types, as well as a function to determine which type is actually used
* when the field is resolved.
*
* Example:
*
* const EntityType = new GraphQLInterfaceType({
* name: 'Entity',
* fields: {
* name: { type: GraphQLString }
* }
* });
*
*/
var GraphQLInterfaceType = exports.GraphQLInterfaceType = function () {
function GraphQLInterfaceType(config) {
_classCallCheck(this, GraphQLInterfaceType);
(0, _assertValidName.assertValidName)(config.name);
this.name = config.name;
this.description = config.description;
if (config.resolveType) {
(0, _invariant2.default)(typeof config.resolveType === 'function', this.name + ' must provide "resolveType" as a function.');
}
this.resolveType = config.resolveType;
this._typeConfig = config;
}
GraphQLInterfaceType.prototype.getFields = function getFields() {
return this._fields || (this._fields = defineFieldMap(this, this._typeConfig.fields));
};
GraphQLInterfaceType.prototype.toString = function toString() {
return this.name;
};
return GraphQLInterfaceType;
}();
// Also provide toJSON and inspect aliases for toString.
GraphQLInterfaceType.prototype.toJSON = GraphQLInterfaceType.prototype.inspect = GraphQLInterfaceType.prototype.toString;
/**
* Union Type Definition
*
* When a field can return one of a heterogeneous set of types, a Union type
* is used to describe what types are possible as well as providing a function
* to determine which type is actually used when the field is resolved.
*
* Example:
*
* const PetType = new GraphQLUnionType({
* name: 'Pet',
* types: [ DogType, CatType ],
* resolveType(value) {
* if (value instanceof Dog) {
* return DogType;
* }
* if (value instanceof Cat) {
* return CatType;
* }
* }
* });
*
*/
var GraphQLUnionType = exports.GraphQLUnionType = function () {
function GraphQLUnionType(config) {
_classCallCheck(this, GraphQLUnionType);
(0, _assertValidName.assertValidName)(config.name);
this.name = config.name;
this.description = config.description;
if (config.resolveType) {
(0, _invariant2.default)(typeof config.resolveType === 'function', this.name + ' must provide "resolveType" as a function.');
}
this.resolveType = config.resolveType;
this._typeConfig = config;
}
GraphQLUnionType.prototype.getTypes = function getTypes() {
return this._types || (this._types = defineTypes(this, this._typeConfig.types));
};
GraphQLUnionType.prototype.toString = function toString() {
return this.name;
};
return GraphQLUnionType;
}();
// Also provide toJSON and inspect aliases for toString.
GraphQLUnionType.prototype.toJSON = GraphQLUnionType.prototype.inspect = GraphQLUnionType.prototype.toString;
function defineTypes(unionType, typesThunk) {
var types = resolveThunk(typesThunk);
(0, _invariant2.default)(Array.isArray(types) && types.length > 0, 'Must provide Array of types or a function which returns ' + ('such an array for Union ' + unionType.name + '.'));
types.forEach(function (objType) {
(0, _invariant2.default)(objType instanceof GraphQLObjectType, unionType.name + ' may only contain Object types, it cannot contain: ' + (String(objType) + '.'));
if (typeof unionType.resolveType !== 'function') {
(0, _invariant2.default)(typeof objType.isTypeOf === 'function', 'Union type "' + unionType.name + '" does not provide a "resolveType" ' + ('function and possible type "' + objType.name + '" does not provide an ') + '"isTypeOf" function. There is no way to resolve this possible type ' + 'during execution.');
}
});
return types;
}
/**
* Enum Type Definition
*
* Some leaf values of requests and input values are Enums. GraphQL serializes
* Enum values as strings, however internally Enums can be represented by any
* kind of type, often integers.
*
* Example:
*
* const RGBType = new GraphQLEnumType({
* name: 'RGB',
* values: {
* RED: { value: 0 },
* GREEN: { value: 1 },
* BLUE: { value: 2 }
* }
* });
*
* Note: If a value is not provided in a definition, the name of the enum value
* will be used as its internal value.
*/
var GraphQLEnumType /* */ = exports.GraphQLEnumType = function () {
function GraphQLEnumType(config /* */) {
_classCallCheck(this, GraphQLEnumType);
this.name = config.name;
(0, _assertValidName.assertValidName)(config.name, config.isIntrospection);
this.description = config.description;
this._values = defineEnumValues(this, config.values);
this._enumConfig = config;
}
GraphQLEnumType.prototype.getValues = function getValues() {
return this._values;
};
GraphQLEnumType.prototype.getValue = function getValue(name) {
return this._getNameLookup()[name];
};
GraphQLEnumType.prototype.serialize = function serialize(value /* T */) {
var enumValue = this._getValueLookup().get(value);
return enumValue ? enumValue.name : null;
};
GraphQLEnumType.prototype.parseValue = function parseValue(value) /* T */{
if (typeof value === 'string') {
var enumValue = this._getNameLookup()[value];
if (enumValue) {
return enumValue.value;
}
}
};
GraphQLEnumType.prototype.parseLiteral = function parseLiteral(valueNode) /* T */{
if (valueNode.kind === _kinds.ENUM) {
var enumValue = this._getNameLookup()[valueNode.value];
if (enumValue) {
return enumValue.value;
}
}
};
GraphQLEnumType.prototype._getValueLookup = function _getValueLookup() {
var _this = this;
if (!this._valueLookup) {
(function () {
var lookup = new Map();
_this.getValues().forEach(function (value) {
lookup.set(value.value, value);
});
_this._valueLookup = lookup;
})();
}
return this._valueLookup;
};
GraphQLEnumType.prototype._getNameLookup = function _getNameLookup() {
var _this2 = this;
if (!this._nameLookup) {
(function () {
var lookup = Object.create(null);
_this2.getValues().forEach(function (value) {
lookup[value.name] = value;
});
_this2._nameLookup = lookup;
})();
}
return this._nameLookup;
};
GraphQLEnumType.prototype.toString = function toString() {
return this.name;
};
return GraphQLEnumType;
}();
// Also provide toJSON and inspect aliases for toString.
GraphQLEnumType.prototype.toJSON = GraphQLEnumType.prototype.inspect = GraphQLEnumType.prototype.toString;
function defineEnumValues(type, valueMap /* */
) {
(0, _invariant2.default)(isPlainObj(valueMap), type.name + ' values must be an object with value names as keys.');
var valueNames = Object.keys(valueMap);
(0, _invariant2.default)(valueNames.length > 0, type.name + ' values must be an object with value names as keys.');
return valueNames.map(function (valueName) {
(0, _assertValidName.assertValidName)(valueName);
var value = valueMap[valueName];
(0, _invariant2.default)(isPlainObj(value), type.name + '.' + valueName + ' must refer to an object with a "value" key ' + ('representing an internal value but got: ' + String(value) + '.'));
(0, _invariant2.default)(!value.hasOwnProperty('isDeprecated'), type.name + '.' + valueName + ' should provide "deprecationReason" instead ' + 'of "isDeprecated".');
return {
name: valueName,
description: value.description,
isDeprecated: Boolean(value.deprecationReason),
deprecationReason: value.deprecationReason,
value: (0, _isNullish2.default)(value.value) ? valueName : value.value
};
});
} /* */
/**
* Input Object Type Definition
*
* An input object defines a structured collection of fields which may be
* supplied to a field argument.
*
* Using `NonNull` will ensure that a value must be provided by the query
*
* Example:
*
* const GeoPoint = new GraphQLInputObjectType({
* name: 'GeoPoint',
* fields: {
* lat: { type: new GraphQLNonNull(GraphQLFloat) },
* lon: { type: new GraphQLNonNull(GraphQLFloat) },
* alt: { type: GraphQLFloat, defaultValue: 0 },
* }
* });
*
*/
var GraphQLInputObjectType = exports.GraphQLInputObjectType = function () {
function GraphQLInputObjectType(config) {
_classCallCheck(this, GraphQLInputObjectType);
(0, _assertValidName.assertValidName)(config.name);
this.name = config.name;
this.description = config.description;
this._typeConfig = config;
}
GraphQLInputObjectType.prototype.getFields = function getFields() {
return this._fields || (this._fields = this._defineFieldMap());
};
GraphQLInputObjectType.prototype._defineFieldMap = function _defineFieldMap() {
var _this3 = this;
var fieldMap = resolveThunk(this._typeConfig.fields);
(0, _invariant2.default)(isPlainObj(fieldMap), this.name + ' fields must be an object with field names as keys or a ' + 'function which returns such an object.');
var fieldNames = Object.keys(fieldMap);
(0, _invariant2.default)(fieldNames.length > 0, this.name + ' fields must be an object with field names as keys or a ' + 'function which returns such an object.');
var resultFieldMap = {};
fieldNames.forEach(function (fieldName) {
(0, _assertValidName.assertValidName)(fieldName);
var field = _extends({}, fieldMap[fieldName], {
name: fieldName
});
(0, _invariant2.default)(isInputType(field.type), _this3.name + '.' + fieldName + ' field type must be Input Type but ' + ('got: ' + String(field.type) + '.'));
(0, _invariant2.default)(field.resolve == null, _this3.name + '.' + fieldName + ' field type has a resolve property, but ' + 'Input Types cannot define resolvers.');
resultFieldMap[fieldName] = field;
});
return resultFieldMap;
};
GraphQLInputObjectType.prototype.toString = function toString() {
return this.name;
};
return GraphQLInputObjectType;
}();
// Also provide toJSON and inspect aliases for toString.
GraphQLInputObjectType.prototype.toJSON = GraphQLInputObjectType.prototype.inspect = GraphQLInputObjectType.prototype.toString;
/**
* List Modifier
*
* A list is a kind of type marker, a wrapping type which points to another
* type. Lists are often created within the context of defining the fields of
* an object type.
*
* Example:
*
* const PersonType = new GraphQLObjectType({
* name: 'Person',
* fields: () => ({
* parents: { type: new GraphQLList(Person) },
* children: { type: new GraphQLList(Person) },
* })
* })
*
*/
var GraphQLList = exports.GraphQLList = function () {
function GraphQLList(type) {
_classCallCheck(this, GraphQLList);
(0, _invariant2.default)(isType(type), 'Can only create List of a GraphQLType but got: ' + String(type) + '.');
this.ofType = type;
}
GraphQLList.prototype.toString = function toString() {
return '[' + String(this.ofType) + ']';
};
return GraphQLList;
}();
// Also provide toJSON and inspect aliases for toString.
GraphQLList.prototype.toJSON = GraphQLList.prototype.inspect = GraphQLList.prototype.toString;
/**
* Non-Null Modifier
*
* A non-null is a kind of type marker, a wrapping type which points to another
* type. Non-null types enforce that their values are never null and can ensure
* an error is raised if this ever occurs during a request. It is useful for
* fields which you can make a strong guarantee on non-nullability, for example
* usually the id field of a database row will never be null.
*
* Example:
*
* const RowType = new GraphQLObjectType({
* name: 'Row',
* fields: () => ({
* id: { type: new GraphQLNonNull(GraphQLString) },
* })
* })
*
* Note: the enforcement of non-nullability occurs within the executor.
*/
var GraphQLNonNull = exports.GraphQLNonNull = function () {
function GraphQLNonNull(type) {
_classCallCheck(this, GraphQLNonNull);
(0, _invariant2.default)(isType(type) && !(type instanceof GraphQLNonNull), 'Can only create NonNull of a Nullable GraphQLType but got: ' + (String(type) + '.'));
this.ofType = type;
}
GraphQLNonNull.prototype.toString = function toString() {
return this.ofType.toString() + '!';
};
return GraphQLNonNull;
}();
// Also provide toJSON and inspect aliases for toString.
GraphQLNonNull.prototype.toJSON = GraphQLNonNull.prototype.inspect = GraphQLNonNull.prototype.toString;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Copyright (c) 2015, 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.
*/
// Name
var NAME = exports.NAME = 'Name';
// Document
var DOCUMENT = exports.DOCUMENT = 'Document';
var OPERATION_DEFINITION = exports.OPERATION_DEFINITION = 'OperationDefinition';
var VARIABLE_DEFINITION = exports.VARIABLE_DEFINITION = 'VariableDefinition';
var VARIABLE = exports.VARIABLE = 'Variable';
var SELECTION_SET = exports.SELECTION_SET = 'SelectionSet';
var FIELD = exports.FIELD = 'Field';
var ARGUMENT = exports.ARGUMENT = 'Argument';
// Fragments
var FRAGMENT_SPREAD = exports.FRAGMENT_SPREAD = 'FragmentSpread';
var INLINE_FRAGMENT = exports.INLINE_FRAGMENT = 'InlineFragment';
var FRAGMENT_DEFINITION = exports.FRAGMENT_DEFINITION = 'FragmentDefinition';
// Values
var INT = exports.INT = 'IntValue';
var FLOAT = exports.FLOAT = 'FloatValue';
var STRING = exports.STRING = 'StringValue';
var BOOLEAN = exports.BOOLEAN = 'BooleanValue';
var NULL = exports.NULL = 'NullValue';
var ENUM = exports.ENUM = 'EnumValue';
var LIST = exports.LIST = 'ListValue';
var OBJECT = exports.OBJECT = 'ObjectValue';
var OBJECT_FIELD = exports.OBJECT_FIELD = 'ObjectField';
// Directives
var DIRECTIVE = exports.DIRECTIVE = 'Directive';
// Types
var NAMED_TYPE = exports.NAMED_TYPE = 'NamedType';
var LIST_TYPE = exports.LIST_TYPE = 'ListType';
var NON_NULL_TYPE = exports.NON_NULL_TYPE = 'NonNullType';
// Type System Definitions
var SCHEMA_DEFINITION = exports.SCHEMA_DEFINITION = 'SchemaDefinition';
var OPERATION_TYPE_DEFINITION = exports.OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';
// Type Definitions
var SCALAR_TYPE_DEFINITION = exports.SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
var OBJECT_TYPE_DEFINITION = exports.OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
var FIELD_DEFINITION = exports.FIELD_DEFINITION = 'FieldDefinition';
var INPUT_VALUE_DEFINITION = exports.INPUT_VALUE_DEFINITION = 'InputValueDefinition';
var INTERFACE_TYPE_DEFINITION = exports.INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
var UNION_TYPE_DEFINITION = exports.UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
var ENUM_TYPE_DEFINITION = exports.ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
var ENUM_VALUE_DEFINITION = exports.ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
var INPUT_OBJECT_TYPE_DEFINITION = exports.INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
// Type Extensions
var TYPE_EXTENSION_DEFINITION = exports.TYPE_EXTENSION_DEFINITION = 'TypeExtensionDefinition';
// Directive Definitions
var DIRECTIVE_DEFINITION = exports.DIRECTIVE_DEFINITION = 'DirectiveDefinition';
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = invariant;
/**
* Copyright (c) 2015, 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.
*/
function invariant(condition, message) {
if (!condition) {
throw new Error(message);
}
}
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.print = print;
var _visitor = __webpack_require__(15);
/**
* Converts an AST into a string, using one set of reasonable
* formatting rules.
*/
function print(ast) {
return (0, _visitor.visit)(ast, { leave: printDocASTReducer });
} /**
* Copyright (c) 2015, 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.
*/
var printDocASTReducer = {
Name: function Name(node) {
return node.value;
},
Variable: function Variable(node) {
return '$' + node.name;
},
// Document
Document: function Document(node) {
return join(node.definitions, '\n\n') + '\n';
},
OperationDefinition: function OperationDefinition(node) {
var op = node.operation;
var name = node.name;
var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
var directives = join(node.directives, ' ');
var selectionSet = node.selectionSet;
// Anonymous queries with no directives or variable definitions can use
// the query short form.
return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
},
VariableDefinition: function VariableDefinition(_ref) {
var variable = _ref.variable,
type = _ref.type,
defaultValue = _ref.defaultValue;
return variable + ': ' + type + wrap(' = ', defaultValue);
},
SelectionSet: function SelectionSet(_ref2) {
var selections = _ref2.selections;
return block(selections);
},
Field: function Field(_ref3) {
var alias = _ref3.alias,
name = _ref3.name,
args = _ref3.arguments,
directives = _ref3.directives,
selectionSet = _ref3.selectionSet;
return join([wrap('', alias, ': ') + name + wrap('(', join(args, ', '), ')'), join(directives, ' '), selectionSet], ' ');
},
Argument: function Argument(_ref4) {
var name = _ref4.name,
value = _ref4.value;
return name + ': ' + value;
},
// Fragments
FragmentSpread: function FragmentSpread(_ref5) {
var name = _ref5.name,
directives = _ref5.directives;
return '...' + name + wrap(' ', join(directives, ' '));
},
InlineFragment: function InlineFragment(_ref6) {
var typeCondition = _ref6.typeCondition,
directives = _ref6.directives,
selectionSet = _ref6.selectionSet;
return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
},
FragmentDefinition: function FragmentDefinition(_ref7) {
var name = _ref7.name,
typeCondition = _ref7.typeCondition,
directives = _ref7.directives,
selectionSet = _ref7.selectionSet;
return 'fragment ' + name + ' on ' + typeCondition + ' ' + wrap('', join(directives, ' '), ' ') + selectionSet;
},
// Value
IntValue: function IntValue(_ref8) {
var value = _ref8.value;
return value;
},
FloatValue: function FloatValue(_ref9) {
var value = _ref9.value;
return value;
},
StringValue: function StringValue(_ref10) {
var value = _ref10.value;
return JSON.stringify(value);
},
BooleanValue: function BooleanValue(_ref11) {
var value = _ref11.value;
return JSON.stringify(value);
},
NullValue: function NullValue() {
return 'null';
},
EnumValue: function EnumValue(_ref12) {
var value = _ref12.value;
return value;
},
ListValue: function ListValue(_ref13) {
var values = _ref13.values;
return '[' + join(values, ', ') + ']';
},
ObjectValue: function ObjectValue(_ref14) {
var fields = _ref14.fields;
return '{' + join(fields, ', ') + '}';
},
ObjectField: function ObjectField(_ref15) {
var name = _ref15.name,
value = _ref15.value;
return name + ': ' + value;
},
// Directive
Directive: function Directive(_ref16) {
var name = _ref16.name,
args = _ref16.arguments;
return '@' + name + wrap('(', join(args, ', '), ')');
},
// Type
NamedType: function NamedType(_ref17) {
var name = _ref17.name;
return name;
},
ListType: function ListType(_ref18) {
var type = _ref18.type;
return '[' + type + ']';
},
NonNullType: function NonNullType(_ref19) {
var type = _ref19.type;
return type + '!';
},
// Type System Definitions
SchemaDefinition: function SchemaDefinition(_ref20) {
var directives = _ref20.directives,
operationTypes = _ref20.operationTypes;
return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
},
OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
var operation = _ref21.operation,
type = _ref21.type;
return operation + ': ' + type;
},
ScalarTypeDefinition: function ScalarTypeDefinition(_ref22) {
var name = _ref22.name,
directives = _ref22.directives;
return join(['scalar', name, join(directives, ' ')], ' ');
},
ObjectTypeDefinition: function ObjectTypeDefinition(_ref23) {
var name = _ref23.name,
interfaces = _ref23.interfaces,
directives = _ref23.directives,
fields = _ref23.fields;
return join(['type', name, wrap('implements ', join(interfaces, ', ')), join(directives, ' '), block(fields)], ' ');
},
FieldDefinition: function FieldDefinition(_ref24) {
var name = _ref24.name,
args = _ref24.arguments,
type = _ref24.type,
directives = _ref24.directives;
return name + wrap('(', join(args, ', '), ')') + ': ' + type + wrap(' ', join(directives, ' '));
},
InputValueDefinition: function InputValueDefinition(_ref25) {
var name = _ref25.name,
type = _ref25.type,
defaultValue = _ref25.defaultValue,
directives = _ref25.directives;
return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
},
InterfaceTypeDefinition: function InterfaceTypeDefinition(_ref26) {
var name = _ref26.name,
directives = _ref26.directives,
fields = _ref26.fields;
return join(['interface', name, join(directives, ' '), block(fields)], ' ');
},
UnionTypeDefinition: function UnionTypeDefinition(_ref27) {
var name = _ref27.name,
directives = _ref27.directives,
types = _ref27.types;
return join(['union', name, join(directives, ' '), '= ' + join(types, ' | ')], ' ');
},
EnumTypeDefinition: function EnumTypeDefinition(_ref28) {
var name = _ref28.name,
directives = _ref28.directives,
values = _ref28.values;
return join(['enum', name, join(directives, ' '), block(values)], ' ');
},
EnumValueDefinition: function EnumValueDefinition(_ref29) {
var name = _ref29.name,
directives = _ref29.directives;
return join([name, join(directives, ' ')], ' ');
},
InputObjectTypeDefinition: function InputObjectTypeDefinition(_ref30) {
var name = _ref30.name,
directives = _ref30.directives,
fields = _ref30.fields;
return join(['input', name, join(directives, ' '), block(fields)], ' ');
},
TypeExtensionDefinition: function TypeExtensionDefinition(_ref31) {
var definition = _ref31.definition;
return 'extend ' + definition;
},
DirectiveDefinition: function DirectiveDefinition(_ref32) {
var name = _ref32.name,
args = _ref32.arguments,
locations = _ref32.locations;
return 'directive @' + name + wrap('(', join(args, ', '), ')') + ' on ' + join(locations, ' | ');
}
};
/**
* Given maybeArray, print an empty string if it is null or empty, otherwise
* print all items together separated by separator if provided
*/
function join(maybeArray, separator) {
return maybeArray ? maybeArray.filter(function (x) {
return x;
}).join(separator || '') : '';
}
/**
* Given array, print each item on its own line, wrapped in an
* indented "{ }" block.
*/
function block(array) {
return array && array.length !== 0 ? indent('{\n' + join(array, '\n')) + '\n}' : '{}';
}
/**
* If maybeString is not null or empty, then wrap with start and end, otherwise
* print an empty string.
*/
function wrap(start, maybeString, end) {
return maybeString ? start + maybeString + (end || '') : '';
}
function indent(maybeString) {
return maybeString && maybeString.replace(/\n/g, '\n ');
}
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.specifiedDirectives = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = exports.DirectiveLocation = undefined;
var _definition = __webpack_require__(1);
var _scalars = __webpack_require__(7);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _assertValidName = __webpack_require__(28);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2015, 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.
*/
var DirectiveLocation = exports.DirectiveLocation = {
// Operations
QUERY: 'QUERY',
MUTATION: 'MUTATION',
SUBSCRIPTION: 'SUBSCRIPTION',
FIELD: 'FIELD',
FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
INLINE_FRAGMENT: 'INLINE_FRAGMENT',
// Schema Definitions
SCHEMA: 'SCHEMA',
SCALAR: 'SCALAR',
OBJECT: 'OBJECT',
FIELD_DEFINITION: 'FIELD_DEFINITION',
ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
INTERFACE: 'INTERFACE',
UNION: 'UNION',
ENUM: 'ENUM',
ENUM_VALUE: 'ENUM_VALUE',
INPUT_OBJECT: 'INPUT_OBJECT',
INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
};
// eslint-disable-line
/**
* Directives are used by the GraphQL runtime as a way of modifying execution
* behavior. Type system creators will usually not create these directly.
*/
var GraphQLDirective = exports.GraphQLDirective = function GraphQLDirective(config) {
_classCallCheck(this, GraphQLDirective);
(0, _invariant2.default)(config.name, 'Directive must be named.');
(0, _assertValidName.assertValidName)(config.name);
(0, _invariant2.default)(Array.isArray(config.locations), 'Must provide locations for directive.');
this.name = config.name;
this.description = config.description;
this.locations = config.locations;
var args = config.args;
if (!args) {
this.args = [];
} else {
(0, _invariant2.default)(!Array.isArray(args), '@' + config.name + ' args must be an object with argument names as keys.');
this.args = Object.keys(args).map(function (argName) {
(0, _assertValidName.assertValidName)(argName);
var arg = args[argName];
(0, _invariant2.default)((0, _definition.isInputType)(arg.type), '@' + config.name + '(' + argName + ':) argument type must be ' + ('Input Type but got: ' + String(arg.type) + '.'));
return {
name: argName,
description: arg.description === undefined ? null : arg.description,
type: arg.type,
defaultValue: arg.defaultValue
};
});
}
};
/**
* Used to conditionally include fields or fragments.
*/
var GraphQLIncludeDirective = exports.GraphQLIncludeDirective = new GraphQLDirective({
name: 'include',
description: 'Directs the executor to include this field or fragment only when ' + 'the `if` argument is true.',
locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],
args: {
'if': {
type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
description: 'Included when true.'
}
}
});
/**
* Used to conditionally skip (exclude) fields or fragments.
*/
var GraphQLSkipDirective = exports.GraphQLSkipDirective = new GraphQLDirective({
name: 'skip',
description: 'Directs the executor to skip this field or fragment when the `if` ' + 'argument is true.',
locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],
args: {
'if': {
type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
description: 'Skipped when true.'
}
}
});
/**
* Constant string used for default reason for a deprecation.
*/
var DEFAULT_DEPRECATION_REASON = exports.DEFAULT_DEPRECATION_REASON = 'No longer supported';
/**
* Used to declare element of a GraphQL schema as deprecated.
*/
var GraphQLDeprecatedDirective = exports.GraphQLDeprecatedDirective = new GraphQLDirective({
name: 'deprecated',
description: 'Marks an element of a GraphQL schema as no longer supported.',
locations: [DirectiveLocation.FIELD_DEFINITION, DirectiveLocation.ENUM_VALUE],
args: {
reason: {
type: _scalars.GraphQLString,
description: 'Explains why this element was deprecated, usually also including a ' + 'suggestion for how to access supported similar data. Formatted ' + 'in [Markdown](https://daringfireball.net/projects/markdown/).',
defaultValue: DEFAULT_DEPRECATION_REASON
}
}
});
/**
* The full list of specified directives.
*/
var specifiedDirectives = exports.specifiedDirectives = [GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective];
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isNullish;
/**
* Copyright (c) 2015, 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.
*/
/**
* Returns true if a value is null, undefined, or NaN.
*/
function isNullish(value) {
return value === null || value === undefined || value !== value;
}
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GraphQLID = exports.GraphQLBoolean = exports.GraphQLString = exports.GraphQLFloat = exports.GraphQLInt = undefined;
var _definition = __webpack_require__(1);
var _kinds = __webpack_require__(2);
var Kind = _interopRequireWildcard(_kinds);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
// As per the GraphQL Spec, Integers are only treated as valid when a valid
// 32-bit signed integer, providing the broadest support across platforms.
//
// n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
// they are internally represented as IEEE 754 doubles.
/**
* Copyright (c) 2015, 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.
*/
var MAX_INT = 2147483647;
var MIN_INT = -2147483648;
function coerceInt(value) {
if (value === '') {
throw new TypeError('Int cannot represent non 32-bit signed integer value: (empty string)');
}
var num = Number(value);
if (num === num && num <= MAX_INT && num >= MIN_INT) {
return (num < 0 ? Math.ceil : Math.floor)(num);
}
throw new TypeError('Int cannot represent non 32-bit signed integer value: ' + String(value));
}
var GraphQLInt = exports.GraphQLInt = new _definition.GraphQLScalarType({
name: 'Int',
description: 'The `Int` scalar type represents non-fractional signed whole numeric ' + 'values. Int can represent values between -(2^31) and 2^31 - 1. ',
serialize: coerceInt,
parseValue: coerceInt,
parseLiteral: function parseLiteral(ast) {
if (ast.kind === Kind.INT) {
var num = parseInt(ast.value, 10);
if (num <= MAX_INT && num >= MIN_INT) {
return num;
}
}
return null;
}
});
function coerceFloat(value) {
if (value === '') {
throw new TypeError('Float cannot represent non numeric value: (empty string)');
}
var num = Number(value);
if (num === num) {
return num;
}
throw new TypeError('Float cannot represent non numeric value: ' + String(value));
}
var GraphQLFloat = exports.GraphQLFloat = new _definition.GraphQLScalarType({
name: 'Float',
description: 'The `Float` scalar type represents signed double-precision fractional ' + 'values as specified by ' + '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ',
serialize: coerceFloat,
parseValue: coerceFloat,
parseLiteral: function parseLiteral(ast) {
return ast.kind === Kind.FLOAT || ast.kind === Kind.INT ? parseFloat(ast.value) : null;
}
});
var GraphQLString = exports.GraphQLString = new _definition.GraphQLScalarType({
name: 'String',
description: 'The `String` scalar type represents textual data, represented as UTF-8 ' + 'character sequences. The String type is most often used by GraphQL to ' + 'represent free-form human-readable text.',
serialize: String,
parseValue: String,
parseLiteral: function parseLiteral(ast) {
return ast.kind === Kind.STRING ? ast.value : null;
}
});
var GraphQLBoolean = exports.GraphQLBoolean = new _definition.GraphQLScalarType({
name: 'Boolean',
description: 'The `Boolean` scalar type represents `true` or `false`.',
serialize: Boolean,
parseValue: Boolean,
parseLiteral: function parseLiteral(ast) {
return ast.kind === Kind.BOOLEAN ? ast.value : null;
}
});
var GraphQLID = exports.GraphQLID = new _definition.GraphQLScalarType({
name: 'ID',
description: 'The `ID` scalar type represents a unique identifier, often used to ' + 'refetch an object or as key for a cache. The ID type appears in a JSON ' + 'response as a String; however, it is not intended to be human-readable. ' + 'When expected as an input type, any string (such as `"4"`) or integer ' + '(such as `4`) input value will be accepted as an ID.',
serialize: String,
parseValue: String,
parseLiteral: function parseLiteral(ast) {
return ast.kind === Kind.STRING || ast.kind === Kind.INT ? ast.value : null;
}
});
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GraphQLSchema = undefined;
var _definition = __webpack_require__(1);
var _directives = __webpack_require__(5);
var _introspection = __webpack_require__(11);
var _find = __webpack_require__(10);
var _find2 = _interopRequireDefault(_find);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _typeComparators = __webpack_require__(19);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2015, 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.
*/
/**
* Schema Definition
*
* A Schema is created by supplying the root types of each type of operation,
* query and mutation (optional). A schema definition is then supplied to the
* validator and executor.
*
* Example:
*
* const MyAppSchema = new GraphQLSchema({
* query: MyAppQueryRootType,
* mutation: MyAppMutationRootType,
* })
*
* Note: If an array of `directives` are provided to GraphQLSchema, that will be
* the exact list of directives represented and allowed. If `directives` is not
* provided then a default set of the specified directives (e.g. @include and
* @skip) will be used. If you wish to provide *additional* directives to these
* specified directives, you must explicitly declare them. Example:
*
* const MyAppSchema = new GraphQLSchema({
* ...
* directives: specifiedDirectives.concat([ myCustomDirective ]),
* })
*
*/
var GraphQLSchema = exports.GraphQLSchema = function () {
function GraphQLSchema(config) {
var _this = this;
_classCallCheck(this, GraphQLSchema);
(0, _invariant2.default)(typeof config === 'object', 'Must provide configuration object.');
(0, _invariant2.default)(config.query instanceof _definition.GraphQLObjectType, 'Schema query must be Object Type but got: ' + String(config.query) + '.');
this._queryType = config.query;
(0, _invariant2.default)(!config.mutation || config.mutation instanceof _definition.GraphQLObjectType, 'Schema mutation must be Object Type if provided but got: ' + String(config.mutation) + '.');
this._mutationType = config.mutation;
(0, _invariant2.default)(!config.subscription || config.subscription instanceof _definition.GraphQLObjectType, 'Schema subscription must be Object Type if provided but got: ' + String(config.subscription) + '.');
this._subscriptionType = config.subscription;
(0, _invariant2.default)(!config.types || Array.isArray(config.types), 'Schema types must be Array if provided but got: ' + String(config.types) + '.');
(0, _invariant2.default)(!config.directives || Array.isArray(config.directives) && config.directives.every(function (directive) {
return directive instanceof _directives.GraphQLDirective;
}), 'Schema directives must be Array if provided but got: ' + String(config.directives) + '.');
// Provide specified directives (e.g. @include and @skip) by default.
this._directives = config.directives || _directives.specifiedDirectives;
// Build type map now to detect any errors within this schema.
var initialTypes = [this.getQueryType(), this.getMutationType(), this.getSubscriptionType(), _introspection.__Schema];
var types = config.types;
if (types) {
initialTypes = initialTypes.concat(types);
}
this._typeMap = initialTypes.reduce(typeMapReducer, Object.create(null));
// Keep track of all implementations by interface name.
this._implementations = Object.create(null);
Object.keys(this._typeMap).forEach(function (typeName) {
var type = _this._typeMap[typeName];
if (type instanceof _definition.GraphQLObjectType) {
type.getInterfaces().forEach(function (iface) {
var impls = _this._implementations[iface.name];
if (impls) {
impls.push(type);
} else {
_this._implementations[iface.name] = [type];
}
});
}
});
// Enforce correct interface implementations.
Object.keys(this._typeMap).forEach(function (typeName) {
var type = _this._typeMap[typeName];
if (type instanceof _definition.GraphQLObjectType) {
type.getInterfaces().forEach(function (iface) {
return assertObjectImplementsInterface(_this, type, iface);
});
}
});
}
GraphQLSchema.prototype.getQueryType = function getQueryType() {
return this._queryType;
};
GraphQLSchema.prototype.getMutationType = function getMutationType() {
return this._mutationType;
};
GraphQLSchema.prototype.getSubscriptionType = function getSubscriptionType() {
return this._subscriptionType;
};
GraphQLSchema.prototype.getTypeMap = function getTypeMap() {
return this._typeMap;
};
GraphQLSchema.prototype.getType = function getType(name) {
return this.getTypeMap()[name];
};
GraphQLSchema.prototype.getPossibleTypes = function getPossibleTypes(abstractType) {
if (abstractType instanceof _definition.GraphQLUnionType) {
return abstractType.getTypes();
}
(0, _invariant2.default)(abstractType instanceof _definition.GraphQLInterfaceType);
return this._implementations[abstractType.name];
};
GraphQLSchema.prototype.isPossibleType = function isPossibleType(abstractType, possibleType) {
var possibleTypeMap = this._possibleTypeMap;
if (!possibleTypeMap) {
this._possibleTypeMap = possibleTypeMap = Object.create(null);
}
if (!possibleTypeMap[abstractType.name]) {
var possibleTypes = this.getPossibleTypes(abstractType);
(0, _invariant2.default)(Array.isArray(possibleTypes), 'Could not find possible implementing types for ' + abstractType.name + ' ' + 'in schema. Check that schema.types is defined and is an array of ' + 'all possible types in the schema.');
possibleTypeMap[abstractType.name] = possibleTypes.reduce(function (map, type) {
return map[type.name] = true, map;
}, Object.create(null));
}
return Boolean(possibleTypeMap[abstractType.name][possibleType.name]);
};
GraphQLSchema.prototype.getDirectives = function getDirectives() {
return this._directives;
};
GraphQLSchema.prototype.getDirective = function getDirective(name) {
return (0, _find2.default)(this.getDirectives(), function (directive) {
return directive.name === name;
});
};
return GraphQLSchema;
}();
function typeMapReducer(map, type) {
if (!type) {
return map;
}
if (type instanceof _definition.GraphQLList || type instanceof _definition.GraphQLNonNull) {
return typeMapReducer(map, type.ofType);
}
if (map[type.name]) {
(0, _invariant2.default)(map[type.name] === type, 'Schema must contain unique named types but contains multiple ' + ('types named "' + type.name + '".'));
return map;
}
map[type.name] = type;
var reducedMap = map;
if (type instanceof _definition.GraphQLUnionType) {
reducedMap = type.getTypes().reduce(typeMapReducer, reducedMap);
}
if (type instanceof _definition.GraphQLObjectType) {
reducedMap = type.getInterfaces().reduce(typeMapReducer, reducedMap);
}
if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
(function () {
var fieldMap = type.getFields();
Object.keys(fieldMap).forEach(function (fieldName) {
var field = fieldMap[fieldName];
if (field.args) {
var fieldArgTypes = field.args.map(function (arg) {
return arg.type;
});
reducedMap = fieldArgTypes.reduce(typeMapReducer, reducedMap);
}
reducedMap = typeMapReducer(reducedMap, field.type);
});
})();
}
if (type instanceof _definition.GraphQLInputObjectType) {
(function () {
var fieldMap = type.getFields();
Object.keys(fieldMap).forEach(function (fieldName) {
var field = fieldMap[fieldName];
reducedMap = typeMapReducer(reducedMap, field.type);
});
})();
}
return reducedMap;
}
function assertObjectImplementsInterface(schema, object, iface) {
var objectFieldMap = object.getFields();
var ifaceFieldMap = iface.getFields();
// Assert each interface field is implemented.
Object.keys(ifaceFieldMap).forEach(function (fieldName) {
var objectField = objectFieldMap[fieldName];
var ifaceField = ifaceFieldMap[fieldName];
// Assert interface field exists on object.
(0, _invariant2.default)(objectField, '"' + iface.name + '" expects field "' + fieldName + '" but "' + object.name + '" ' + 'does not provide it.');
// Assert interface field type is satisfied by object field type, by being
// a valid subtype. (covariant)
(0, _invariant2.default)((0, _typeComparators.isTypeSubTypeOf)(schema, objectField.type, ifaceField.type), iface.name + '.' + fieldName + ' expects type "' + String(ifaceField.type) + '" ' + 'but ' + (object.name + '.' + fieldName + ' provides type "' + String(objectField.type) + '".'));
// Assert each interface field arg is implemented.
ifaceField.args.forEach(function (ifaceArg) {
var argName = ifaceArg.name;
var objectArg = (0, _find2.default)(objectField.args, function (arg) {
return arg.name === argName;
});
// Assert interface field arg exists on object field.
(0, _invariant2.default)(objectArg, iface.name + '.' + fieldName + ' expects argument "' + argName + '" but ' + (object.name + '.' + fieldName + ' does not provide it.'));
// Assert interface field arg type matches object field arg type.
// (invariant)
(0, _invariant2.default)((0, _typeComparators.isEqualType)(ifaceArg.type, objectArg.type), iface.name + '.' + fieldName + '(' + argName + ':) expects type ' + ('"' + String(ifaceArg.type) + '" but ') + (object.name + '.' + fieldName + '(' + argName + ':) provides type ') + ('"' + String(objectArg.type) + '".'));
});
// Assert additional arguments must not be required.
objectField.args.forEach(function (objectArg) {
var argName = objectArg.name;
var ifaceArg = (0, _find2.default)(ifaceField.args, function (arg) {
return arg.name === argName;
});
if (!ifaceArg) {
(0, _invariant2.default)(!(objectArg.type instanceof _definition.GraphQLNonNull), object.name + '.' + fieldName + '(' + argName + ':) is of required type ' + ('"' + String(objectArg.type) + '" but is not also provided by the ') + ('interface ' + iface.name + '.' + fieldName + '.'));
}
});
});
}
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.typeFromAST = typeFromAST;
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _kinds = __webpack_require__(2);
var _definition = __webpack_require__(1);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function typeFromAST(schema, typeNode) {
var innerType = void 0;
if (typeNode.kind === _kinds.LIST_TYPE) {
innerType = typeFromAST(schema, typeNode.type);
return innerType && new _definition.GraphQLList(innerType);
}
if (typeNode.kind === _kinds.NON_NULL_TYPE) {
innerType = typeFromAST(schema, typeNode.type);
return innerType && new _definition.GraphQLNonNull(innerType);
}
(0, _invariant2.default)(typeNode.kind === _kinds.NAMED_TYPE, 'Must be a named type.');
return schema.getType(typeNode.name.value);
}
/**
* Copyright (c) 2015, 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.
*/
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = find;
/**
* Copyright (c) 2015, 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.
*/
function find(list, predicate) {
for (var i = 0; i < list.length; i++) {
if (predicate(list[i])) {
return list[i];
}
}
}
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TypeNameMetaFieldDef = exports.TypeMetaFieldDef = exports.SchemaMetaFieldDef = exports.__TypeKind = exports.TypeKind = exports.__EnumValue = exports.__InputValue = exports.__Field = exports.__Type = exports.__DirectiveLocation = exports.__Directive = exports.__Schema = undefined;
var _isInvalid = __webpack_require__(14);
var _isInvalid2 = _interopRequireDefault(_isInvalid);
var _astFromValue = __webpack_require__(29);
var _printer = __webpack_require__(4);
var _definition = __webpack_require__(1);
var _scalars = __webpack_require__(7);
var _directives = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Copyright (c) 2015, 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.
*/
var __Schema = exports.__Schema = new _definition.GraphQLObjectType({
name: '__Schema',
isIntrospection: true,
description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It ' + 'exposes all available types and directives on the server, as well as ' + 'the entry points for query, mutation, and subscription operations.',
fields: function fields() {
return {
types: {
description: 'A list of all types supported by this server.',
type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type))),
resolve: function resolve(schema) {
var typeMap = schema.getTypeMap();
return Object.keys(typeMap).map(function (key) {
return typeMap[key];
});
}
},
queryType: {
description: 'The type that query operations will be rooted at.',
type: new _definition.GraphQLNonNull(__Type),
resolve: function resolve(schema) {
return schema.getQueryType();
}
},
mutationType: {
description: 'If this server supports mutation, the type that ' + 'mutation operations will be rooted at.',
type: __Type,
resolve: function resolve(schema) {
return schema.getMutationType();
}
},
subscriptionType: {
description: 'If this server support subscription, the type that ' + 'subscription operations will be rooted at.',
type: __Type,
resolve: function resolve(schema) {
return schema.getSubscriptionType();
}
},
directives: {
description: 'A list of all directives supported by this server.',
type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__Directive))),
resolve: function resolve(schema) {
return schema.getDirectives();
}
}
};
}
});
var __Directive = exports.__Directive = new _definition.GraphQLObjectType({
name: '__Directive',
isIntrospection: true,
description: 'A Directive provides a way to describe alternate runtime execution and ' + 'type validation behavior in a GraphQL document.' + '\n\nIn some cases, you need to provide options to alter GraphQL\'s ' + 'execution behavior in ways field arguments will not suffice, such as ' + 'conditionally including or skipping a field. Directives provide this by ' + 'describing additional information to the executor.',
fields: function fields() {
return {
name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
description: { type: _scalars.GraphQLString },
locations: {
type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__DirectiveLocation)))
},
args: {
type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue))),
resolve: function resolve(directive) {
return directive.args || [];
}
},
// NOTE: the following three fields are deprecated and are no longer part
// of the GraphQL specification.
onOperation: {
deprecationReason: 'Use `locations`.',
type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
resolve: function resolve(d) {
return d.locations.indexOf(_directives.DirectiveLocation.QUERY) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.MUTATION) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.SUBSCRIPTION) !== -1;
}
},
onFragment: {
deprecationReason: 'Use `locations`.',
type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
resolve: function resolve(d) {
return d.locations.indexOf(_directives.DirectiveLocation.FRAGMENT_SPREAD) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.INLINE_FRAGMENT) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.FRAGMENT_DEFINITION) !== -1;
}
},
onField: {
deprecationReason: 'Use `locations`.',
type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
resolve: function resolve(d) {
return d.locations.indexOf(_directives.DirectiveLocation.FIELD) !== -1;
}
}
};
}
});
var __DirectiveLocation = exports.__DirectiveLocation = new _definition.GraphQLEnumType({
name: '__DirectiveLocation',
isIntrospection: true,
description: 'A Directive can be adjacent to many parts of the GraphQL language, a ' + '__DirectiveLocation describes one such possible adjacencies.',
values: {
QUERY: {
value: _directives.DirectiveLocation.QUERY,
description: 'Location adjacent to a query operation.'
},
MUTATION: {
value: _directives.DirectiveLocation.MUTATION,
description: 'Location adjacent to a mutation operation.'
},
SUBSCRIPTION: {
value: _directives.DirectiveLocation.SUBSCRIPTION,
description: 'Location adjacent to a subscription operation.'
},
FIELD: {
value: _directives.DirectiveLocation.FIELD,
description: 'Location adjacent to a field.'
},
FRAGMENT_DEFINITION: {
value: _directives.DirectiveLocation.FRAGMENT_DEFINITION,
description: 'Location adjacent to a fragment definition.'
},
FRAGMENT_SPREAD: {
value: _directives.DirectiveLocation.FRAGMENT_SPREAD,
description: 'Location adjacent to a fragment spread.'
},
INLINE_FRAGMENT: {
value: _directives.DirectiveLocation.INLINE_FRAGMENT,
description: 'Location adjacent to an inline fragment.'
},
SCHEMA: {
value: _directives.DirectiveLocation.SCHEMA,
description: 'Location adjacent to a schema definition.'
},
SCALAR: {
value: _directives.DirectiveLocation.SCALAR,
description: 'Location adjacent to a scalar definition.'
},
OBJECT: {
value: _directives.DirectiveLocation.OBJECT,
description: 'Location adjacent to an object type definition.'
},
FIELD_DEFINITION: {
value: _directives.DirectiveLocation.FIELD_DEFINITION,
description: 'Location adjacent to a field definition.'
},
ARGUMENT_DEFINITION: {
value: _directives.DirectiveLocation.ARGUMENT_DEFINITION,
description: 'Location adjacent to an argument definition.'
},
INTERFACE: {
value: _directives.DirectiveLocation.INTERFACE,
description: 'Location adjacent to an interface definition.'
},
UNION: {
value: _directives.DirectiveLocation.UNION,
description: 'Location adjacent to a union definition.'
},
ENUM: {
value: _directives.DirectiveLocation.ENUM,
description: 'Location adjacent to an enum definition.'
},
ENUM_VALUE: {
value: _directives.DirectiveLocation.ENUM_VALUE,
description: 'Location adjacent to an enum value definition.'
},
INPUT_OBJECT: {
value: _directives.DirectiveLocation.INPUT_OBJECT,
description: 'Location adjacent to an input object type definition.'
},
INPUT_FIELD_DEFINITION: {
value: _directives.DirectiveLocation.INPUT_FIELD_DEFINITION,
description: 'Location adjacent to an input object field definition.'
}
}
});
var __Type = exports.__Type = new _definition.GraphQLObjectType({
name: '__Type',
isIntrospection: true,
description: 'The fundamental unit of any GraphQL Schema is the type. There are ' + 'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' + '\n\nDepending on the kind of a type, certain fields describe ' + 'information about that type. Scalar types provide no information ' + 'beyond a name and description, while Enum types provide their values. ' + 'Object and Interface types provide the fields they describe. Abstract ' + 'types, Union and Interface, provide the Object types possible ' + 'at runtime. List and NonNull types compose other types.',
fields: function fields() {
return {
kind: {
type: new _definition.GraphQLNonNull(__TypeKind),
resolve: function resolve(type) {
if (type instanceof _definition.GraphQLScalarType) {
return TypeKind.SCALAR;
} else if (type instanceof _definition.GraphQLObjectType) {
return TypeKind.OBJECT;
} else if (type instanceof _definition.GraphQLInterfaceType) {
return TypeKind.INTERFACE;
} else if (type instanceof _definition.GraphQLUnionType) {
return TypeKind.UNION;
} else if (type instanceof _definition.GraphQLEnumType) {
return TypeKind.ENUM;
} else if (type instanceof _definition.GraphQLInputObjectType) {
return TypeKind.INPUT_OBJECT;
} else if (type instanceof _definition.GraphQLList) {
return TypeKind.LIST;
} else if (type instanceof _definition.GraphQLNonNull) {
return TypeKind.NON_NULL;
}
throw new Error('Unknown kind of type: ' + type);
}
},
name: { type: _scalars.GraphQLString },
description: { type: _scalars.GraphQLString },
fields: {
type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Field)),
args: {
includeDeprecated: { type: _scalars.GraphQLBoolean, defaultValue: false }
},
resolve: function resolve(type, _ref) {
var includeDeprecated = _ref.includeDeprecated;
if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
var _ret = function () {
var fieldMap = type.getFields();
var fields = Object.keys(fieldMap).map(function (fieldName) {
return fieldMap[fieldName];
});
if (!includeDeprecated) {
fields = fields.filter(function (field) {
return !field.deprecationReason;
});
}
return {
v: fields
};
}();
if (typeof _ret === "object") return _ret.v;
}
return null;
}
},
interfaces: {
type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)),
resolve: function resolve(type) {
if (type instanceof _definition.GraphQLObjectType) {
return type.getInterfaces();
}
}
},
possibleTypes: {
type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)),
resolve: function resolve(type, args, context, _ref2) {
var schema = _ref2.schema;
if (type instanceof _definition.GraphQLInterfaceType || type instanceof _definition.GraphQLUnionType) {
return schema.getPossibleTypes(type);
}
}
},
enumValues: {
type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__EnumValue)),
args: {
includeDeprecated: { type: _scalars.GraphQLBoolean, defaultValue: false }
},
resolve: function resolve(type, _ref3) {
var includeDeprecated = _ref3.includeDeprecated;
if (type instanceof _definition.GraphQLEnumType) {
var values = type.getValues();
if (!includeDeprecated) {
values = values.filter(function (value) {
return !value.deprecationReason;
});
}
return values;
}
}
},
inputFields: {
type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue)),
resolve: function resolve(type) {
if (type instanceof _definition.GraphQLInputObjectType) {
var _ret2 = function () {
var fieldMap = type.getFields();
return {
v: Object.keys(fieldMap).map(function (fieldName) {
return fieldMap[fieldName];
})
};
}();
if (typeof _ret2 === "object") return _ret2.v;
}
}
},
ofType: { type: __Type }
};
}
});
var __Field = exports.__Field = new _definition.GraphQLObjectType({
name: '__Field',
isIntrospection: true,
description: 'Object and Interface types are described by a list of Fields, each of ' + 'which has a name, potentially a list of arguments, and a return type.',
fields: function fields() {
return {
name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
description: { type: _scalars.GraphQLString },
args: {
type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue))),
resolve: function resolve(field) {
return field.args || [];
}
},
type: { type: new _definition.GraphQLNonNull(__Type) },
isDeprecated: { type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean) },
deprecationReason: {
type: _scalars.GraphQLString
}
};
}
});
var __InputValue = exports.__InputValue = new _definition.GraphQLObjectType({
name: '__InputValue',
isIntrospection: true,
description: 'Arguments provided to Fields or Directives and the input fields of an ' + 'InputObject are represented as Input Values which describe their type ' + 'and optionally a default value.',
fields: function fields() {
return {
name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
description: { type: _scalars.GraphQLString },
type: { type: new _definition.GraphQLNonNull(__Type) },
defaultValue: {
type: _scalars.GraphQLString,
description: 'A GraphQL-formatted string representing the default value for this ' + 'input value.',
resolve: function resolve(inputVal) {
return (0, _isInvalid2.default)(inputVal.defaultValue) ? null : (0, _printer.print)((0, _astFromValue.astFromValue)(inputVal.defaultValue, inputVal.type));
}
}
};
}
});
var __EnumValue = exports.__EnumValue = new _definition.GraphQLObjectType({
name: '__EnumValue',
isIntrospection: true,
description: 'One possible value for a given Enum. Enum values are unique values, not ' + 'a placeholder for a string or numeric value. However an Enum value is ' + 'returned in a JSON response as a string.',
fields: function fields() {
return {
name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
description: { type: _scalars.GraphQLString },
isDeprecated: { type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean) },
deprecationReason: {
type: _scalars.GraphQLString
}
};
}
});
var TypeKind = exports.TypeKind = {
SCALAR: 'SCALAR',
OBJECT: 'OBJECT',
INTERFACE: 'INTERFACE',
UNION: 'UNION',
ENUM: 'ENUM',
INPUT_OBJECT: 'INPUT_OBJECT',
LIST: 'LIST',
NON_NULL: 'NON_NULL'
};
var __TypeKind = exports.__TypeKind = new _definition.GraphQLEnumType({
name: '__TypeKind',
isIntrospection: true,
description: 'An enum describing what kind of type a given `__Type` is.',
values: {
SCALAR: {
value: TypeKind.SCALAR,
description: 'Indicates this type is a scalar.'
},
OBJECT: {
value: TypeKind.OBJECT,
description: 'Indicates this type is an object. ' + '`fields` and `interfaces` are valid fields.'
},
INTERFACE: {
value: TypeKind.INTERFACE,
description: 'Indicates this type is an interface. ' + '`fields` and `possibleTypes` are valid fields.'
},
UNION: {
value: TypeKind.UNION,
description: 'Indicates this type is a union. ' + '`possibleTypes` is a valid field.'
},
ENUM: {
value: TypeKind.ENUM,
description: 'Indicates this type is an enum. ' + '`enumValues` is a valid field.'
},
INPUT_OBJECT: {
value: TypeKind.INPUT_OBJECT,
description: 'Indicates this type is an input object. ' + '`inputFields` is a valid field.'
},
LIST: {
value: TypeKind.LIST,
description: 'Indicates this type is a list. ' + '`ofType` is a valid field.'
},
NON_NULL: {
value: TypeKind.NON_NULL,
description: 'Indicates this type is a non-null. ' + '`ofType` is a valid field.'
}
}
});
/**
* Note that these are GraphQLField and not GraphQLFieldConfig,
* so the format for args is different.
*/
var SchemaMetaFieldDef = exports.SchemaMetaFieldDef = {
name: '__schema',
type: new _definition.GraphQLNonNull(__Schema),
description: 'Access the current type schema of this server.',
args: [],
resolve: function resolve(source, args, context, _ref4) {
var schema = _ref4.schema;
return schema;
}
};
var TypeMetaFieldDef = exports.TypeMetaFieldDef = {
name: '__type',
type: __Type,
description: 'Request the type information of a single type.',
args: [{ name: 'name', type: new _definition.GraphQLNonNull(_scalars.GraphQLString) }],
resolve: function resolve(source, _ref5, context, _ref6) {
var name = _ref5.name;
var schema = _ref6.schema;
return schema.getType(name);
}
};
var TypeNameMetaFieldDef = exports.TypeNameMetaFieldDef = {
name: '__typename',
type: new _definition.GraphQLNonNull(_scalars.GraphQLString),
description: 'The name of the current Object type at runtime.',
args: [],
resolve: function resolve(source, args, context, _ref7) {
var parentType = _ref7.parentType;
return parentType.name;
}
};
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = keyMap;
/**
* Copyright (c) 2015, 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.
*/
/**
* Creates a keyed JS object from an array, given a function to produce the keys
* for each value in the array.
*
* This provides a convenient lookup for the array items if the key function
* produces unique results.
*
* const phoneBook = [
* { name: 'Jon', num: '555-1234' },
* { name: 'Jenny', num: '867-5309' }
* ]
*
* // { Jon: { name: 'Jon', num: '555-1234' },
* // Jenny: { name: 'Jenny', num: '867-5309' } }
* const entriesByName = keyMap(
* phoneBook,
* entry => entry.name
* )
*
* // { name: 'Jenny', num: '857-6309' }
* const jennyEntry = entriesByName['Jenny']
*
*/
function keyMap(list, keyFn) {
return list.reduce(function (map, item) {
return map[keyFn(item)] = item, map;
}, {});
}
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GraphQLError = GraphQLError;
var _location = __webpack_require__(25);
/**
* A GraphQLError describes an Error found during the parse, validate, or
* execute phases of performing a GraphQL operation. In addition to a message
* and stack trace, it also includes information about the locations in a
* GraphQL document and/or execution result that correspond to the Error.
*/
function GraphQLError( // eslint-disable-line no-redeclare
message, nodes, source, positions, path, originalError) {
// Include (non-enumerable) stack trace.
if (originalError && originalError.stack) {
Object.defineProperty(this, 'stack', {
value: originalError.stack,
writable: true,
configurable: true
});
} else if (Error.captureStackTrace) {
Error.captureStackTrace(this, GraphQLError);
} else {
Object.defineProperty(this, 'stack', {
value: Error().stack,
writable: true,
configurable: true
});
}
// Compute locations in the source for the given nodes/positions.
var _source = source;
if (!_source && nodes && nodes.length > 0) {
var node = nodes[0];
_source = node && node.loc && node.loc.source;
}
var _positions = positions;
if (!_positions && nodes) {
_positions = nodes.filter(function (node) {
return Boolean(node.loc);
}).map(function (node) {
return node.loc.start;
});
}
if (_positions && _positions.length === 0) {
_positions = undefined;
}
var _locations = void 0;
var _source2 = _source; // seems here Flow need a const to resolve type.
if (_source2 && _positions) {
_locations = _positions.map(function (pos) {
return (0, _location.getLocation)(_source2, pos);
});
}
Object.defineProperties(this, {
message: {
value: message,
// By being enumerable, JSON.stringify will include `message` in the
// resulting output. This ensures that the simplist possible GraphQL
// service adheres to the spec.
enumerable: true,
writable: true
},
locations: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: _locations || undefined,
// By being enumerable, JSON.stringify will include `locations` in the
// resulting output. This ensures that the simplist possible GraphQL
// service adheres to the spec.
enumerable: true
},
path: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: path || undefined,
// By being enumerable, JSON.stringify will include `path` in the
// resulting output. This ensures that the simplist possible GraphQL
// service adheres to the spec.
enumerable: true
},
nodes: {
value: nodes || undefined
},
source: {
value: _source || undefined
},
positions: {
value: _positions || undefined
},
originalError: {
value: originalError
}
});
}
/**
* Copyright (c) 2015, 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.
*/
GraphQLError.prototype = Object.create(Error.prototype, {
constructor: { value: GraphQLError },
name: { value: 'GraphQLError' }
});
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isInvalid;
/**
* Copyright (c) 2015, 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.
*/
/**
* Returns true if a value is undefined, or NaN.
*/
function isInvalid(value) {
return value === undefined || value !== value;
}
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.visit = visit;
exports.visitInParallel = visitInParallel;
exports.visitWithTypeInfo = visitWithTypeInfo;
/**
* Copyright (c) 2015, 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.
*/
var QueryDocumentKeys = exports.QueryDocumentKeys = {
Name: [],
Document: ['definitions'],
OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],
VariableDefinition: ['variable', 'type', 'defaultValue'],
Variable: ['name'],
SelectionSet: ['selections'],
Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
Argument: ['name', 'value'],
FragmentSpread: ['name', 'directives'],
InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
FragmentDefinition: ['name', 'typeCondition', 'directives', 'selectionSet'],
IntValue: [],
FloatValue: [],
StringValue: [],
BooleanValue: [],
NullValue: [],
EnumValue: [],
ListValue: ['values'],
ObjectValue: ['fields'],
ObjectField: ['name', 'value'],
Directive: ['name', 'arguments'],
NamedType: ['name'],
ListType: ['type'],
NonNullType: ['type'],
SchemaDefinition: ['directives', 'operationTypes'],
OperationTypeDefinition: ['type'],
ScalarTypeDefinition: ['name', 'directives'],
ObjectTypeDefinition: ['name', 'interfaces', 'directives', 'fields'],
FieldDefinition: ['name', 'arguments', 'type', 'directives'],
InputValueDefinition: ['name', 'type', 'defaultValue', 'directives'],
InterfaceTypeDefinition: ['name', 'directives', 'fields'],
UnionTypeDefinition: ['name', 'directives', 'types'],
EnumTypeDefinition: ['name', 'directives', 'values'],
EnumValueDefinition: ['name', 'directives'],
InputObjectTypeDefinition: ['name', 'directives', 'fields'],
TypeExtensionDefinition: ['definition'],
DirectiveDefinition: ['name', 'arguments', 'locations']
};
var BREAK = exports.BREAK = {};
/**
* visit() will walk through an AST using a depth first traversal, calling
* the visitor's enter function at each node in the traversal, and calling the
* leave function after visiting that node and all of its child nodes.
*
* By returning different values from the enter and leave functions, the
* behavior of the visitor can be altered, including skipping over a sub-tree of
* the AST (by returning false), editing the AST by returning a value or null
* to remove the value, or to stop the whole traversal by returning BREAK.
*
* When using visit() to edit an AST, the original AST will not be modified, and
* a new version of the AST with the changes applied will be returned from the
* visit function.
*
* const editedAST = visit(ast, {
* enter(node, key, parent, path, ancestors) {
* // @return
* // undefined: no action
* // false: skip visiting this node
* // visitor.BREAK: stop visiting altogether
* // null: delete this node
* // any value: replace this node with the returned value
* },
* leave(node, key, parent, path, ancestors) {
* // @return
* // undefined: no action
* // false: no action
* // visitor.BREAK: stop visiting altogether
* // null: delete this node
* // any value: replace this node with the returned value
* }
* });
*
* Alternatively to providing enter() and leave() functions, a visitor can
* instead provide functions named the same as the kinds of AST nodes, or
* enter/leave visitors at a named key, leading to four permutations of
* visitor API:
*
* 1) Named visitors triggered when entering a node a specific kind.
*
* visit(ast, {
* Kind(node) {
* // enter the "Kind" node
* }
* })
*
* 2) Named visitors that trigger upon entering and leaving a node of
* a specific kind.
*
* visit(ast, {
* Kind: {
* enter(node) {
* // enter the "Kind" node
* }
* leave(node) {
* // leave the "Kind" node
* }
* }
* })
*
* 3) Generic visitors that trigger upon entering and leaving any node.
*
* visit(ast, {
* enter(node) {
* // enter any node
* },
* leave(node) {
* // leave any node
* }
* })
*
* 4) Parallel visitors for entering and leaving nodes of a specific kind.
*
* visit(ast, {
* enter: {
* Kind(node) {
* // enter the "Kind" node
* }
* },
* leave: {
* Kind(node) {
* // leave the "Kind" node
* }
* }
* })
*/
function visit(root, visitor, keyMap) {
var visitorKeys = keyMap || QueryDocumentKeys;
var stack = void 0;
var inArray = Array.isArray(root);
var keys = [root];
var index = -1;
var edits = [];
var parent = void 0;
var path = [];
var ancestors = [];
var newRoot = root;
do {
index++;
var isLeaving = index === keys.length;
var key = void 0;
var node = void 0;
var isEdited = isLeaving && edits.length !== 0;
if (isLeaving) {
key = ancestors.length === 0 ? undefined : path.pop();
node = parent;
parent = ancestors.pop();
if (isEdited) {
if (inArray) {
node = node.slice();
} else {
var clone = {};
for (var k in node) {
if (node.hasOwnProperty(k)) {
clone[k] = node[k];
}
}
node = clone;
}
var editOffset = 0;
for (var ii = 0; ii < edits.length; ii++) {
var editKey = edits[ii][0];
var editValue = edits[ii][1];
if (inArray) {
editKey -= editOffset;
}
if (inArray && editValue === null) {
node.splice(editKey, 1);
editOffset++;
} else {
node[editKey] = editValue;
}
}
}
index = stack.index;
keys = stack.keys;
edits = stack.edits;
inArray = stack.inArray;
stack = stack.prev;
} else {
key = parent ? inArray ? index : keys[index] : undefined;
node = parent ? parent[key] : newRoot;
if (node === null || node === undefined) {
continue;
}
if (parent) {
path.push(key);
}
}
var result = void 0;
if (!Array.isArray(node)) {
if (!isNode(node)) {
throw new Error('Invalid AST Node: ' + JSON.stringify(node));
}
var visitFn = getVisitFn(visitor, node.kind, isLeaving);
if (visitFn) {
result = visitFn.call(visitor, node, key, parent, path, ancestors);
if (result === BREAK) {
break;
}
if (result === false) {
if (!isLeaving) {
path.pop();
continue;
}
} else if (result !== undefined) {
edits.push([key, result]);
if (!isLeaving) {
if (isNode(result)) {
node = result;
} else {
path.pop();
continue;
}
}
}
}
}
if (result === undefined && isEdited) {
edits.push([key, node]);
}
if (!isLeaving) {
stack = { inArray: inArray, index: index, keys: keys, edits: edits, prev: stack };
inArray = Array.isArray(node);
keys = inArray ? node : visitorKeys[node.kind] || [];
index = -1;
edits = [];
if (parent) {
ancestors.push(parent);
}
parent = node;
}
} while (stack !== undefined);
if (edits.length !== 0) {
newRoot = edits[edits.length - 1][1];
}
return newRoot;
}
function isNode(maybeNode) {
return maybeNode && typeof maybeNode.kind === 'string';
}
/**
* Creates a new visitor instance which delegates to many visitors to run in
* parallel. Each visitor will be visited for each node before moving on.
*
* If a prior visitor edits a node, no following visitors will see that node.
*/
function visitInParallel(visitors) {
var skipping = new Array(visitors.length);
return {
enter: function enter(node) {
for (var i = 0; i < visitors.length; i++) {
if (!skipping[i]) {
var fn = getVisitFn(visitors[i], node.kind, /* isLeaving */false);
if (fn) {
var result = fn.apply(visitors[i], arguments);
if (result === false) {
skipping[i] = node;
} else if (result === BREAK) {
skipping[i] = BREAK;
} else if (result !== undefined) {
return result;
}
}
}
}
},
leave: function leave(node) {
for (var i = 0; i < visitors.length; i++) {
if (!skipping[i]) {
var fn = getVisitFn(visitors[i], node.kind, /* isLeaving */true);
if (fn) {
var result = fn.apply(visitors[i], arguments);
if (result === BREAK) {
skipping[i] = BREAK;
} else if (result !== undefined && result !== false) {
return result;
}
}
} else if (skipping[i] === node) {
skipping[i] = null;
}
}
}
};
}
/**
* Creates a new visitor instance which maintains a provided TypeInfo instance
* along with visiting visitor.
*/
function visitWithTypeInfo(typeInfo, visitor) {
return {
enter: function enter(node) {
typeInfo.enter(node);
var fn = getVisitFn(visitor, node.kind, /* isLeaving */false);
if (fn) {
var result = fn.apply(visitor, arguments);
if (result !== undefined) {
typeInfo.leave(node);
if (isNode(result)) {
typeInfo.enter(result);
}
}
return result;
}
},
leave: function leave(node) {
var fn = getVisitFn(visitor, node.kind, /* isLeaving */true);
var result = void 0;
if (fn) {
result = fn.apply(visitor, arguments);
}
typeInfo.leave(node);
return result;
}
};
}
/**
* Given a visitor instance, if it is leaving or not, and a node kind, return
* the function the visitor runtime should call.
*/
function getVisitFn(visitor, kind, isLeaving) {
var kindVisitor = visitor[kind];
if (kindVisitor) {
if (!isLeaving && typeof kindVisitor === 'function') {
// { Kind() {} }
return kindVisitor;
}
var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;
if (typeof kindSpecificVisitor === 'function') {
// { Kind: { enter() {}, leave() {} } }
return kindSpecificVisitor;
}
} else {
var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
if (specificVisitor) {
if (typeof specificVisitor === 'function') {
// { enter() {}, leave() {} }
return specificVisitor;
}
var specificKindVisitor = specificVisitor[kind];
if (typeof specificKindVisitor === 'function') {
// { enter: { Kind() {} }, leave: { Kind() {} } }
return specificKindVisitor;
}
}
}
}
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.valueFromAST = valueFromAST;
var _keyMap = __webpack_require__(12);
var _keyMap2 = _interopRequireDefault(_keyMap);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _isNullish = __webpack_require__(6);
var _isNullish2 = _interopRequireDefault(_isNullish);
var _isInvalid = __webpack_require__(14);
var _isInvalid2 = _interopRequireDefault(_isInvalid);
var _kinds = __webpack_require__(2);
var Kind = _interopRequireWildcard(_kinds);
var _definition = __webpack_require__(1);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Produces a JavaScript value given a GraphQL Value AST.
*
* A GraphQL type must be provided, which will be used to interpret different
* GraphQL Value literals.
*
* Returns `undefined` when the value could not be validly coerced according to
* the provided type.
*
* | GraphQL Value | JSON Value |
* | -------------------- | ------------- |
* | Input Object | Object |
* | List | Array |
* | Boolean | Boolean |
* | String | String |
* | Int / Float | Number |
* | Enum Value | Mixed |
* | NullValue | null |
*
*/
/**
* Copyright (c) 2015, 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.
*/
function valueFromAST(valueNode, type, variables) {
if (!valueNode) {
// When there is no node, then there is also no value.
// Importantly, this is different from returning the value null.
return;
}
if (type instanceof _definition.GraphQLNonNull) {
if (valueNode.kind === Kind.NULL) {
return; // Invalid: intentionally return no value.
}
return valueFromAST(valueNode, type.ofType, variables);
}
if (valueNode.kind === Kind.NULL) {
// This is explicitly returning the value null.
return null;
}
if (valueNode.kind === Kind.VARIABLE) {
var variableName = valueNode.name.value;
if (!variables || (0, _isInvalid2.default)(variables[variableName])) {
// No valid return value.
return;
}
// Note: we're not doing any checking that this variable is correct. We're
// assuming that this query has been validated and the variable usage here
// is of the correct type.
return variables[variableName];
}
if (type instanceof _definition.GraphQLList) {
var itemType = type.ofType;
if (valueNode.kind === Kind.LIST) {
var coercedValues = [];
var itemNodes = valueNode.values;
for (var i = 0; i < itemNodes.length; i++) {
if (isMissingVariable(itemNodes[i], variables)) {
// If an array contains a missing variable, it is either coerced to
// null or if the item type is non-null, it considered invalid.
if (itemType instanceof _definition.GraphQLNonNull) {
return; // Invalid: intentionally return no value.
}
coercedValues.push(null);
} else {
var itemValue = valueFromAST(itemNodes[i], itemType, variables);
if ((0, _isInvalid2.default)(itemValue)) {
return; // Invalid: intentionally return no value.
}
coercedValues.push(itemValue);
}
}
return coercedValues;
}
var coercedValue = valueFromAST(valueNode, itemType, variables);
if ((0, _isInvalid2.default)(coercedValue)) {
return; // Invalid: intentionally return no value.
}
return [coercedValue];
}
if (type instanceof _definition.GraphQLInputObjectType) {
if (valueNode.kind !== Kind.OBJECT) {
return; // Invalid: intentionally return no value.
}
var coercedObj = Object.create(null);
var fields = type.getFields();
var fieldNodes = (0, _keyMap2.default)(valueNode.fields, function (field) {
return field.name.value;
});
var fieldNames = Object.keys(fields);
for (var _i = 0; _i < fieldNames.length; _i++) {
var fieldName = fieldNames[_i];
var field = fields[fieldName];
var fieldNode = fieldNodes[fieldName];
if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
if (!(0, _isInvalid2.default)(field.defaultValue)) {
coercedObj[fieldName] = field.defaultValue;
} else if (field.type instanceof _definition.GraphQLNonNull) {
return; // Invalid: intentionally return no value.
}
continue;
}
var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
if ((0, _isInvalid2.default)(fieldValue)) {
return; // Invalid: intentionally return no value.
}
coercedObj[fieldName] = fieldValue;
}
return coercedObj;
}
(0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
var parsed = type.parseLiteral(valueNode);
if ((0, _isNullish2.default)(parsed)) {
// null or invalid values represent a failure to parse correctly,
// in which case no value is returned.
return;
}
return parsed;
}
// Returns true if the provided valueNode is a variable which is not defined
// in the set of variables.
function isMissingVariable(valueNode, variables) {
return valueNode.kind === Kind.VARIABLE && (!variables || (0, _isInvalid2.default)(variables[valueNode.name.value]));
}
/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parse = parse;
exports.parseValue = parseValue;
exports.parseType = parseType;
exports.parseConstValue = parseConstValue;
exports.parseTypeReference = parseTypeReference;
exports.parseNamedType = parseNamedType;
var _source = __webpack_require__(26);
var _error = __webpack_require__(0);
var _lexer = __webpack_require__(24);
var _kinds = __webpack_require__(2);
/**
* Given a GraphQL source, parses it into a Document.
* Throws GraphQLError if a syntax error is encountered.
*/
/**
* Configuration options to control parser behavior
*/
/**
* Copyright (c) 2015, 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.
*/
function parse(source, options) {
var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
return parseDocument(lexer);
}
/**
* Given a string containing a GraphQL value (ex. `[42]`), parse the AST for
* that value.
* Throws GraphQLError if a syntax error is encountered.
*
* This is useful within tools that operate upon GraphQL Values directly and
* in isolation of complete GraphQL documents.
*
* Consider providing the results to the utility function: valueFromAST().
*/
function parseValue(source, options) {
var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
expect(lexer, _lexer.TokenKind.SOF);
var value = parseValueLiteral(lexer, false);
expect(lexer, _lexer.TokenKind.EOF);
return value;
}
/**
* Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
* that type.
* Throws GraphQLError if a syntax error is encountered.
*
* This is useful within tools that operate upon GraphQL Types directly and
* in isolation of complete GraphQL documents.
*
* Consider providing the results to the utility function: typeFromAST().
*/
function parseType(source, options) {
var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
expect(lexer, _lexer.TokenKind.SOF);
var type = parseTypeReference(lexer);
expect(lexer, _lexer.TokenKind.EOF);
return type;
}
/**
* Converts a name lex token into a name parse node.
*/
function parseName(lexer) {
var token = expect(lexer, _lexer.TokenKind.NAME);
return {
kind: _kinds.NAME,
value: token.value,
loc: loc(lexer, token)
};
}
// Implements the parsing rules in the Document section.
/**
* Document : Definition+
*/
function parseDocument(lexer) {
var start = lexer.token;
expect(lexer, _lexer.TokenKind.SOF);
var definitions = [];
do {
definitions.push(parseDefinition(lexer));
} while (!skip(lexer, _lexer.TokenKind.EOF));
return {
kind: _kinds.DOCUMENT,
definitions: definitions,
loc: loc(lexer, start)
};
}
/**
* Definition :
* - OperationDefinition
* - FragmentDefinition
* - TypeSystemDefinition
*/
function parseDefinition(lexer) {
if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
return parseOperationDefinition(lexer);
}
if (peek(lexer, _lexer.TokenKind.NAME)) {
switch (lexer.token.value) {
// Note: subscription is an experimental non-spec addition.
case 'query':
case 'mutation':
case 'subscription':
return parseOperationDefinition(lexer);
case 'fragment':
return parseFragmentDefinition(lexer);
// Note: the Type System IDL is an experimental non-spec addition.
case 'schema':
case 'scalar':
case 'type':
case 'interface':
case 'union':
case 'enum':
case 'input':
case 'extend':
case 'directive':
return parseTypeSystemDefinition(lexer);
}
}
throw unexpected(lexer);
}
// Implements the parsing rules in the Operations section.
/**
* OperationDefinition :
* - SelectionSet
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
*/
function parseOperationDefinition(lexer) {
var start = lexer.token;
if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
return {
kind: _kinds.OPERATION_DEFINITION,
operation: 'query',
name: null,
variableDefinitions: null,
directives: [],
selectionSet: parseSelectionSet(lexer),
loc: loc(lexer, start)
};
}
var operation = parseOperationType(lexer);
var name = void 0;
if (peek(lexer, _lexer.TokenKind.NAME)) {
name = parseName(lexer);
}
return {
kind: _kinds.OPERATION_DEFINITION,
operation: operation,
name: name,
variableDefinitions: parseVariableDefinitions(lexer),
directives: parseDirectives(lexer),
selectionSet: parseSelectionSet(lexer),
loc: loc(lexer, start)
};
}
/**
* OperationType : one of query mutation subscription
*/
function parseOperationType(lexer) {
var operationToken = expect(lexer, _lexer.TokenKind.NAME);
switch (operationToken.value) {
case 'query':
return 'query';
case 'mutation':
return 'mutation';
// Note: subscription is an experimental non-spec addition.
case 'subscription':
return 'subscription';
}
throw unexpected(lexer, operationToken);
}
/**
* VariableDefinitions : ( VariableDefinition+ )
*/
function parseVariableDefinitions(lexer) {
return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseVariableDefinition, _lexer.TokenKind.PAREN_R) : [];
}
/**
* VariableDefinition : Variable : Type DefaultValue?
*/
function parseVariableDefinition(lexer) {
var start = lexer.token;
return {
kind: _kinds.VARIABLE_DEFINITION,
variable: parseVariable(lexer),
type: (expect(lexer, _lexer.TokenKind.COLON), parseTypeReference(lexer)),
defaultValue: skip(lexer, _lexer.TokenKind.EQUALS) ? parseValueLiteral(lexer, true) : null,
loc: loc(lexer, start)
};
}
/**
* Variable : $ Name
*/
function parseVariable(lexer) {
var start = lexer.token;
expect(lexer, _lexer.TokenKind.DOLLAR);
return {
kind: _kinds.VARIABLE,
name: parseName(lexer),
loc: loc(lexer, start)
};
}
/**
* SelectionSet : { Selection+ }
*/
function parseSelectionSet(lexer) {
var start = lexer.token;
return {
kind: _kinds.SELECTION_SET,
selections: many(lexer, _lexer.TokenKind.BRACE_L, parseSelection, _lexer.TokenKind.BRACE_R),
loc: loc(lexer, start)
};
}
/**
* Selection :
* - Field
* - FragmentSpread
* - InlineFragment
*/
function parseSelection(lexer) {
return peek(lexer, _lexer.TokenKind.SPREAD) ? parseFragment(lexer) : parseField(lexer);
}
/**
* Field : Alias? Name Arguments? Directives? SelectionSet?
*
* Alias : Name :
*/
function parseField(lexer) {
var start = lexer.token;
var nameOrAlias = parseName(lexer);
var alias = void 0;
var name = void 0;
if (skip(lexer, _lexer.TokenKind.COLON)) {
alias = nameOrAlias;
name = parseName(lexer);
} else {
alias = null;
name = nameOrAlias;
}
return {
kind: _kinds.FIELD,
alias: alias,
name: name,
arguments: parseArguments(lexer),
directives: parseDirectives(lexer),
selectionSet: peek(lexer, _lexer.TokenKind.BRACE_L) ? parseSelectionSet(lexer) : null,
loc: loc(lexer, start)
};
}
/**
* Arguments : ( Argument+ )
*/
function parseArguments(lexer) {
return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseArgument, _lexer.TokenKind.PAREN_R) : [];
}
/**
* Argument : Name : Value
*/
function parseArgument(lexer) {
var start = lexer.token;
return {
kind: _kinds.ARGUMENT,
name: parseName(lexer),
value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, false)),
loc: loc(lexer, start)
};
}
// Implements the parsing rules in the Fragments section.
/**
* Corresponds to both FragmentSpread and InlineFragment in the spec.
*
* FragmentSpread : ... FragmentName Directives?
*
* InlineFragment : ... TypeCondition? Directives? SelectionSet
*/
function parseFragment(lexer) {
var start = lexer.token;
expect(lexer, _lexer.TokenKind.SPREAD);
if (peek(lexer, _lexer.TokenKind.NAME) && lexer.token.value !== 'on') {
return {
kind: _kinds.FRAGMENT_SPREAD,
name: parseFragmentName(lexer),
directives: parseDirectives(lexer),
loc: loc(lexer, start)
};
}
var typeCondition = null;
if (lexer.token.value === 'on') {
lexer.advance();
typeCondition = parseNamedType(lexer);
}
return {
kind: _kinds.INLINE_FRAGMENT,
typeCondition: typeCondition,
directives: parseDirectives(lexer),
selectionSet: parseSelectionSet(lexer),
loc: loc(lexer, start)
};
}
/**
* FragmentDefinition :
* - fragment FragmentName on TypeCondition Directives? SelectionSet
*
* TypeCondition : NamedType
*/
function parseFragmentDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'fragment');
return {
kind: _kinds.FRAGMENT_DEFINITION,
name: parseFragmentName(lexer),
typeCondition: (expectKeyword(lexer, 'on'), parseNamedType(lexer)),
directives: parseDirectives(lexer),
selectionSet: parseSelectionSet(lexer),
loc: loc(lexer, start)
};
}
/**
* FragmentName : Name but not `on`
*/
function parseFragmentName(lexer) {
if (lexer.token.value === 'on') {
throw unexpected(lexer);
}
return parseName(lexer);
}
// Implements the parsing rules in the Values section.
/**
* Value[Const] :
* - [~Const] Variable
* - IntValue
* - FloatValue
* - StringValue
* - BooleanValue
* - NullValue
* - EnumValue
* - ListValue[?Const]
* - ObjectValue[?Const]
*
* BooleanValue : one of `true` `false`
*
* NullValue : `null`
*
* EnumValue : Name but not `true`, `false` or `null`
*/
function parseValueLiteral(lexer, isConst) {
var token = lexer.token;
switch (token.kind) {
case _lexer.TokenKind.BRACKET_L:
return parseList(lexer, isConst);
case _lexer.TokenKind.BRACE_L:
return parseObject(lexer, isConst);
case _lexer.TokenKind.INT:
lexer.advance();
return {
kind: _kinds.INT,
value: token.value,
loc: loc(lexer, token)
};
case _lexer.TokenKind.FLOAT:
lexer.advance();
return {
kind: _kinds.FLOAT,
value: token.value,
loc: loc(lexer, token)
};
case _lexer.TokenKind.STRING:
lexer.advance();
return {
kind: _kinds.STRING,
value: token.value,
loc: loc(lexer, token)
};
case _lexer.TokenKind.NAME:
if (token.value === 'true' || token.value === 'false') {
lexer.advance();
return {
kind: _kinds.BOOLEAN,
value: token.value === 'true',
loc: loc(lexer, token)
};
} else if (token.value === 'null') {
lexer.advance();
return {
kind: _kinds.NULL,
loc: loc(lexer, token)
};
}
lexer.advance();
return {
kind: _kinds.ENUM,
value: token.value,
loc: loc(lexer, token)
};
case _lexer.TokenKind.DOLLAR:
if (!isConst) {
return parseVariable(lexer);
}
break;
}
throw unexpected(lexer);
}
function parseConstValue(lexer) {
return parseValueLiteral(lexer, true);
}
function parseValueValue(lexer) {
return parseValueLiteral(lexer, false);
}
/**
* ListValue[Const] :
* - [ ]
* - [ Value[?Const]+ ]
*/
function parseList(lexer, isConst) {
var start = lexer.token;
var item = isConst ? parseConstValue : parseValueValue;
return {
kind: _kinds.LIST,
values: any(lexer, _lexer.TokenKind.BRACKET_L, item, _lexer.TokenKind.BRACKET_R),
loc: loc(lexer, start)
};
}
/**
* ObjectValue[Const] :
* - { }
* - { ObjectField[?Const]+ }
*/
function parseObject(lexer, isConst) {
var start = lexer.token;
expect(lexer, _lexer.TokenKind.BRACE_L);
var fields = [];
while (!skip(lexer, _lexer.TokenKind.BRACE_R)) {
fields.push(parseObjectField(lexer, isConst));
}
return {
kind: _kinds.OBJECT,
fields: fields,
loc: loc(lexer, start)
};
}
/**
* ObjectField[Const] : Name : Value[?Const]
*/
function parseObjectField(lexer, isConst) {
var start = lexer.token;
return {
kind: _kinds.OBJECT_FIELD,
name: parseName(lexer),
value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, isConst)),
loc: loc(lexer, start)
};
}
// Implements the parsing rules in the Directives section.
/**
* Directives : Directive+
*/
function parseDirectives(lexer) {
var directives = [];
while (peek(lexer, _lexer.TokenKind.AT)) {
directives.push(parseDirective(lexer));
}
return directives;
}
/**
* Directive : @ Name Arguments?
*/
function parseDirective(lexer) {
var start = lexer.token;
expect(lexer, _lexer.TokenKind.AT);
return {
kind: _kinds.DIRECTIVE,
name: parseName(lexer),
arguments: parseArguments(lexer),
loc: loc(lexer, start)
};
}
// Implements the parsing rules in the Types section.
/**
* Type :
* - NamedType
* - ListType
* - NonNullType
*/
function parseTypeReference(lexer) {
var start = lexer.token;
var type = void 0;
if (skip(lexer, _lexer.TokenKind.BRACKET_L)) {
type = parseTypeReference(lexer);
expect(lexer, _lexer.TokenKind.BRACKET_R);
type = {
kind: _kinds.LIST_TYPE,
type: type,
loc: loc(lexer, start)
};
} else {
type = parseNamedType(lexer);
}
if (skip(lexer, _lexer.TokenKind.BANG)) {
return {
kind: _kinds.NON_NULL_TYPE,
type: type,
loc: loc(lexer, start)
};
}
return type;
}
/**
* NamedType : Name
*/
function parseNamedType(lexer) {
var start = lexer.token;
return {
kind: _kinds.NAMED_TYPE,
name: parseName(lexer),
loc: loc(lexer, start)
};
}
// Implements the parsing rules in the Type Definition section.
/**
* TypeSystemDefinition :
* - SchemaDefinition
* - TypeDefinition
* - TypeExtensionDefinition
* - DirectiveDefinition
*
* TypeDefinition :
* - ScalarTypeDefinition
* - ObjectTypeDefinition
* - InterfaceTypeDefinition
* - UnionTypeDefinition
* - EnumTypeDefinition
* - InputObjectTypeDefinition
*/
function parseTypeSystemDefinition(lexer) {
if (peek(lexer, _lexer.TokenKind.NAME)) {
switch (lexer.token.value) {
case 'schema':
return parseSchemaDefinition(lexer);
case 'scalar':
return parseScalarTypeDefinition(lexer);
case 'type':
return parseObjectTypeDefinition(lexer);
case 'interface':
return parseInterfaceTypeDefinition(lexer);
case 'union':
return parseUnionTypeDefinition(lexer);
case 'enum':
return parseEnumTypeDefinition(lexer);
case 'input':
return parseInputObjectTypeDefinition(lexer);
case 'extend':
return parseTypeExtensionDefinition(lexer);
case 'directive':
return parseDirectiveDefinition(lexer);
}
}
throw unexpected(lexer);
}
/**
* SchemaDefinition : schema Directives? { OperationTypeDefinition+ }
*
* OperationTypeDefinition : OperationType : NamedType
*/
function parseSchemaDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'schema');
var directives = parseDirectives(lexer);
var operationTypes = many(lexer, _lexer.TokenKind.BRACE_L, parseOperationTypeDefinition, _lexer.TokenKind.BRACE_R);
return {
kind: _kinds.SCHEMA_DEFINITION,
directives: directives,
operationTypes: operationTypes,
loc: loc(lexer, start)
};
}
function parseOperationTypeDefinition(lexer) {
var start = lexer.token;
var operation = parseOperationType(lexer);
expect(lexer, _lexer.TokenKind.COLON);
var type = parseNamedType(lexer);
return {
kind: _kinds.OPERATION_TYPE_DEFINITION,
operation: operation,
type: type,
loc: loc(lexer, start)
};
}
/**
* ScalarTypeDefinition : scalar Name Directives?
*/
function parseScalarTypeDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'scalar');
var name = parseName(lexer);
var directives = parseDirectives(lexer);
return {
kind: _kinds.SCALAR_TYPE_DEFINITION,
name: name,
directives: directives,
loc: loc(lexer, start)
};
}
/**
* ObjectTypeDefinition :
* - type Name ImplementsInterfaces? Directives? { FieldDefinition+ }
*/
function parseObjectTypeDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'type');
var name = parseName(lexer);
var interfaces = parseImplementsInterfaces(lexer);
var directives = parseDirectives(lexer);
var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseFieldDefinition, _lexer.TokenKind.BRACE_R);
return {
kind: _kinds.OBJECT_TYPE_DEFINITION,
name: name,
interfaces: interfaces,
directives: directives,
fields: fields,
loc: loc(lexer, start)
};
}
/**
* ImplementsInterfaces : implements NamedType+
*/
function parseImplementsInterfaces(lexer) {
var types = [];
if (lexer.token.value === 'implements') {
lexer.advance();
do {
types.push(parseNamedType(lexer));
} while (peek(lexer, _lexer.TokenKind.NAME));
}
return types;
}
/**
* FieldDefinition : Name ArgumentsDefinition? : Type Directives?
*/
function parseFieldDefinition(lexer) {
var start = lexer.token;
var name = parseName(lexer);
var args = parseArgumentDefs(lexer);
expect(lexer, _lexer.TokenKind.COLON);
var type = parseTypeReference(lexer);
var directives = parseDirectives(lexer);
return {
kind: _kinds.FIELD_DEFINITION,
name: name,
arguments: args,
type: type,
directives: directives,
loc: loc(lexer, start)
};
}
/**
* ArgumentsDefinition : ( InputValueDefinition+ )
*/
function parseArgumentDefs(lexer) {
if (!peek(lexer, _lexer.TokenKind.PAREN_L)) {
return [];
}
return many(lexer, _lexer.TokenKind.PAREN_L, parseInputValueDef, _lexer.TokenKind.PAREN_R);
}
/**
* InputValueDefinition : Name : Type DefaultValue? Directives?
*/
function parseInputValueDef(lexer) {
var start = lexer.token;
var name = parseName(lexer);
expect(lexer, _lexer.TokenKind.COLON);
var type = parseTypeReference(lexer);
var defaultValue = null;
if (skip(lexer, _lexer.TokenKind.EQUALS)) {
defaultValue = parseConstValue(lexer);
}
var directives = parseDirectives(lexer);
return {
kind: _kinds.INPUT_VALUE_DEFINITION,
name: name,
type: type,
defaultValue: defaultValue,
directives: directives,
loc: loc(lexer, start)
};
}
/**
* InterfaceTypeDefinition : interface Name Directives? { FieldDefinition+ }
*/
function parseInterfaceTypeDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'interface');
var name = parseName(lexer);
var directives = parseDirectives(lexer);
var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseFieldDefinition, _lexer.TokenKind.BRACE_R);
return {
kind: _kinds.INTERFACE_TYPE_DEFINITION,
name: name,
directives: directives,
fields: fields,
loc: loc(lexer, start)
};
}
/**
* UnionTypeDefinition : union Name Directives? = UnionMembers
*/
function parseUnionTypeDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'union');
var name = parseName(lexer);
var directives = parseDirectives(lexer);
expect(lexer, _lexer.TokenKind.EQUALS);
var types = parseUnionMembers(lexer);
return {
kind: _kinds.UNION_TYPE_DEFINITION,
name: name,
directives: directives,
types: types,
loc: loc(lexer, start)
};
}
/**
* UnionMembers :
* - NamedType
* - UnionMembers | NamedType
*/
function parseUnionMembers(lexer) {
var members = [];
do {
members.push(parseNamedType(lexer));
} while (skip(lexer, _lexer.TokenKind.PIPE));
return members;
}
/**
* EnumTypeDefinition : enum Name Directives? { EnumValueDefinition+ }
*/
function parseEnumTypeDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'enum');
var name = parseName(lexer);
var directives = parseDirectives(lexer);
var values = many(lexer, _lexer.TokenKind.BRACE_L, parseEnumValueDefinition, _lexer.TokenKind.BRACE_R);
return {
kind: _kinds.ENUM_TYPE_DEFINITION,
name: name,
directives: directives,
values: values,
loc: loc(lexer, start)
};
}
/**
* EnumValueDefinition : EnumValue Directives?
*
* EnumValue : Name
*/
function parseEnumValueDefinition(lexer) {
var start = lexer.token;
var name = parseName(lexer);
var directives = parseDirectives(lexer);
return {
kind: _kinds.ENUM_VALUE_DEFINITION,
name: name,
directives: directives,
loc: loc(lexer, start)
};
}
/**
* InputObjectTypeDefinition : input Name Directives? { InputValueDefinition+ }
*/
function parseInputObjectTypeDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'input');
var name = parseName(lexer);
var directives = parseDirectives(lexer);
var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseInputValueDef, _lexer.TokenKind.BRACE_R);
return {
kind: _kinds.INPUT_OBJECT_TYPE_DEFINITION,
name: name,
directives: directives,
fields: fields,
loc: loc(lexer, start)
};
}
/**
* TypeExtensionDefinition : extend ObjectTypeDefinition
*/
function parseTypeExtensionDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'extend');
var definition = parseObjectTypeDefinition(lexer);
return {
kind: _kinds.TYPE_EXTENSION_DEFINITION,
definition: definition,
loc: loc(lexer, start)
};
}
/**
* DirectiveDefinition :
* - directive @ Name ArgumentsDefinition? on DirectiveLocations
*/
function parseDirectiveDefinition(lexer) {
var start = lexer.token;
expectKeyword(lexer, 'directive');
expect(lexer, _lexer.TokenKind.AT);
var name = parseName(lexer);
var args = parseArgumentDefs(lexer);
expectKeyword(lexer, 'on');
var locations = parseDirectiveLocations(lexer);
return {
kind: _kinds.DIRECTIVE_DEFINITION,
name: name,
arguments: args,
locations: locations,
loc: loc(lexer, start)
};
}
/**
* DirectiveLocations :
* - Name
* - DirectiveLocations | Name
*/
function parseDirectiveLocations(lexer) {
var locations = [];
do {
locations.push(parseName(lexer));
} while (skip(lexer, _lexer.TokenKind.PIPE));
return locations;
}
// Core parsing utility functions
/**
* Returns a location object, used to identify the place in
* the source that created a given parsed object.
*/
function loc(lexer, startToken) {
if (!lexer.options.noLocation) {
return new Loc(startToken, lexer.lastToken, lexer.source);
}
}
function Loc(startToken, endToken, source) {
this.start = startToken.start;
this.end = endToken.end;
this.startToken = startToken;
this.endToken = endToken;
this.source = source;
}
// Print a simplified form when appearing in JSON/util.inspect.
Loc.prototype.toJSON = Loc.prototype.inspect = function toJSON() {
return { start: this.start, end: this.end };
};
/**
* Determines if the next token is of a given kind
*/
function peek(lexer, kind) {
return lexer.token.kind === kind;
}
/**
* If the next token is of the given kind, return true after advancing
* the lexer. Otherwise, do not change the parser state and return false.
*/
function skip(lexer, kind) {
var match = lexer.token.kind === kind;
if (match) {
lexer.advance();
}
return match;
}
/**
* If the next token is of the given kind, return that token after advancing
* the lexer. Otherwise, do not change the parser state and throw an error.
*/
function expect(lexer, kind) {
var token = lexer.token;
if (token.kind === kind) {
lexer.advance();
return token;
}
throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected ' + kind + ', found ' + (0, _lexer.getTokenDesc)(token));
}
/**
* If the next token is a keyword with the given value, return that token after
* advancing the lexer. Otherwise, do not change the parser state and return
* false.
*/
function expectKeyword(lexer, value) {
var token = lexer.token;
if (token.kind === _lexer.TokenKind.NAME && token.value === value) {
lexer.advance();
return token;
}
throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected "' + value + '", found ' + (0, _lexer.getTokenDesc)(token));
}
/**
* Helper function for creating an error when an unexpected lexed token
* is encountered.
*/
function unexpected(lexer, atToken) {
var token = atToken || lexer.token;
return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));
}
/**
* Returns a possibly empty list of parse nodes, determined by
* the parseFn. This list begins with a lex token of openKind
* and ends with a lex token of closeKind. Advances the parser
* to the next lex token after the closing token.
*/
function any(lexer, openKind, parseFn, closeKind) {
expect(lexer, openKind);
var nodes = [];
while (!skip(lexer, closeKind)) {
nodes.push(parseFn(lexer));
}
return nodes;
}
/**
* Returns a non-empty list of parse nodes, determined by
* the parseFn. This list begins with a lex token of openKind
* and ends with a lex token of closeKind. Advances the parser
* to the next lex token after the closing token.
*/
function many(lexer, openKind, parseFn, closeKind) {
expect(lexer, openKind);
var nodes = [parseFn(lexer)];
while (!skip(lexer, closeKind)) {
nodes.push(parseFn(lexer));
}
return nodes;
}
/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isValidLiteralValue = isValidLiteralValue;
var _printer = __webpack_require__(4);
var _kinds = __webpack_require__(2);
var _definition = __webpack_require__(1);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _keyMap = __webpack_require__(12);
var _keyMap2 = _interopRequireDefault(_keyMap);
var _isNullish = __webpack_require__(6);
var _isNullish2 = _interopRequireDefault(_isNullish);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Utility for validators which determines if a value literal node is valid
* given an input type.
*
* Note that this only validates literal values, variables are assumed to
* provide values of the correct type.
*/
/**
* Copyright (c) 2015, 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.
*/
function isValidLiteralValue(type, valueNode) {
// A value must be provided if the type is non-null.
if (type instanceof _definition.GraphQLNonNull) {
if (!valueNode || valueNode.kind === _kinds.NULL) {
return ['Expected "' + String(type) + '", found null.'];
}
return isValidLiteralValue(type.ofType, valueNode);
}
if (!valueNode || valueNode.kind === _kinds.NULL) {
return [];
}
// This function only tests literals, and assumes variables will provide
// values of the correct type.
if (valueNode.kind === _kinds.VARIABLE) {
return [];
}
// Lists accept a non-list value as a list of one.
if (type instanceof _definition.GraphQLList) {
var _ret = function () {
var itemType = type.ofType;
if (valueNode.kind === _kinds.LIST) {
return {
v: valueNode.values.reduce(function (acc, item, index) {
var errors = isValidLiteralValue(itemType, item);
return acc.concat(errors.map(function (error) {
return 'In element #' + index + ': ' + error;
}));
}, [])
};
}
return {
v: isValidLiteralValue(itemType, valueNode)
};
}();
if (typeof _ret === "object") return _ret.v;
}
// Input objects check each defined field and look for undefined fields.
if (type instanceof _definition.GraphQLInputObjectType) {
var _ret2 = function () {
if (valueNode.kind !== _kinds.OBJECT) {
return {
v: ['Expected "' + type.name + '", found not an object.']
};
}
var fields = type.getFields();
var errors = [];
// Ensure every provided field is defined.
var fieldNodes = valueNode.fields;
fieldNodes.forEach(function (providedFieldNode) {
if (!fields[providedFieldNode.name.value]) {
errors.push('In field "' + providedFieldNode.name.value + '": Unknown field.');
}
});
// Ensure every defined field is valid.
var fieldNodeMap = (0, _keyMap2.default)(fieldNodes, function (fieldNode) {
return fieldNode.name.value;
});
Object.keys(fields).forEach(function (fieldName) {
var result = isValidLiteralValue(fields[fieldName].type, fieldNodeMap[fieldName] && fieldNodeMap[fieldName].value);
errors.push.apply(errors, result.map(function (error) {
return 'In field "' + fieldName + '": ' + error;
}));
});
return {
v: errors
};
}();
if (typeof _ret2 === "object") return _ret2.v;
}
(0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
// Scalar/Enum input checks to ensure the type can parse the value to
// a non-null value.
var parseResult = type.parseLiteral(valueNode);
if ((0, _isNullish2.default)(parseResult)) {
return ['Expected type "' + type.name + '", found ' + (0, _printer.print)(valueNode) + '.'];
}
return [];
}
/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEqualType = isEqualType;
exports.isTypeSubTypeOf = isTypeSubTypeOf;
exports.doTypesOverlap = doTypesOverlap;
var _definition = __webpack_require__(1);
/**
* Provided two types, return true if the types are equal (invariant).
*/
function isEqualType(typeA, typeB) {
// Equivalent types are equal.
if (typeA === typeB) {
return true;
}
// If either type is non-null, the other must also be non-null.
if (typeA instanceof _definition.GraphQLNonNull && typeB instanceof _definition.GraphQLNonNull) {
return isEqualType(typeA.ofType, typeB.ofType);
}
// If either type is a list, the other must also be a list.
if (typeA instanceof _definition.GraphQLList && typeB instanceof _definition.GraphQLList) {
return isEqualType(typeA.ofType, typeB.ofType);
}
// Otherwise the types are not equal.
return false;
}
/**
* Provided a type and a super type, return true if the first type is either
* equal or a subset of the second super type (covariant).
*/
/**
* Copyright (c) 2015, 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.
*/
function isTypeSubTypeOf(schema, maybeSubType, superType) {
// Equivalent type is a valid subtype
if (maybeSubType === superType) {
return true;
}
// If superType is non-null, maybeSubType must also be non-null.
if (superType instanceof _definition.GraphQLNonNull) {
if (maybeSubType instanceof _definition.GraphQLNonNull) {
return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
}
return false;
} else if (maybeSubType instanceof _definition.GraphQLNonNull) {
// If superType is nullable, maybeSubType may be non-null or nullable.
return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);
}
// If superType type is a list, maybeSubType type must also be a list.
if (superType instanceof _definition.GraphQLList) {
if (maybeSubType instanceof _definition.GraphQLList) {
return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
}
return false;
} else if (maybeSubType instanceof _definition.GraphQLList) {
// If superType is not a list, maybeSubType must also be not a list.
return false;
}
// If superType type is an abstract type, maybeSubType type may be a currently
// possible object type.
if ((0, _definition.isAbstractType)(superType) && maybeSubType instanceof _definition.GraphQLObjectType && schema.isPossibleType(superType, maybeSubType)) {
return true;
}
// Otherwise, the child type is not a valid subtype of the parent type.
return false;
}
/**
* Provided two composite types, determine if they "overlap". Two composite
* types overlap when the Sets of possible concrete types for each intersect.
*
* This is often used to determine if a fragment of a given type could possibly
* be visited in a context of another type.
*
* This function is commutative.
*/
function doTypesOverlap(schema, typeA, typeB) {
// So flow is aware this is constant
var _typeB = typeB;
// Equivalent types overlap
if (typeA === _typeB) {
return true;
}
if (typeA instanceof _definition.GraphQLInterfaceType || typeA instanceof _definition.GraphQLUnionType) {
if (_typeB instanceof _definition.GraphQLInterfaceType || _typeB instanceof _definition.GraphQLUnionType) {
// If both types are abstract, then determine if there is any intersection
// between possible concrete types of each.
return schema.getPossibleTypes(typeA).some(function (type) {
return schema.isPossibleType(_typeB, type);
});
}
// Determine if the latter type is a possible concrete type of the former.
return schema.isPossibleType(typeA, _typeB);
}
if (_typeB instanceof _definition.GraphQLInterfaceType || _typeB instanceof _definition.GraphQLUnionType) {
// Determine if the former type is a possible concrete type of the latter.
return schema.isPossibleType(_typeB, typeA);
}
// Otherwise the types do not overlap.
return false;
}
/***/ }),
/* 20 */
/***/ (function(module, exports) {
/**
* Copyright (c) 2016, Lee Byron
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @ignore
*/
/**
* [Iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterator)
* is a *protocol* which describes a standard way to produce a sequence of
* values, typically the values of the Iterable represented by this Iterator.
*
* While described by the [ES2015 version of JavaScript](http://www.ecma-international.org/ecma-262/6.0/#sec-iterator-interface)
* it can be utilized by any version of JavaScript.
*
* @typedef {Object} Iterator
* @template T The type of each iterated value
* @property {function (): { value: T, done: boolean }} next
* A method which produces either the next value in a sequence or a result
* where the `done` property is `true` indicating the end of the Iterator.
*/
/**
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable)
* is a *protocol* which when implemented allows a JavaScript object to define
* their iteration behavior, such as what values are looped over in a `for..of`
* loop or `iterall`'s `forEach` function. Many [built-in types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#Builtin_iterables)
* implement the Iterable protocol, including `Array` and `Map`.
*
* While described by the [ES2015 version of JavaScript](http://www.ecma-international.org/ecma-262/6.0/#sec-iterable-interface)
* it can be utilized by any version of JavaScript.
*
* @typedef {Object} Iterable
* @template T The type of each iterated value
* @property {function (): Iterator} Symbol.iterator
* A method which produces an Iterator for this Iterable.
*/
// In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
var SYMBOL_ITERATOR = typeof Symbol === 'function' && Symbol.iterator
/**
* A property name to be used as the name of an Iterable's method responsible
* for producing an Iterator, referred to as `@@iterator`. Typically represents
* the value `Symbol.iterator` but falls back to the string `"@@iterator"` when
* `Symbol.iterator` is not defined.
*
* Use `$$iterator` for defining new Iterables instead of `Symbol.iterator`,
* but do not use it for accessing existing Iterables, instead use
* `getIterator()` or `isIterable()`.
*
* @example
*
* var $$iterator = require('iterall').$$iterator
*
* function Counter (to) {
* this.to = to
* }
*
* Counter.prototype[$$iterator] = function () {
* return {
* to: this.to,
* num: 0,
* next () {
* if (this.num >= this.to) {
* return { value: undefined, done: true }
* }
* return { value: this.num++, done: false }
* }
* }
* }
*
* var counter = new Counter(3)
* for (var number of counter) {
* console.log(number) // 0 ... 1 ... 2
* }
*
* @type {Symbol|string}
*/
var $$iterator = SYMBOL_ITERATOR || '@@iterator'
exports.$$iterator = $$iterator
/**
* Returns true if the provided object implements the Iterator protocol via
* either implementing a `Symbol.iterator` or `"@@iterator"` method.
*
* @example
*
* var isIterable = require('iterall').isIterable
* isIterable([ 1, 2, 3 ]) // true
* isIterable('ABC') // true
* isIterable({ length: 1, 0: 'Alpha' }) // false
* isIterable({ key: 'value' }) // false
* isIterable(new Map()) // true
*
* @param obj
* A value which might implement the Iterable protocol.
* @return {boolean} true if Iterable.
*/
function isIterable (obj) {
return !!getIteratorMethod(obj)
}
exports.isIterable = isIterable
/**
* Returns true if the provided object implements the Array-like protocol via
* defining a positive-integer `length` property.
*
* @example
*
* var isArrayLike = require('iterall').isArrayLike
* isArrayLike([ 1, 2, 3 ]) // true
* isArrayLike('ABC') // true
* isArrayLike({ length: 1, 0: 'Alpha' }) // true
* isArrayLike({ key: 'value' }) // false
* isArrayLike(new Map()) // false
*
* @param obj
* A value which might implement the Array-like protocol.
* @return {boolean} true if Array-like.
*/
function isArrayLike (obj) {
var length = obj != null && obj.length
return typeof length === 'number' && length >= 0 && length % 1 === 0
}
exports.isArrayLike = isArrayLike
/**
* Returns true if the provided object is an Object (i.e. not a string literal)
* and is either Iterable or Array-like.
*
* This may be used in place of [Array.isArray()][isArray] to determine if an
* object should be iterated-over. It always excludes string literals and
* includes Arrays (regardless of if it is Iterable). It also includes other
* Array-like objects such as NodeList, TypedArray, and Buffer.
*
* @example
*
* var isCollection = require('iterall').isCollection
* isCollection([ 1, 2, 3 ]) // true
* isCollection('ABC') // false
* isCollection({ length: 1, 0: 'Alpha' }) // true
* isCollection({ key: 'value' }) // false
* isCollection(new Map()) // true
*
* @example
*
* var forEach = require('iterall').forEach
* if (isCollection(obj)) {
* forEach(obj, function (value) {
* console.log(value)
* })
* }
*
* @param obj
* An Object value which might implement the Iterable or Array-like protocols.
* @return {boolean} true if Iterable or Array-like Object.
*/
function isCollection (obj) {
return Object(obj) === obj && (isArrayLike(obj) || isIterable(obj))
}
exports.isCollection = isCollection
/**
* If the provided object implements the Iterator protocol, its Iterator object
* is returned. Otherwise returns undefined.
*
* @example
*
* var getIterator = require('iterall').getIterator
* var iterator = getIterator([ 1, 2, 3 ])
* iterator.next() // { value: 1, done: false }
* iterator.next() // { value: 2, done: false }
* iterator.next() // { value: 3, done: false }
* iterator.next() // { value: undefined, done: true }
*
* @template T the type of each iterated value
* @param {Iterable} iterable
* An Iterable object which is the source of an Iterator.
* @return {Iterator} new Iterator instance.
*/
function getIterator (iterable) {
var method = getIteratorMethod(iterable)
if (method) {
return method.call(iterable)
}
}
exports.getIterator = getIterator
/**
* If the provided object implements the Iterator protocol, the method
* responsible for producing its Iterator object is returned.
*
* This is used in rare cases for performance tuning. This method must be called
* with obj as the contextual this-argument.
*
* @example
*
* var getIteratorMethod = require('iterall').getIteratorMethod
* var myArray = [ 1, 2, 3 ]
* var method = getIteratorMethod(myArray)
* if (method) {
* var iterator = method.call(myArray)
* }
*
* @template T the type of each iterated value
* @param {Iterable} iterable
* An Iterable object which defines an `@@iterator` method.
* @return {function(): Iterator} `@@iterator` method.
*/
function getIteratorMethod (iterable) {
if (iterable != null) {
var method = SYMBOL_ITERATOR && iterable[SYMBOL_ITERATOR] || iterable['@@iterator']
if (typeof method === 'function') {
return method
}
}
}
exports.getIteratorMethod = getIteratorMethod
/**
* Given an object which either implements the Iterable protocol or is
* Array-like, iterate over it, calling the `callback` at each iteration.
*
* Use `forEach` where you would expect to use a `for ... of` loop in ES6.
* However `forEach` adheres to the behavior of [Array#forEach][] described in
* the ECMAScript specification, skipping over "holes" in Array-likes. It will
* also delegate to a `forEach` method on `collection` if one is defined,
* ensuring native performance for `Arrays`.
*
* Similar to [Array#forEach][], the `callback` function accepts three
* arguments, and is provided with `thisArg` as the calling context.
*
* Note: providing an infinite Iterator to forEach will produce an error.
*
* [Array#forEach]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
*
* @example
*
* var forEach = require('iterall').forEach
*
* forEach(myIterable, function (value, index, iterable) {
* console.log(value, index, iterable === myIterable)
* })
*
* @example
*
* // ES6:
* for (let value of myIterable) {
* console.log(value)
* }
*
* // Any JavaScript environment:
* forEach(myIterable, function (value) {
* console.log(value)
* })
*
* @template T the type of each iterated value
* @param {Iterable|{ length: number }} collection
* The Iterable or array to iterate over.
* @param {function(T, number, object)} callback
* Function to execute for each iteration, taking up to three arguments
* @param [thisArg]
* Optional. Value to use as `this` when executing `callback`.
*/
function forEach (collection, callback, thisArg) {
if (collection != null) {
if (typeof collection.forEach === 'function') {
return collection.forEach(callback, thisArg)
}
var i = 0
var iterator = getIterator(collection)
if (iterator) {
var step
while (!(step = iterator.next()).done) {
callback.call(thisArg, step.value, i++, collection)
// Infinite Iterators could cause forEach to run forever.
// After a very large number of iterations, produce an error.
/* istanbul ignore if */
if (i > 9999999) {
throw new TypeError('Near-infinite iteration.')
}
}
} else if (isArrayLike(collection)) {
for (; i < collection.length; i++) {
if (collection.hasOwnProperty(i)) {
callback.call(thisArg, collection[i], i, collection)
}
}
}
}
}
exports.forEach = forEach
/**
* Similar to `getIterator()`, this method returns a new Iterator given an
* Iterable. However it will also create an Iterator for a non-Iterable
* Array-like collection, such as Array in a non-ES2015 environment.
*
* `createIterator` is complimentary to `forEach`, but allows a "pull"-based
* iteration as opposed to `forEach`'s "push"-based iteration.
*
* `createIterator` produces an Iterator for Array-likes with the same behavior
* as ArrayIteratorPrototype described in the ECMAScript specification, and
* does *not* skip over "holes".
*
* @example
*
* var createIterator = require('iterall').createIterator
*
* var myArraylike = { length: 3, 0: 'Alpha', 1: 'Bravo', 2: 'Charlie' }
* var iterator = createIterator(myArraylike)
* iterator.next() // { value: 'Alpha', done: false }
* iterator.next() // { value: 'Bravo', done: false }
* iterator.next() // { value: 'Charlie', done: false }
* iterator.next() // { value: undefined, done: true }
*
* @template T the type of each iterated value
* @param {Iterable|{ length: number }} collection
* An Iterable or Array-like object to produce an Iterator.
* @return {Iterator} new Iterator instance.
*/
function createIterator (collection) {
if (collection != null) {
var iterator = getIterator(collection)
if (iterator) {
return iterator
}
if (isArrayLike(collection)) {
return new ArrayLikeIterator(collection)
}
}
}
exports.createIterator = createIterator
// When the object provided to `createIterator` is not Iterable but is
// Array-like, this simple Iterator is created.
function ArrayLikeIterator (obj) {
this._o = obj
this._i = 0
}
// Note: all Iterators are themselves Iterable.
ArrayLikeIterator.prototype[$$iterator] = function () {
return this
}
// A simple state-machine determines the IteratorResult returned, yielding
// each value in the Array-like object in order of their indicies.
ArrayLikeIterator.prototype.next = function () {
if (this._o === void 0 || this._i >= this._o.length) {
this._o = void 0
return { value: void 0, done: true }
}
return { value: this._o[this._i++], done: false }
}
/***/ }),
/* 21 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = keyValMap;
/**
* Copyright (c) 2015, 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.
*/
/**
* Creates a keyed JS object from an array, given a function to produce the keys
* and a function to produce the values from each item in the array.
*
* const phoneBook = [
* { name: 'Jon', num: '555-1234' },
* { name: 'Jenny', num: '867-5309' }
* ]
*
* // { Jon: '555-1234', Jenny: '867-5309' }
* const phonesByName = keyValMap(
* phoneBook,
* entry => entry.name,
* entry => entry.num
* )
*
*/
function keyValMap(list, keyFn, valFn) {
return list.reduce(function (map, item) {
return map[keyFn(item)] = valFn(item), map;
}, {});
}
/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = quotedOrList;
/**
* Copyright (c) 2015, 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.
*/
var MAX_LENGTH = 5;
/**
* Given [ A, B, C ] return '"A", "B", or "C"'.
*/
function quotedOrList(items) {
var selected = items.slice(0, MAX_LENGTH);
return selected.map(function (item) {
return '"' + item + '"';
}).reduce(function (list, quoted, index) {
return list + (selected.length > 2 ? ', ' : ' ') + (index === selected.length - 1 ? 'or ' : '') + quoted;
});
}
/***/ }),
/* 23 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = suggestionList;
/**
* Copyright (c) 2015, 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.
*/
/**
* Given an invalid input string and a list of valid options, returns a filtered
* list of valid options sorted based on their similarity with the input.
*/
function suggestionList(input, options) {
var optionsByDistance = Object.create(null);
var oLength = options.length;
var inputThreshold = input.length / 2;
for (var i = 0; i < oLength; i++) {
var distance = lexicalDistance(input, options[i]);
var threshold = Math.max(inputThreshold, options[i].length / 2, 1);
if (distance <= threshold) {
optionsByDistance[options[i]] = distance;
}
}
return Object.keys(optionsByDistance).sort(function (a, b) {
return optionsByDistance[a] - optionsByDistance[b];
});
}
/**
* Computes the lexical distance between strings A and B.
*
* The "distance" between two strings is given by counting the minimum number
* of edits needed to transform string A into string B. An edit can be an
* insertion, deletion, or substitution of a single character, or a swap of two
* adjacent characters.
*
* This distance can be useful for detecting typos in input or sorting
*
* @param {string} a
* @param {string} b
* @return {int} distance in number of edits
*/
function lexicalDistance(a, b) {
var i = void 0;
var j = void 0;
var d = [];
var aLength = a.length;
var bLength = b.length;
for (i = 0; i <= aLength; i++) {
d[i] = [i];
}
for (j = 1; j <= bLength; j++) {
d[0][j] = j;
}
for (i = 1; i <= aLength; i++) {
for (j = 1; j <= bLength; j++) {
var cost = a[i - 1] === b[j - 1] ? 0 : 1;
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
}
}
}
return d[aLength][bLength];
}
/***/ }),
/* 24 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TokenKind = undefined;
exports.createLexer = createLexer;
exports.getTokenDesc = getTokenDesc;
var _error = __webpack_require__(0);
/**
* Given a Source object, this returns a Lexer for that source.
* A Lexer is a stateful stream generator in that every time
* it is advanced, it returns the next token in the Source. Assuming the
* source lexes, the final Token emitted by the lexer will be of kind
* EOF, after which the lexer will repeatedly return the same EOF token
* whenever called.
*/
function createLexer(source, options) {
var startOfFileToken = new Tok(SOF, 0, 0, 0, 0, null);
var lexer = {
source: source,
options: options,
lastToken: startOfFileToken,
token: startOfFileToken,
line: 1,
lineStart: 0,
advance: advanceLexer
};
return lexer;
} /* /
/**
* Copyright (c) 2015, 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.
*/
function advanceLexer() {
var token = this.lastToken = this.token;
if (token.kind !== EOF) {
do {
token = token.next = readToken(this, token);
} while (token.kind === COMMENT);
this.token = token;
}
return token;
}
/**
* The return type of createLexer.
*/
// Each kind of token.
var SOF = '';
var EOF = '';
var BANG = '!';
var DOLLAR = '$';
var PAREN_L = '(';
var PAREN_R = ')';
var SPREAD = '...';
var COLON = ':';
var EQUALS = '=';
var AT = '@';
var BRACKET_L = '[';
var BRACKET_R = ']';
var BRACE_L = '{';
var PIPE = '|';
var BRACE_R = '}';
var NAME = 'Name';
var INT = 'Int';
var FLOAT = 'Float';
var STRING = 'String';
var COMMENT = 'Comment';
/**
* An exported enum describing the different kinds of tokens that the
* lexer emits.
*/
var TokenKind = exports.TokenKind = {
SOF: SOF,
EOF: EOF,
BANG: BANG,
DOLLAR: DOLLAR,
PAREN_L: PAREN_L,
PAREN_R: PAREN_R,
SPREAD: SPREAD,
COLON: COLON,
EQUALS: EQUALS,
AT: AT,
BRACKET_L: BRACKET_L,
BRACKET_R: BRACKET_R,
BRACE_L: BRACE_L,
PIPE: PIPE,
BRACE_R: BRACE_R,
NAME: NAME,
INT: INT,
FLOAT: FLOAT,
STRING: STRING,
COMMENT: COMMENT
};
/**
* A helper function to describe a token as a string for debugging
*/
function getTokenDesc(token) {
var value = token.value;
return value ? token.kind + ' "' + value + '"' : token.kind;
}
var charCodeAt = String.prototype.charCodeAt;
var slice = String.prototype.slice;
/**
* Helper function for constructing the Token object.
*/
function Tok(kind, start, end, line, column, prev, value) {
this.kind = kind;
this.start = start;
this.end = end;
this.line = line;
this.column = column;
this.value = value;
this.prev = prev;
this.next = null;
}
// Print a simplified form when appearing in JSON/util.inspect.
Tok.prototype.toJSON = Tok.prototype.inspect = function toJSON() {
return {
kind: this.kind,
value: this.value,
line: this.line,
column: this.column
};
};
function printCharCode(code) {
return (
// NaN/undefined represents access beyond the end of the file.
isNaN(code) ? EOF :
// Trust JSON for ASCII.
code < 0x007F ? JSON.stringify(String.fromCharCode(code)) :
// Otherwise print the escaped form.
'"\\u' + ('00' + code.toString(16).toUpperCase()).slice(-4) + '"'
);
}
/**
* Gets the next token from the source starting at the given position.
*
* This skips over whitespace and comments until it finds the next lexable
* token, then lexes punctuators immediately or calls the appropriate helper
* function for more complicated tokens.
*/
function readToken(lexer, prev) {
var source = lexer.source;
var body = source.body;
var bodyLength = body.length;
var position = positionAfterWhitespace(body, prev.end, lexer);
var line = lexer.line;
var col = 1 + position - lexer.lineStart;
if (position >= bodyLength) {
return new Tok(EOF, bodyLength, bodyLength, line, col, prev);
}
var code = charCodeAt.call(body, position);
// SourceCharacter
if (code < 0x0020 && code !== 0x0009 && code !== 0x000A && code !== 0x000D) {
throw (0, _error.syntaxError)(source, position, 'Cannot contain the invalid character ' + printCharCode(code) + '.');
}
switch (code) {
// !
case 33:
return new Tok(BANG, position, position + 1, line, col, prev);
// #
case 35:
return readComment(source, position, line, col, prev);
// $
case 36:
return new Tok(DOLLAR, position, position + 1, line, col, prev);
// (
case 40:
return new Tok(PAREN_L, position, position + 1, line, col, prev);
// )
case 41:
return new Tok(PAREN_R, position, position + 1, line, col, prev);
// .
case 46:
if (charCodeAt.call(body, position + 1) === 46 && charCodeAt.call(body, position + 2) === 46) {
return new Tok(SPREAD, position, position + 3, line, col, prev);
}
break;
// :
case 58:
return new Tok(COLON, position, position + 1, line, col, prev);
// =
case 61:
return new Tok(EQUALS, position, position + 1, line, col, prev);
// @
case 64:
return new Tok(AT, position, position + 1, line, col, prev);
// [
case 91:
return new Tok(BRACKET_L, position, position + 1, line, col, prev);
// ]
case 93:
return new Tok(BRACKET_R, position, position + 1, line, col, prev);
// {
case 123:
return new Tok(BRACE_L, position, position + 1, line, col, prev);
// |
case 124:
return new Tok(PIPE, position, position + 1, line, col, prev);
// }
case 125:
return new Tok(BRACE_R, position, position + 1, line, col, prev);
// A-Z _ a-z
case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:
case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:
case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:
case 89:case 90:
case 95:
case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:
case 105:case 106:case 107:case 108:case 109:case 110:case 111:
case 112:case 113:case 114:case 115:case 116:case 117:case 118:
case 119:case 120:case 121:case 122:
return readName(source, position, line, col, prev);
// - 0-9
case 45:
case 48:case 49:case 50:case 51:case 52:
case 53:case 54:case 55:case 56:case 57:
return readNumber(source, position, code, line, col, prev);
// "
case 34:
return readString(source, position, line, col, prev);
}
throw (0, _error.syntaxError)(source, position, unexpectedCharacterMessage(code));
}
/**
* Report a message that an unexpected character was encountered.
*/
function unexpectedCharacterMessage(code) {
if (code === 39) {
// '
return 'Unexpected single quote character (\'), did you mean to use ' + 'a double quote (")?';
}
return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';
}
/**
* Reads from body starting at startPosition until it finds a non-whitespace
* or commented character, then returns the position of that character for
* lexing.
*/
function positionAfterWhitespace(body, startPosition, lexer) {
var bodyLength = body.length;
var position = startPosition;
while (position < bodyLength) {
var code = charCodeAt.call(body, position);
// tab | space | comma | BOM
if (code === 9 || code === 32 || code === 44 || code === 0xFEFF) {
++position;
} else if (code === 10) {
// new line
++position;
++lexer.line;
lexer.lineStart = position;
} else if (code === 13) {
// carriage return
if (charCodeAt.call(body, position + 1) === 10) {
position += 2;
} else {
++position;
}
++lexer.line;
lexer.lineStart = position;
} else {
break;
}
}
return position;
}
/**
* Reads a comment token from the source file.
*
* #[\u0009\u0020-\uFFFF]*
*/
function readComment(source, start, line, col, prev) {
var body = source.body;
var code = void 0;
var position = start;
do {
code = charCodeAt.call(body, ++position);
} while (code !== null && (
// SourceCharacter but not LineTerminator
code > 0x001F || code === 0x0009));
return new Tok(COMMENT, start, position, line, col, prev, slice.call(body, start + 1, position));
}
/**
* Reads a number token from the source file, either a float
* or an int depending on whether a decimal point appears.
*
* Int: -?(0|[1-9][0-9]*)
* Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
*/
function readNumber(source, start, firstCode, line, col, prev) {
var body = source.body;
var code = firstCode;
var position = start;
var isFloat = false;
if (code === 45) {
// -
code = charCodeAt.call(body, ++position);
}
if (code === 48) {
// 0
code = charCodeAt.call(body, ++position);
if (code >= 48 && code <= 57) {
throw (0, _error.syntaxError)(source, position, 'Invalid number, unexpected digit after 0: ' + printCharCode(code) + '.');
}
} else {
position = readDigits(source, position, code);
code = charCodeAt.call(body, position);
}
if (code === 46) {
// .
isFloat = true;
code = charCodeAt.call(body, ++position);
position = readDigits(source, position, code);
code = charCodeAt.call(body, position);
}
if (code === 69 || code === 101) {
// E e
isFloat = true;
code = charCodeAt.call(body, ++position);
if (code === 43 || code === 45) {
// + -
code = charCodeAt.call(body, ++position);
}
position = readDigits(source, position, code);
}
return new Tok(isFloat ? FLOAT : INT, start, position, line, col, prev, slice.call(body, start, position));
}
/**
* Returns the new position in the source after reading digits.
*/
function readDigits(source, start, firstCode) {
var body = source.body;
var position = start;
var code = firstCode;
if (code >= 48 && code <= 57) {
// 0 - 9
do {
code = charCodeAt.call(body, ++position);
} while (code >= 48 && code <= 57); // 0 - 9
return position;
}
throw (0, _error.syntaxError)(source, position, 'Invalid number, expected digit but got: ' + printCharCode(code) + '.');
}
/**
* Reads a string token from the source file.
*
* "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
*/
function readString(source, start, line, col, prev) {
var body = source.body;
var position = start + 1;
var chunkStart = position;
var code = 0;
var value = '';
while (position < body.length && (code = charCodeAt.call(body, position)) !== null &&
// not LineTerminator
code !== 0x000A && code !== 0x000D &&
// not Quote (")
code !== 34) {
// SourceCharacter
if (code < 0x0020 && code !== 0x0009) {
throw (0, _error.syntaxError)(source, position, 'Invalid character within String: ' + printCharCode(code) + '.');
}
++position;
if (code === 92) {
// \
value += slice.call(body, chunkStart, position - 1);
code = charCodeAt.call(body, position);
switch (code) {
case 34:
value += '"';break;
case 47:
value += '/';break;
case 92:
value += '\\';break;
case 98:
value += '\b';break;
case 102:
value += '\f';break;
case 110:
value += '\n';break;
case 114:
value += '\r';break;
case 116:
value += '\t';break;
case 117:
// u
var charCode = uniCharCode(charCodeAt.call(body, position + 1), charCodeAt.call(body, position + 2), charCodeAt.call(body, position + 3), charCodeAt.call(body, position + 4));
if (charCode < 0) {
throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: ' + ('\\u' + body.slice(position + 1, position + 5) + '.'));
}
value += String.fromCharCode(charCode);
position += 4;
break;
default:
throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: \\' + String.fromCharCode(code) + '.');
}
++position;
chunkStart = position;
}
}
if (code !== 34) {
// quote (")
throw (0, _error.syntaxError)(source, position, 'Unterminated string.');
}
value += slice.call(body, chunkStart, position);
return new Tok(STRING, start, position + 1, line, col, prev, value);
}
/**
* Converts four hexidecimal chars to the integer that the
* string represents. For example, uniCharCode('0','0','0','f')
* will return 15, and uniCharCode('0','0','f','f') returns 255.
*
* Returns a negative number on error, if a char was invalid.
*
* This is implemented by noting that char2hex() returns -1 on error,
* which means the result of ORing the char2hex() will also be negative.
*/
function uniCharCode(a, b, c, d) {
return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);
}
/**
* Converts a hex character to its integer value.
* '0' becomes 0, '9' becomes 9
* 'A' becomes 10, 'F' becomes 15
* 'a' becomes 10, 'f' becomes 15
*
* Returns -1 on error.
*/
function char2hex(a) {
return a >= 48 && a <= 57 ? a - 48 : // 0-9
a >= 65 && a <= 70 ? a - 55 : // A-F
a >= 97 && a <= 102 ? a - 87 : // a-f
-1;
}
/**
* Reads an alphanumeric + underscore name from the source.
*
* [_A-Za-z][_0-9A-Za-z]*
*/
function readName(source, position, line, col, prev) {
var body = source.body;
var bodyLength = body.length;
var end = position + 1;
var code = 0;
while (end !== bodyLength && (code = charCodeAt.call(body, end)) !== null && (code === 95 || // _
code >= 48 && code <= 57 || // 0-9
code >= 65 && code <= 90 || // A-Z
code >= 97 && code <= 122 // a-z
)) {
++end;
}
return new Tok(NAME, position, end, line, col, prev, slice.call(body, position, end));
}
/***/ }),
/* 25 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getLocation = getLocation;
/**
* Takes a Source and a UTF-8 character offset, and returns the corresponding
* line and column as a SourceLocation.
*/
/**
* Copyright (c) 2015, 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.
*/
function getLocation(source, position) {
var lineRegexp = /\r\n|[\n\r]/g;
var line = 1;
var column = position + 1;
var match = void 0;
while ((match = lineRegexp.exec(source.body)) && match.index < position) {
line += 1;
column = position + 1 - (match.index + match[0].length);
}
return { line: line, column: column };
}
/**
* Represents a location in a Source.
*/
/***/ }),
/* 26 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2015, 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.
*/
/**
* A representation of source input to GraphQL. The name is optional,
* but is mostly useful for clients who store GraphQL documents in
* source files; for example, if the GraphQL input is in a file Foo.graphql,
* it might be useful for name to be "Foo.graphql".
*/
var Source = exports.Source = function Source(body, name) {
_classCallCheck(this, Source);
this.body = body;
this.name = name || 'GraphQL';
};
/***/ }),
/* 27 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TypeInfo = undefined;
var _kinds = __webpack_require__(2);
var Kind = _interopRequireWildcard(_kinds);
var _definition = __webpack_require__(1);
var _introspection = __webpack_require__(11);
var _typeFromAST = __webpack_require__(9);
var _find = __webpack_require__(10);
var _find2 = _interopRequireDefault(_find);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2015, 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.
*/
/**
* TypeInfo is a utility class which, given a GraphQL schema, can keep track
* of the current field and type definitions at any point in a GraphQL document
* AST during a recursive descent by calling `enter(node)` and `leave(node)`.
*/
var TypeInfo = exports.TypeInfo = function () {
function TypeInfo(schema,
// NOTE: this experimental optional second parameter is only needed in order
// to support non-spec-compliant codebases. You should never need to use it.
getFieldDefFn) {
_classCallCheck(this, TypeInfo);
this._schema = schema;
this._typeStack = [];
this._parentTypeStack = [];
this._inputTypeStack = [];
this._fieldDefStack = [];
this._directive = null;
this._argument = null;
this._enumValue = null;
this._getFieldDef = getFieldDefFn || getFieldDef;
}
TypeInfo.prototype.getType = function getType() {
if (this._typeStack.length > 0) {
return this._typeStack[this._typeStack.length - 1];
}
};
TypeInfo.prototype.getParentType = function getParentType() {
if (this._parentTypeStack.length > 0) {
return this._parentTypeStack[this._parentTypeStack.length - 1];
}
};
TypeInfo.prototype.getInputType = function getInputType() {
if (this._inputTypeStack.length > 0) {
return this._inputTypeStack[this._inputTypeStack.length - 1];
}
};
TypeInfo.prototype.getFieldDef = function getFieldDef() {
if (this._fieldDefStack.length > 0) {
return this._fieldDefStack[this._fieldDefStack.length - 1];
}
};
TypeInfo.prototype.getDirective = function getDirective() {
return this._directive;
};
TypeInfo.prototype.getArgument = function getArgument() {
return this._argument;
};
TypeInfo.prototype.getEnumValue = function getEnumValue() {
return this._enumValue;
};
// Flow does not yet handle this case.
TypeInfo.prototype.enter = function enter(node /* ASTNode */) {
var schema = this._schema;
switch (node.kind) {
case Kind.SELECTION_SET:
var namedType = (0, _definition.getNamedType)(this.getType());
var compositeType = void 0;
if ((0, _definition.isCompositeType)(namedType)) {
// isCompositeType is a type refining predicate, so this is safe.
compositeType = namedType;
}
this._parentTypeStack.push(compositeType);
break;
case Kind.FIELD:
var parentType = this.getParentType();
var fieldDef = void 0;
if (parentType) {
fieldDef = this._getFieldDef(schema, parentType, node);
}
this._fieldDefStack.push(fieldDef);
this._typeStack.push(fieldDef && fieldDef.type);
break;
case Kind.DIRECTIVE:
this._directive = schema.getDirective(node.name.value);
break;
case Kind.OPERATION_DEFINITION:
var type = void 0;
if (node.operation === 'query') {
type = schema.getQueryType();
} else if (node.operation === 'mutation') {
type = schema.getMutationType();
} else if (node.operation === 'subscription') {
type = schema.getSubscriptionType();
}
this._typeStack.push(type);
break;
case Kind.INLINE_FRAGMENT:
case Kind.FRAGMENT_DEFINITION:
var typeConditionAST = node.typeCondition;
var outputType = typeConditionAST ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) : this.getType();
this._typeStack.push(outputType);
break;
case Kind.VARIABLE_DEFINITION:
var inputType = (0, _typeFromAST.typeFromAST)(schema, node.type);
this._inputTypeStack.push(inputType);
break;
case Kind.ARGUMENT:
var argDef = void 0;
var argType = void 0;
var fieldOrDirective = this.getDirective() || this.getFieldDef();
if (fieldOrDirective) {
argDef = (0, _find2.default)(fieldOrDirective.args, function (arg) {
return arg.name === node.name.value;
});
if (argDef) {
argType = argDef.type;
}
}
this._argument = argDef;
this._inputTypeStack.push(argType);
break;
case Kind.LIST:
var listType = (0, _definition.getNullableType)(this.getInputType());
this._inputTypeStack.push(listType instanceof _definition.GraphQLList ? listType.ofType : undefined);
break;
case Kind.OBJECT_FIELD:
var objectType = (0, _definition.getNamedType)(this.getInputType());
var fieldType = void 0;
if (objectType instanceof _definition.GraphQLInputObjectType) {
var inputField = objectType.getFields()[node.name.value];
fieldType = inputField ? inputField.type : undefined;
}
this._inputTypeStack.push(fieldType);
break;
case Kind.ENUM:
var enumType = (0, _definition.getNamedType)(this.getInputType());
var enumValue = void 0;
if (enumType instanceof _definition.GraphQLEnumType) {
enumValue = enumType.getValue(node.value);
}
this._enumValue = enumValue;
break;
}
};
TypeInfo.prototype.leave = function leave(node) {
switch (node.kind) {
case Kind.SELECTION_SET:
this._parentTypeStack.pop();
break;
case Kind.FIELD:
this._fieldDefStack.pop();
this._typeStack.pop();
break;
case Kind.DIRECTIVE:
this._directive = null;
break;
case Kind.OPERATION_DEFINITION:
case Kind.INLINE_FRAGMENT:
case Kind.FRAGMENT_DEFINITION:
this._typeStack.pop();
break;
case Kind.VARIABLE_DEFINITION:
this._inputTypeStack.pop();
break;
case Kind.ARGUMENT:
this._argument = null;
this._inputTypeStack.pop();
break;
case Kind.LIST:
case Kind.OBJECT_FIELD:
this._inputTypeStack.pop();
break;
case Kind.ENUM:
this._enumValue = null;
break;
}
};
return TypeInfo;
}();
/**
* Not exactly the same as the executor's definition of getFieldDef, in this
* statically evaluated environment we do not always have an Object type,
* and need to handle Interface and Union types.
*/
function getFieldDef(schema, parentType, fieldNode) {
var name = fieldNode.name.value;
if (name === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
return _introspection.SchemaMetaFieldDef;
}
if (name === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
return _introspection.TypeMetaFieldDef;
}
if (name === _introspection.TypeNameMetaFieldDef.name && (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType || parentType instanceof _definition.GraphQLUnionType)) {
return _introspection.TypeNameMetaFieldDef;
}
if (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType) {
return parentType.getFields()[name];
}
}
/***/ }),
/* 28 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.assertValidName = assertValidName;
/**
* Copyright (c) 2015, 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.
*/
var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
// Ensures console warnings are only issued once.
var hasWarnedAboutDunder = false;
/**
* Upholds the spec rules about naming.
*/
function assertValidName(name, isIntrospection) {
if (!name || typeof name !== 'string') {
throw new Error('Must be named. Unexpected name: ' + name + '.');
}
if (!isIntrospection && name.slice(0, 2) === '__' && !hasWarnedAboutDunder) {
hasWarnedAboutDunder = true;
/* eslint-disable no-console */
if (console && console.error) {
var error = new Error('Name "' + name + '" must not begin with "__", which is reserved by ' + 'GraphQL introspection.');
console.error(error.stack || String(error));
}
/* eslint-enable no-console */
}
if (!NAME_RX.test(name)) {
throw new Error('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "' + name + '" does not.');
}
}
/***/ }),
/* 29 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.astFromValue = astFromValue;
var _iterall = __webpack_require__(20);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _isNullish = __webpack_require__(6);
var _isNullish2 = _interopRequireDefault(_isNullish);
var _isInvalid = __webpack_require__(14);
var _isInvalid2 = _interopRequireDefault(_isInvalid);
var _kinds = __webpack_require__(2);
var _definition = __webpack_require__(1);
var _scalars = __webpack_require__(7);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Produces a GraphQL Value AST given a JavaScript value.
*
* A GraphQL type must be provided, which will be used to interpret different
* JavaScript values.
*
* | JSON Value | GraphQL Value |
* | ------------- | -------------------- |
* | Object | Input Object |
* | Array | List |
* | Boolean | Boolean |
* | String | String / Enum Value |
* | Number | Int / Float |
* | Mixed | Enum Value |
* | null | NullValue |
*
*/
function astFromValue(value, type) {
// Ensure flow knows that we treat function params as const.
var _value = value;
if (type instanceof _definition.GraphQLNonNull) {
var astValue = astFromValue(_value, type.ofType);
if (astValue && astValue.kind === _kinds.NULL) {
return null;
}
return astValue;
}
// only explicit null, not undefined, NaN
if (_value === null) {
return { kind: _kinds.NULL };
}
// undefined, NaN
if ((0, _isInvalid2.default)(_value)) {
return null;
}
// Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but
// the value is not an array, convert the value using the list's item type.
if (type instanceof _definition.GraphQLList) {
var _ret = function () {
var itemType = type.ofType;
if ((0, _iterall.isCollection)(_value)) {
var _ret2 = function () {
var valuesNodes = [];
(0, _iterall.forEach)(_value, function (item) {
var itemNode = astFromValue(item, itemType);
if (itemNode) {
valuesNodes.push(itemNode);
}
});
return {
v: {
v: { kind: _kinds.LIST, values: valuesNodes }
}
};
}();
if (typeof _ret2 === "object") return _ret2.v;
}
return {
v: astFromValue(_value, itemType)
};
}();
if (typeof _ret === "object") return _ret.v;
}
// Populate the fields of the input object by creating ASTs from each value
// in the JavaScript object according to the fields in the input type.
if (type instanceof _definition.GraphQLInputObjectType) {
var _ret3 = function () {
if (_value === null || typeof _value !== 'object') {
return {
v: null
};
}
var fields = type.getFields();
var fieldNodes = [];
Object.keys(fields).forEach(function (fieldName) {
var fieldType = fields[fieldName].type;
var fieldValue = astFromValue(_value[fieldName], fieldType);
if (fieldValue) {
fieldNodes.push({
kind: _kinds.OBJECT_FIELD,
name: { kind: _kinds.NAME, value: fieldName },
value: fieldValue
});
}
});
return {
v: { kind: _kinds.OBJECT, fields: fieldNodes }
};
}();
if (typeof _ret3 === "object") return _ret3.v;
}
(0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must provide Input Type, cannot use: ' + String(type));
// Since value is an internally represented value, it must be serialized
// to an externally represented value before converting into an AST.
var serialized = type.serialize(_value);
if ((0, _isNullish2.default)(serialized)) {
return null;
}
// Others serialize based on their corresponding JavaScript scalar types.
if (typeof serialized === 'boolean') {
return { kind: _kinds.BOOLEAN, value: serialized };
}
// JavaScript numbers can be Int or Float values.
if (typeof serialized === 'number') {
var stringNum = String(serialized);
return (/^[0-9]+$/.test(stringNum) ? { kind: _kinds.INT, value: stringNum } : { kind: _kinds.FLOAT, value: stringNum }
);
}
if (typeof serialized === 'string') {
// Enum types use Enum literals.
if (type instanceof _definition.GraphQLEnumType) {
return { kind: _kinds.ENUM, value: serialized };
}
// ID types can use Int literals.
if (type === _scalars.GraphQLID && /^[0-9]+$/.test(serialized)) {
return { kind: _kinds.INT, value: serialized };
}
// Use JSON stringify, which uses the same string encoding as GraphQL,
// then remove the quotes.
return {
kind: _kinds.STRING,
value: JSON.stringify(serialized).slice(1, -1)
};
}
throw new TypeError('Cannot convert value to AST: ' + String(serialized));
}
/**
* Copyright (c) 2015, 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.
*/
/***/ }),
/* 30 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defaultFieldResolver = undefined;
exports.execute = execute;
exports.responsePathAsArray = responsePathAsArray;
var _iterall = __webpack_require__(20);
var _error = __webpack_require__(0);
var _find = __webpack_require__(10);
var _find2 = _interopRequireDefault(_find);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _isNullish = __webpack_require__(6);
var _isNullish2 = _interopRequireDefault(_isNullish);
var _typeFromAST = __webpack_require__(9);
var _kinds = __webpack_require__(2);
var Kind = _interopRequireWildcard(_kinds);
var _values = __webpack_require__(31);
var _definition = __webpack_require__(1);
var _schema = __webpack_require__(8);
var _introspection = __webpack_require__(11);
var _directives = __webpack_require__(5);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Implements the "Evaluating requests" section of the GraphQL specification.
*
* Returns a Promise that will eventually be resolved and never rejected.
*
* If the arguments to this function do not result in a legal execution context,
* a GraphQLError will be thrown immediately explaining the invalid input.
*/
/**
* Terminology
*
* "Definitions" are the generic name for top-level statements in the document.
* Examples of this include:
* 1) Operations (such as a query)
* 2) Fragments
*
* "Operations" are a generic name for requests in the document.
* Examples of this include:
* 1) query,
* 2) mutation
*
* "Selections" are the definitions that can appear legally and at
* single level of the query. These include:
* 1) field references e.g "a"
* 2) fragment "spreads" e.g. "...c"
* 3) inline fragment "spreads" e.g. "...on Type { a }"
*/
/**
* Data that must be available at all points during query execution.
*
* Namely, schema of the type system that is currently executing,
* and the fragments defined in the query document
*/
/**
* The result of GraphQL execution.
*
* - `data` is the result of a successful execution of the query.
* - `errors` is included when any errors occurred as a non-empty array.
*/
/**
* Copyright (c) 2015, 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.
*/
function execute(schema, document, rootValue, contextValue, variableValues, operationName) {
(0, _invariant2.default)(schema, 'Must provide schema');
(0, _invariant2.default)(document, 'Must provide document');
(0, _invariant2.default)(schema instanceof _schema.GraphQLSchema, 'Schema must be an instance of GraphQLSchema. Also ensure that there are ' + 'not multiple versions of GraphQL installed in your node_modules directory.');
// Variables, if provided, must be an object.
(0, _invariant2.default)(!variableValues || typeof variableValues === 'object', 'Variables must be provided as an Object where each property is a ' + 'variable value. Perhaps look to see if an unparsed JSON string ' + 'was provided.');
// If a valid context cannot be created due to incorrect arguments,
// this will throw an error.
var context = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName);
// Return a Promise that will eventually resolve to the data described by
// The "Response" section of the GraphQL specification.
//
// If errors are encountered while executing a GraphQL field, only that
// field and its descendants will be omitted, and sibling fields will still
// be executed. An execution which encounters errors will still result in a
// resolved Promise.
return new Promise(function (resolve) {
resolve(executeOperation(context, context.operation, rootValue));
}).then(undefined, function (error) {
// Errors from sub-fields of a NonNull type may propagate to the top level,
// at which point we still log the error and null the parent field, which
// in this case is the entire response.
context.errors.push(error);
return null;
}).then(function (data) {
if (!context.errors.length) {
return { data: data };
}
return { data: data, errors: context.errors };
});
}
/**
* Given a ResponsePath (found in the `path` entry in the information provided
* as the last argument to a field resolver), return an Array of the path keys.
*/
function responsePathAsArray(path) {
var flattened = [];
var curr = path;
while (curr) {
flattened.push(curr.key);
curr = curr.prev;
}
return flattened.reverse();
}
function addPath(prev, key) {
return { prev: prev, key: key };
}
/**
* Constructs a ExecutionContext object from the arguments passed to
* execute, which we will pass throughout the other execution methods.
*
* Throws a GraphQLError if a valid execution context cannot be created.
*/
function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName) {
var errors = [];
var operation = void 0;
var fragments = Object.create(null);
document.definitions.forEach(function (definition) {
switch (definition.kind) {
case Kind.OPERATION_DEFINITION:
if (!operationName && operation) {
throw new _error.GraphQLError('Must provide operation name if query contains multiple operations.');
}
if (!operationName || definition.name && definition.name.value === operationName) {
operation = definition;
}
break;
case Kind.FRAGMENT_DEFINITION:
fragments[definition.name.value] = definition;
break;
default:
throw new _error.GraphQLError('GraphQL cannot execute a request containing a ' + definition.kind + '.', [definition]);
}
});
if (!operation) {
if (operationName) {
throw new _error.GraphQLError('Unknown operation named "' + operationName + '".');
} else {
throw new _error.GraphQLError('Must provide an operation.');
}
}
var variableValues = (0, _values.getVariableValues)(schema, operation.variableDefinitions || [], rawVariableValues || {});
return {
schema: schema,
fragments: fragments,
rootValue: rootValue,
contextValue: contextValue,
operation: operation,
variableValues: variableValues,
errors: errors
};
}
/**
* Implements the "Evaluating operations" section of the spec.
*/
function executeOperation(exeContext, operation, rootValue) {
var type = getOperationRootType(exeContext.schema, operation);
var fields = collectFields(exeContext, type, operation.selectionSet, Object.create(null), Object.create(null));
var path = undefined;
if (operation.operation === 'mutation') {
return executeFieldsSerially(exeContext, type, rootValue, path, fields);
}
return executeFields(exeContext, type, rootValue, path, fields);
}
/**
* Extracts the root type of the operation from the schema.
*/
function getOperationRootType(schema, operation) {
switch (operation.operation) {
case 'query':
return schema.getQueryType();
case 'mutation':
var mutationType = schema.getMutationType();
if (!mutationType) {
throw new _error.GraphQLError('Schema is not configured for mutations', [operation]);
}
return mutationType;
case 'subscription':
var subscriptionType = schema.getSubscriptionType();
if (!subscriptionType) {
throw new _error.GraphQLError('Schema is not configured for subscriptions', [operation]);
}
return subscriptionType;
default:
throw new _error.GraphQLError('Can only execute queries, mutations and subscriptions', [operation]);
}
}
/**
* Implements the "Evaluating selection sets" section of the spec
* for "write" mode.
*/
function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) {
return Object.keys(fields).reduce(function (prevPromise, responseName) {
return prevPromise.then(function (results) {
var fieldNodes = fields[responseName];
var fieldPath = addPath(path, responseName);
var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
if (result === undefined) {
return results;
}
if (isThenable(result)) {
return result.then(function (resolvedResult) {
results[responseName] = resolvedResult;
return results;
});
}
results[responseName] = result;
return results;
});
}, Promise.resolve({}));
}
/**
* Implements the "Evaluating selection sets" section of the spec
* for "read" mode.
*/
function executeFields(exeContext, parentType, sourceValue, path, fields) {
var containsPromise = false;
var finalResults = Object.keys(fields).reduce(function (results, responseName) {
var fieldNodes = fields[responseName];
var fieldPath = addPath(path, responseName);
var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
if (result === undefined) {
return results;
}
results[responseName] = result;
if (isThenable(result)) {
containsPromise = true;
}
return results;
}, Object.create(null));
// If there are no promises, we can just return the object
if (!containsPromise) {
return finalResults;
}
// Otherwise, results is a map from field name to the result
// of resolving that field, which is possibly a promise. Return
// a promise that will return this same map, but with any
// promises replaced with the values they resolved to.
return promiseForObject(finalResults);
}
/**
* Given a selectionSet, adds all of the fields in that selection to
* the passed in map of fields, and returns it at the end.
*
* CollectFields requires the "runtime type" of an object. For a field which
* returns and Interface or Union type, the "runtime type" will be the actual
* Object type returned by that field.
*/
function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
for (var i = 0; i < selectionSet.selections.length; i++) {
var selection = selectionSet.selections[i];
switch (selection.kind) {
case Kind.FIELD:
if (!shouldIncludeNode(exeContext, selection.directives)) {
continue;
}
var _name = getFieldEntryKey(selection);
if (!fields[_name]) {
fields[_name] = [];
}
fields[_name].push(selection);
break;
case Kind.INLINE_FRAGMENT:
if (!shouldIncludeNode(exeContext, selection.directives) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
continue;
}
collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
break;
case Kind.FRAGMENT_SPREAD:
var fragName = selection.name.value;
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection.directives)) {
continue;
}
visitedFragmentNames[fragName] = true;
var fragment = exeContext.fragments[fragName];
if (!fragment || !doesFragmentConditionMatch(exeContext, fragment, runtimeType)) {
continue;
}
collectFields(exeContext, runtimeType, fragment.selectionSet, fields, visitedFragmentNames);
break;
}
}
return fields;
}
/**
* Determines if a field should be included based on the @include and @skip
* directives, where @skip has higher precidence than @include.
*/
function shouldIncludeNode(exeContext, directives) {
var skipNode = directives && (0, _find2.default)(directives, function (directive) {
return directive.name.value === _directives.GraphQLSkipDirective.name;
});
if (skipNode) {
var _getArgumentValues = (0, _values.getArgumentValues)(_directives.GraphQLSkipDirective, skipNode, exeContext.variableValues),
skipIf = _getArgumentValues.if;
if (skipIf === true) {
return false;
}
}
var includeNode = directives && (0, _find2.default)(directives, function (directive) {
return directive.name.value === _directives.GraphQLIncludeDirective.name;
});
if (includeNode) {
var _getArgumentValues2 = (0, _values.getArgumentValues)(_directives.GraphQLIncludeDirective, includeNode, exeContext.variableValues),
includeIf = _getArgumentValues2.if;
if (includeIf === false) {
return false;
}
}
return true;
}
/**
* Determines if a fragment is applicable to the given type.
*/
function doesFragmentConditionMatch(exeContext, fragment, type) {
var typeConditionNode = fragment.typeCondition;
if (!typeConditionNode) {
return true;
}
var conditionalType = (0, _typeFromAST.typeFromAST)(exeContext.schema, typeConditionNode);
if (conditionalType === type) {
return true;
}
if ((0, _definition.isAbstractType)(conditionalType)) {
var abstractType = conditionalType;
return exeContext.schema.isPossibleType(abstractType, type);
}
return false;
}
/**
* This function transforms a JS object `{[key: string]: Promise}` into
* a `Promise<{[key: string]: T}>`
*
* This is akin to bluebird's `Promise.props`, but implemented only using
* `Promise.all` so it will work with any implementation of ES6 promises.
*/
function promiseForObject(object) {
var keys = Object.keys(object);
var valuesAndPromises = keys.map(function (name) {
return object[name];
});
return Promise.all(valuesAndPromises).then(function (values) {
return values.reduce(function (resolvedObject, value, i) {
resolvedObject[keys[i]] = value;
return resolvedObject;
}, Object.create(null));
});
}
/**
* Implements the logic to compute the key of a given field's entry
*/
function getFieldEntryKey(node) {
return node.alias ? node.alias.value : node.name.value;
}
/**
* Resolves the field on the given source object. In particular, this
* figures out the value that the field returns by calling its resolve function,
* then calls completeValue to complete promises, serialize scalars, or execute
* the sub-selection-set for objects.
*/
function resolveField(exeContext, parentType, source, fieldNodes, path) {
var fieldNode = fieldNodes[0];
var fieldName = fieldNode.name.value;
var fieldDef = getFieldDef(exeContext.schema, parentType, fieldName);
if (!fieldDef) {
return;
}
var returnType = fieldDef.type;
var resolveFn = fieldDef.resolve || defaultFieldResolver;
// The resolve function's optional third argument is a context value that
// is provided to every resolve function within an execution. It is commonly
// used to represent an authenticated user, or request-specific caches.
var context = exeContext.contextValue;
// The resolve function's optional fourth argument is a collection of
// information about the current execution state.
var info = {
fieldName: fieldName,
fieldNodes: fieldNodes,
returnType: returnType,
parentType: parentType,
path: path,
schema: exeContext.schema,
fragments: exeContext.fragments,
rootValue: exeContext.rootValue,
operation: exeContext.operation,
variableValues: exeContext.variableValues
};
// Get the resolve function, regardless of if its result is normal
// or abrupt (error).
var result = resolveOrError(exeContext, fieldDef, fieldNode, resolveFn, source, context, info);
return completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result);
}
// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
// function. Returns the result of resolveFn or the abrupt-return Error object.
function resolveOrError(exeContext, fieldDef, fieldNode, resolveFn, source, context, info) {
try {
// Build a JS object of arguments from the field.arguments AST, using the
// variables scope to fulfill any variable references.
// TODO: find a way to memoize, in case this field is within a List type.
var args = (0, _values.getArgumentValues)(fieldDef, fieldNode, exeContext.variableValues);
return resolveFn(source, args, context, info);
} catch (error) {
// Sometimes a non-error is thrown, wrap it as an Error for a
// consistent interface.
return error instanceof Error ? error : new Error(error);
}
}
// This is a small wrapper around completeValue which detects and logs errors
// in the execution context.
function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
// If the field type is non-nullable, then it is resolved without any
// protection from errors, however it still properly locates the error.
if (returnType instanceof _definition.GraphQLNonNull) {
return completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result);
}
// Otherwise, error protection is applied, logging the error and resolving
// a null value for this field if one is encountered.
try {
var completed = completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result);
if (isThenable(completed)) {
// If `completeValueWithLocatedError` returned a rejected promise, log
// the rejection error and resolve to null.
// Note: we don't rely on a `catch` method, but we do expect "thenable"
// to take a second callback for the error case.
return completed.then(undefined, function (error) {
exeContext.errors.push(error);
return Promise.resolve(null);
});
}
return completed;
} catch (error) {
// If `completeValueWithLocatedError` returned abruptly (threw an error),
// log the error and return null.
exeContext.errors.push(error);
return null;
}
}
// This is a small wrapper around completeValue which annotates errors with
// location information.
function completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result) {
try {
var completed = completeValue(exeContext, returnType, fieldNodes, info, path, result);
if (isThenable(completed)) {
return completed.then(undefined, function (error) {
return Promise.reject((0, _error.locatedError)(error, fieldNodes, responsePathAsArray(path)));
});
}
return completed;
} catch (error) {
throw (0, _error.locatedError)(error, fieldNodes, responsePathAsArray(path));
}
}
/**
* Implements the instructions for completeValue as defined in the
* "Field entries" section of the spec.
*
* If the field type is Non-Null, then this recursively completes the value
* for the inner type. It throws a field error if that completion returns null,
* as per the "Nullability" section of the spec.
*
* If the field type is a List, then this recursively completes the value
* for the inner type on each item in the list.
*
* If the field type is a Scalar or Enum, ensures the completed value is a legal
* value of the type by calling the `serialize` method of GraphQL type
* definition.
*
* If the field is an abstract type, determine the runtime type of the value
* and then complete based on that type
*
* Otherwise, the field type expects a sub-selection set, and will complete the
* value by evaluating all sub-selections.
*/
function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
// If result is a Promise, apply-lift over completeValue.
if (isThenable(result)) {
return result.then(function (resolved) {
return completeValue(exeContext, returnType, fieldNodes, info, path, resolved);
});
}
// If result is an Error, throw a located error.
if (result instanceof Error) {
throw result;
}
// If field type is NonNull, complete for inner type, and throw field error
// if result is null.
if (returnType instanceof _definition.GraphQLNonNull) {
var completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path, result);
if (completed === null) {
throw new Error('Cannot return null for non-nullable field ' + info.parentType.name + '.' + info.fieldName + '.');
}
return completed;
}
// If result value is null-ish (null, undefined, or NaN) then return null.
if ((0, _isNullish2.default)(result)) {
return null;
}
// If field type is List, complete each item in the list with the inner type
if (returnType instanceof _definition.GraphQLList) {
return completeListValue(exeContext, returnType, fieldNodes, info, path, result);
}
// If field type is a leaf type, Scalar or Enum, serialize to a valid value,
// returning null if serialization is not possible.
if (returnType instanceof _definition.GraphQLScalarType || returnType instanceof _definition.GraphQLEnumType) {
return completeLeafValue(returnType, result);
}
// If field type is an abstract type, Interface or Union, determine the
// runtime Object type and complete for that type.
if (returnType instanceof _definition.GraphQLInterfaceType || returnType instanceof _definition.GraphQLUnionType) {
return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
}
// If field type is Object, execute and complete all sub-selections.
if (returnType instanceof _definition.GraphQLObjectType) {
return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
}
// Not reachable. All possible output types have been considered.
throw new Error('Cannot complete value of unexpected type "' + String(returnType) + '".');
}
/**
* Complete a list value by completing each item in the list with the
* inner type
*/
function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
(0, _invariant2.default)((0, _iterall.isCollection)(result), 'Expected Iterable, but did not find one for field ' + info.parentType.name + '.' + info.fieldName + '.');
// This is specified as a simple map, however we're optimizing the path
// where the list contains no Promises by avoiding creating another Promise.
var itemType = returnType.ofType;
var containsPromise = false;
var completedResults = [];
(0, _iterall.forEach)(result, function (item, index) {
// No need to modify the info object containing the path,
// since from here on it is not ever accessed by resolver functions.
var fieldPath = addPath(path, index);
var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
if (!containsPromise && isThenable(completedItem)) {
containsPromise = true;
}
completedResults.push(completedItem);
});
return containsPromise ? Promise.all(completedResults) : completedResults;
}
/**
* Complete a Scalar or Enum by serializing to a valid value, returning
* null if serialization is not possible.
*/
function completeLeafValue(returnType, result) {
(0, _invariant2.default)(returnType.serialize, 'Missing serialize method on type');
var serializedResult = returnType.serialize(result);
if ((0, _isNullish2.default)(serializedResult)) {
throw new Error('Expected a value of type "' + String(returnType) + '" but ' + ('received: ' + String(result)));
}
return serializedResult;
}
/**
* Complete a value of an abstract type by determining the runtime object type
* of that value, then complete the value for that type.
*/
function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
var runtimeType = returnType.resolveType ? returnType.resolveType(result, exeContext.contextValue, info) : defaultResolveTypeFn(result, exeContext.contextValue, info, returnType);
if (isThenable(runtimeType)) {
// Cast to Promise
var runtimeTypePromise = runtimeType;
return runtimeTypePromise.then(function (resolvedRuntimeType) {
return completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
});
}
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
}
function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
var runtimeType = typeof runtimeTypeOrName === 'string' ? exeContext.schema.getType(runtimeTypeOrName) : runtimeTypeOrName;
if (!(runtimeType instanceof _definition.GraphQLObjectType)) {
throw new _error.GraphQLError('Abstract type ' + returnType.name + ' must resolve to an Object type at ' + ('runtime for field ' + info.parentType.name + '.' + info.fieldName + ' with ') + ('value "' + String(result) + '", received "' + String(runtimeType) + '".'), fieldNodes);
}
if (!exeContext.schema.isPossibleType(returnType, runtimeType)) {
throw new _error.GraphQLError('Runtime Object type "' + runtimeType.name + '" is not a possible type ' + ('for "' + returnType.name + '".'), fieldNodes);
}
return runtimeType;
}
/**
* Complete an Object value by executing all sub-selections.
*/
function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
// If there is an isTypeOf predicate function, call it with the
// current result. If isTypeOf returns false, then raise an error rather
// than continuing execution.
if (returnType.isTypeOf) {
var isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
if (isThenable(isTypeOf)) {
return isTypeOf.then(function (isTypeOfResult) {
if (!isTypeOfResult) {
throw invalidReturnTypeError(returnType, result, fieldNodes);
}
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result);
});
}
if (!isTypeOf) {
throw invalidReturnTypeError(returnType, result, fieldNodes);
}
}
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result);
}
function invalidReturnTypeError(returnType, result, fieldNodes) {
return new _error.GraphQLError('Expected value of type "' + returnType.name + '" but got: ' + String(result) + '.', fieldNodes);
}
function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result) {
// Collect sub-fields to execute to complete this value.
var subFieldNodes = Object.create(null);
var visitedFragmentNames = Object.create(null);
for (var i = 0; i < fieldNodes.length; i++) {
var selectionSet = fieldNodes[i].selectionSet;
if (selectionSet) {
subFieldNodes = collectFields(exeContext, returnType, selectionSet, subFieldNodes, visitedFragmentNames);
}
}
return executeFields(exeContext, returnType, result, path, subFieldNodes);
}
/**
* If a resolveType function is not given, then a default resolve behavior is
* used which tests each possible type for the abstract type by calling
* isTypeOf for the object being coerced, returning the first type that matches.
*/
function defaultResolveTypeFn(value, context, info, abstractType) {
var possibleTypes = info.schema.getPossibleTypes(abstractType);
var promisedIsTypeOfResults = [];
for (var i = 0; i < possibleTypes.length; i++) {
var type = possibleTypes[i];
if (type.isTypeOf) {
var isTypeOfResult = type.isTypeOf(value, context, info);
if (isThenable(isTypeOfResult)) {
promisedIsTypeOfResults[i] = isTypeOfResult;
} else if (isTypeOfResult) {
return type;
}
}
}
if (promisedIsTypeOfResults.length) {
return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
for (var _i = 0; _i < isTypeOfResults.length; _i++) {
if (isTypeOfResults[_i]) {
return possibleTypes[_i];
}
}
});
}
}
/**
* If a resolve function is not given, then a default resolve behavior is used
* which takes the property of the source object of the same name as the field
* and returns it as the result, or if it's a function, returns the result
* of calling that function while passing along args and context.
*/
var defaultFieldResolver = exports.defaultFieldResolver = function defaultFieldResolver(source, args, context, info) {
// ensure source is a value for which property access is acceptable.
if (typeof source === 'object' || typeof source === 'function') {
var property = source[info.fieldName];
if (typeof property === 'function') {
return source[info.fieldName](args, context, info);
}
return property;
}
};
/**
* Checks to see if this object acts like a Promise, i.e. has a "then"
* function.
*/
function isThenable(value) {
return typeof value === 'object' && value !== null && typeof value.then === 'function';
}
/**
* This method looks up the field on the given type defintion.
* It has special casing for the two introspection fields, __schema
* and __typename. __typename is special because it can always be
* queried as a field, even in situations where no other fields
* are allowed, like on a Union. __schema could get automatically
* added to the query type, but that would require mutating type
* definitions, which would cause issues.
*/
function getFieldDef(schema, parentType, fieldName) {
if (fieldName === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
return _introspection.SchemaMetaFieldDef;
} else if (fieldName === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
return _introspection.TypeMetaFieldDef;
} else if (fieldName === _introspection.TypeNameMetaFieldDef.name) {
return _introspection.TypeNameMetaFieldDef;
}
return parentType.getFields()[fieldName];
}
/***/ }),
/* 31 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getVariableValues = getVariableValues;
exports.getArgumentValues = getArgumentValues;
var _iterall = __webpack_require__(20);
var _error = __webpack_require__(0);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _isNullish = __webpack_require__(6);
var _isNullish2 = _interopRequireDefault(_isNullish);
var _isInvalid = __webpack_require__(14);
var _isInvalid2 = _interopRequireDefault(_isInvalid);
var _keyMap = __webpack_require__(12);
var _keyMap2 = _interopRequireDefault(_keyMap);
var _typeFromAST = __webpack_require__(9);
var _valueFromAST = __webpack_require__(16);
var _isValidJSValue = __webpack_require__(33);
var _isValidLiteralValue = __webpack_require__(18);
var _kinds = __webpack_require__(2);
var Kind = _interopRequireWildcard(_kinds);
var _printer = __webpack_require__(4);
var _definition = __webpack_require__(1);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Prepares an object map of variableValues of the correct type based on the
* provided variable definitions and arbitrary input. If the input cannot be
* parsed to match the variable definitions, a GraphQLError will be thrown.
*/
function getVariableValues(schema, varDefNodes, inputs) {
var coercedValues = Object.create(null);
for (var i = 0; i < varDefNodes.length; i++) {
var varDefNode = varDefNodes[i];
var varName = varDefNode.variable.name.value;
var varType = (0, _typeFromAST.typeFromAST)(schema, varDefNode.type);
if (!(0, _definition.isInputType)(varType)) {
throw new _error.GraphQLError('Variable "$' + varName + '" expected value of type ' + ('"' + (0, _printer.print)(varDefNode.type) + '" which cannot be used as an input type.'), [varDefNode.type]);
}
varType = varType;
var value = inputs[varName];
if ((0, _isInvalid2.default)(value)) {
var defaultValue = varDefNode.defaultValue;
if (defaultValue) {
coercedValues[varName] = (0, _valueFromAST.valueFromAST)(defaultValue, varType);
}
if (varType instanceof _definition.GraphQLNonNull) {
throw new _error.GraphQLError('Variable "$' + varName + '" of required type ' + ('"' + String(varType) + '" was not provided.'), [varDefNode]);
}
} else {
var errors = (0, _isValidJSValue.isValidJSValue)(value, varType);
if (errors.length) {
var message = errors ? '\n' + errors.join('\n') : '';
throw new _error.GraphQLError('Variable "$' + varName + '" got invalid value ' + (JSON.stringify(value) + '.' + message), [varDefNode]);
}
var coercedValue = coerceValue(varType, value);
(0, _invariant2.default)(!(0, _isInvalid2.default)(coercedValue), 'Should have reported error.');
coercedValues[varName] = coercedValue;
}
}
return coercedValues;
}
/**
* Prepares an object map of argument values given a list of argument
* definitions and list of argument AST nodes.
*/
/**
* Copyright (c) 2015, 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.
*/
function getArgumentValues(def, node, variableValues) {
var argDefs = def.args;
var argNodes = node.arguments;
if (!argDefs || !argNodes) {
return {};
}
var coercedValues = Object.create(null);
var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
return arg.name.value;
});
for (var i = 0; i < argDefs.length; i++) {
var argDef = argDefs[i];
var name = argDef.name;
var argType = argDef.type;
var argumentNode = argNodeMap[name];
var defaultValue = argDef.defaultValue;
if (!argumentNode) {
if (!(0, _isInvalid2.default)(defaultValue)) {
coercedValues[name] = defaultValue;
} else if (argType instanceof _definition.GraphQLNonNull) {
throw new _error.GraphQLError('Argument "' + name + '" of required type ' + ('"' + String(argType) + '" was not provided.'), [node]);
}
} else if (argumentNode.value.kind === Kind.VARIABLE) {
var variableName = argumentNode.value.name.value;
if (variableValues && !(0, _isInvalid2.default)(variableValues[variableName])) {
// Note: this does not check that this variable value is correct.
// This assumes that this query has been validated and the variable
// usage here is of the correct type.
coercedValues[name] = variableValues[variableName];
} else if (!(0, _isInvalid2.default)(defaultValue)) {
coercedValues[name] = defaultValue;
} else if (argType instanceof _definition.GraphQLNonNull) {
throw new _error.GraphQLError('Argument "' + name + '" of required type "' + String(argType) + '" was ' + ('provided the variable "$' + variableName + '" which was not provided ') + 'a runtime value.', [argumentNode.value]);
}
} else {
var valueNode = argumentNode.value;
var coercedValue = (0, _valueFromAST.valueFromAST)(valueNode, argType, variableValues);
if ((0, _isInvalid2.default)(coercedValue)) {
var errors = (0, _isValidLiteralValue.isValidLiteralValue)(argType, valueNode);
var message = errors ? '\n' + errors.join('\n') : '';
throw new _error.GraphQLError('Argument "' + name + '" got invalid value ' + (0, _printer.print)(valueNode) + '.' + message, [argumentNode.value]);
}
coercedValues[name] = coercedValue;
}
}
return coercedValues;
}
/**
* Given a type and any value, return a runtime value coerced to match the type.
*/
function coerceValue(type, value) {
// Ensure flow knows that we treat function params as const.
var _value = value;
if ((0, _isInvalid2.default)(_value)) {
return; // Intentionally return no value.
}
if (type instanceof _definition.GraphQLNonNull) {
if (_value === null) {
return; // Intentionally return no value.
}
return coerceValue(type.ofType, _value);
}
if (_value === null) {
// Intentionally return the value null.
return null;
}
if (type instanceof _definition.GraphQLList) {
var itemType = type.ofType;
if ((0, _iterall.isCollection)(_value)) {
var coercedValues = [];
var valueIter = (0, _iterall.createIterator)(_value);
if (!valueIter) {
return; // Intentionally return no value.
}
var step = void 0;
while (!(step = valueIter.next()).done) {
var itemValue = coerceValue(itemType, step.value);
if ((0, _isInvalid2.default)(itemValue)) {
return; // Intentionally return no value.
}
coercedValues.push(itemValue);
}
return coercedValues;
}
var coercedValue = coerceValue(itemType, _value);
if ((0, _isInvalid2.default)(coercedValue)) {
return; // Intentionally return no value.
}
return [coerceValue(itemType, _value)];
}
if (type instanceof _definition.GraphQLInputObjectType) {
if (typeof _value !== 'object') {
return; // Intentionally return no value.
}
var coercedObj = Object.create(null);
var fields = type.getFields();
var fieldNames = Object.keys(fields);
for (var i = 0; i < fieldNames.length; i++) {
var fieldName = fieldNames[i];
var field = fields[fieldName];
if ((0, _isInvalid2.default)(_value[fieldName])) {
if (!(0, _isInvalid2.default)(field.defaultValue)) {
coercedObj[fieldName] = field.defaultValue;
} else if (field.type instanceof _definition.GraphQLNonNull) {
return; // Intentionally return no value.
}
continue;
}
var fieldValue = coerceValue(field.type, _value[fieldName]);
if ((0, _isInvalid2.default)(fieldValue)) {
return; // Intentionally return no value.
}
coercedObj[fieldName] = fieldValue;
}
return coercedObj;
}
(0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
var parsed = type.parseValue(_value);
if ((0, _isNullish2.default)(parsed)) {
// null or invalid values represent a failure to parse correctly,
// in which case no value is returned.
return;
}
return parsed;
}
/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildASTSchema = buildASTSchema;
exports.getDescription = getDescription;
exports.buildSchema = buildSchema;
var _find = __webpack_require__(10);
var _find2 = _interopRequireDefault(_find);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _keyValMap = __webpack_require__(21);
var _keyValMap2 = _interopRequireDefault(_keyValMap);
var _valueFromAST = __webpack_require__(16);
var _lexer = __webpack_require__(24);
var _parser = __webpack_require__(17);
var _values = __webpack_require__(31);
var _kinds = __webpack_require__(2);
var _schema = __webpack_require__(8);
var _scalars = __webpack_require__(7);
var _definition = __webpack_require__(1);
var _directives = __webpack_require__(5);
var _introspection = __webpack_require__(11);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function buildWrappedType(innerType, inputTypeNode) {
if (inputTypeNode.kind === _kinds.LIST_TYPE) {
return new _definition.GraphQLList(buildWrappedType(innerType, inputTypeNode.type));
}
if (inputTypeNode.kind === _kinds.NON_NULL_TYPE) {
var wrappedType = buildWrappedType(innerType, inputTypeNode.type);
(0, _invariant2.default)(!(wrappedType instanceof _definition.GraphQLNonNull), 'No nesting nonnull.');
return new _definition.GraphQLNonNull(wrappedType);
}
return innerType;
}
/**
* Copyright (c) 2015, 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.
*/
function getNamedTypeNode(typeNode) {
var namedType = typeNode;
while (namedType.kind === _kinds.LIST_TYPE || namedType.kind === _kinds.NON_NULL_TYPE) {
namedType = namedType.type;
}
return namedType;
}
/**
* This takes the ast of a schema document produced by the parse function in
* src/language/parser.js.
*
* If no schema definition is provided, then it will look for types named Query
* and Mutation.
*
* Given that AST it constructs a GraphQLSchema. The resulting schema
* has no resolve methods, so execution will use default resolvers.
*/
function buildASTSchema(ast) {
if (!ast || ast.kind !== _kinds.DOCUMENT) {
throw new Error('Must provide a document ast.');
}
var schemaDef = void 0;
var typeDefs = [];
var nodeMap = Object.create(null);
var directiveDefs = [];
for (var i = 0; i < ast.definitions.length; i++) {
var d = ast.definitions[i];
switch (d.kind) {
case _kinds.SCHEMA_DEFINITION:
if (schemaDef) {
throw new Error('Must provide only one schema definition.');
}
schemaDef = d;
break;
case _kinds.SCALAR_TYPE_DEFINITION:
case _kinds.OBJECT_TYPE_DEFINITION:
case _kinds.INTERFACE_TYPE_DEFINITION:
case _kinds.ENUM_TYPE_DEFINITION:
case _kinds.UNION_TYPE_DEFINITION:
case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
typeDefs.push(d);
nodeMap[d.name.value] = d;
break;
case _kinds.DIRECTIVE_DEFINITION:
directiveDefs.push(d);
break;
}
}
var queryTypeName = void 0;
var mutationTypeName = void 0;
var subscriptionTypeName = void 0;
if (schemaDef) {
schemaDef.operationTypes.forEach(function (operationType) {
var typeName = operationType.type.name.value;
if (operationType.operation === 'query') {
if (queryTypeName) {
throw new Error('Must provide only one query type in schema.');
}
if (!nodeMap[typeName]) {
throw new Error('Specified query type "' + typeName + '" not found in document.');
}
queryTypeName = typeName;
} else if (operationType.operation === 'mutation') {
if (mutationTypeName) {
throw new Error('Must provide only one mutation type in schema.');
}
if (!nodeMap[typeName]) {
throw new Error('Specified mutation type "' + typeName + '" not found in document.');
}
mutationTypeName = typeName;
} else if (operationType.operation === 'subscription') {
if (subscriptionTypeName) {
throw new Error('Must provide only one subscription type in schema.');
}
if (!nodeMap[typeName]) {
throw new Error('Specified subscription type "' + typeName + '" not found in document.');
}
subscriptionTypeName = typeName;
}
});
} else {
if (nodeMap.Query) {
queryTypeName = 'Query';
}
if (nodeMap.Mutation) {
mutationTypeName = 'Mutation';
}
if (nodeMap.Subscription) {
subscriptionTypeName = 'Subscription';
}
}
if (!queryTypeName) {
throw new Error('Must provide schema definition with query type or a type named Query.');
}
var innerTypeMap = {
String: _scalars.GraphQLString,
Int: _scalars.GraphQLInt,
Float: _scalars.GraphQLFloat,
Boolean: _scalars.GraphQLBoolean,
ID: _scalars.GraphQLID,
__Schema: _introspection.__Schema,
__Directive: _introspection.__Directive,
__DirectiveLocation: _introspection.__DirectiveLocation,
__Type: _introspection.__Type,
__Field: _introspection.__Field,
__InputValue: _introspection.__InputValue,
__EnumValue: _introspection.__EnumValue,
__TypeKind: _introspection.__TypeKind
};
var types = typeDefs.map(function (def) {
return typeDefNamed(def.name.value);
});
var directives = directiveDefs.map(getDirective);
// If specified directives were not explicitly declared, add them.
if (!directives.some(function (directive) {
return directive.name === 'skip';
})) {
directives.push(_directives.GraphQLSkipDirective);
}
if (!directives.some(function (directive) {
return directive.name === 'include';
})) {
directives.push(_directives.GraphQLIncludeDirective);
}
if (!directives.some(function (directive) {
return directive.name === 'deprecated';
})) {
directives.push(_directives.GraphQLDeprecatedDirective);
}
return new _schema.GraphQLSchema({
query: getObjectType(nodeMap[queryTypeName]),
mutation: mutationTypeName ? getObjectType(nodeMap[mutationTypeName]) : null,
subscription: subscriptionTypeName ? getObjectType(nodeMap[subscriptionTypeName]) : null,
types: types,
directives: directives
});
function getDirective(directiveNode) {
return new _directives.GraphQLDirective({
name: directiveNode.name.value,
description: getDescription(directiveNode),
locations: directiveNode.locations.map(function (node) {
return node.value;
}),
args: directiveNode.arguments && makeInputValues(directiveNode.arguments)
});
}
function getObjectType(typeNode) {
var type = typeDefNamed(typeNode.name.value);
(0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'AST must provide object type.');
return type;
}
function produceType(typeNode) {
var typeName = getNamedTypeNode(typeNode).name.value;
var typeDef = typeDefNamed(typeName);
return buildWrappedType(typeDef, typeNode);
}
function produceInputType(typeNode) {
var type = produceType(typeNode);
(0, _invariant2.default)((0, _definition.isInputType)(type), 'Expected Input type.');
return type;
}
function produceOutputType(typeNode) {
var type = produceType(typeNode);
(0, _invariant2.default)((0, _definition.isOutputType)(type), 'Expected Output type.');
return type;
}
function produceObjectType(typeNode) {
var type = produceType(typeNode);
(0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Expected Object type.');
return type;
}
function produceInterfaceType(typeNode) {
var type = produceType(typeNode);
(0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Expected Interface type.');
return type;
}
function typeDefNamed(typeName) {
if (innerTypeMap[typeName]) {
return innerTypeMap[typeName];
}
if (!nodeMap[typeName]) {
throw new Error('Type "' + typeName + '" not found in document.');
}
var innerTypeDef = makeSchemaDef(nodeMap[typeName]);
if (!innerTypeDef) {
throw new Error('Nothing constructed for "' + typeName + '".');
}
innerTypeMap[typeName] = innerTypeDef;
return innerTypeDef;
}
function makeSchemaDef(def) {
if (!def) {
throw new Error('def must be defined');
}
switch (def.kind) {
case _kinds.OBJECT_TYPE_DEFINITION:
return makeTypeDef(def);
case _kinds.INTERFACE_TYPE_DEFINITION:
return makeInterfaceDef(def);
case _kinds.ENUM_TYPE_DEFINITION:
return makeEnumDef(def);
case _kinds.UNION_TYPE_DEFINITION:
return makeUnionDef(def);
case _kinds.SCALAR_TYPE_DEFINITION:
return makeScalarDef(def);
case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
return makeInputObjectDef(def);
default:
throw new Error('Type kind "' + def.kind + '" not supported.');
}
}
function makeTypeDef(def) {
var typeName = def.name.value;
return new _definition.GraphQLObjectType({
name: typeName,
description: getDescription(def),
fields: function fields() {
return makeFieldDefMap(def);
},
interfaces: function interfaces() {
return makeImplementedInterfaces(def);
}
});
}
function makeFieldDefMap(def) {
return (0, _keyValMap2.default)(def.fields, function (field) {
return field.name.value;
}, function (field) {
return {
type: produceOutputType(field.type),
description: getDescription(field),
args: makeInputValues(field.arguments),
deprecationReason: getDeprecationReason(field.directives)
};
});
}
function makeImplementedInterfaces(def) {
return def.interfaces && def.interfaces.map(function (iface) {
return produceInterfaceType(iface);
});
}
function makeInputValues(values) {
return (0, _keyValMap2.default)(values, function (value) {
return value.name.value;
}, function (value) {
var type = produceInputType(value.type);
return {
type: type,
description: getDescription(value),
defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type)
};
});
}
function makeInterfaceDef(def) {
var typeName = def.name.value;
return new _definition.GraphQLInterfaceType({
name: typeName,
description: getDescription(def),
fields: function fields() {
return makeFieldDefMap(def);
},
resolveType: cannotExecuteSchema
});
}
function makeEnumDef(def) {
var enumType = new _definition.GraphQLEnumType({
name: def.name.value,
description: getDescription(def),
values: (0, _keyValMap2.default)(def.values, function (enumValue) {
return enumValue.name.value;
}, function (enumValue) {
return {
description: getDescription(enumValue),
deprecationReason: getDeprecationReason(enumValue.directives)
};
})
});
return enumType;
}
function makeUnionDef(def) {
return new _definition.GraphQLUnionType({
name: def.name.value,
description: getDescription(def),
types: def.types.map(function (t) {
return produceObjectType(t);
}),
resolveType: cannotExecuteSchema
});
}
function makeScalarDef(def) {
return new _definition.GraphQLScalarType({
name: def.name.value,
description: getDescription(def),
serialize: function serialize() {
return null;
},
// Note: validation calls the parse functions to determine if a
// literal value is correct. Returning null would cause use of custom
// scalars to always fail validation. Returning false causes them to
// always pass validation.
parseValue: function parseValue() {
return false;
},
parseLiteral: function parseLiteral() {
return false;
}
});
}
function makeInputObjectDef(def) {
return new _definition.GraphQLInputObjectType({
name: def.name.value,
description: getDescription(def),
fields: function fields() {
return makeInputValues(def.fields);
}
});
}
}
function getDeprecationReason(directives) {
var deprecatedAST = directives && (0, _find2.default)(directives, function (directive) {
return directive.name.value === _directives.GraphQLDeprecatedDirective.name;
});
if (!deprecatedAST) {
return;
}
var _getArgumentValues = (0, _values.getArgumentValues)(_directives.GraphQLDeprecatedDirective, deprecatedAST),
reason = _getArgumentValues.reason;
return reason;
}
/**
* Given an ast node, returns its string description based on a contiguous
* block full-line of comments preceding it.
*/
function getDescription(node) {
var loc = node.loc;
if (!loc) {
return;
}
var comments = [];
var minSpaces = void 0;
var token = loc.startToken.prev;
while (token && token.kind === _lexer.TokenKind.COMMENT && token.next && token.prev && token.line + 1 === token.next.line && token.line !== token.prev.line) {
var value = String(token.value);
var spaces = leadingSpaces(value);
if (minSpaces === undefined || spaces < minSpaces) {
minSpaces = spaces;
}
comments.push(value);
token = token.prev;
}
return comments.reverse().map(function (comment) {
return comment.slice(minSpaces);
}).join('\n');
}
/**
* A helper function to build a GraphQLSchema directly from a source
* document.
*/
function buildSchema(source) {
return buildASTSchema((0, _parser.parse)(source));
}
// Count the number of spaces on the starting side of a string.
function leadingSpaces(str) {
var i = 0;
for (; i < str.length; i++) {
if (str[i] !== ' ') {
break;
}
}
return i;
}
function cannotExecuteSchema() {
throw new Error('Generated Schema cannot use Interface or Union types for execution.');
}
/***/ }),
/* 33 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isValidJSValue = isValidJSValue;
var _iterall = __webpack_require__(20);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _isNullish = __webpack_require__(6);
var _isNullish2 = _interopRequireDefault(_isNullish);
var _definition = __webpack_require__(1);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Given a JavaScript value and a GraphQL type, determine if the value will be
* accepted for that type. This is primarily useful for validating the
* runtime values of query variables.
*/
/**
* Copyright (c) 2015, 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.
*/
function isValidJSValue(value, type) {
// A value must be provided if the type is non-null.
if (type instanceof _definition.GraphQLNonNull) {
if ((0, _isNullish2.default)(value)) {
return ['Expected "' + String(type) + '", found null.'];
}
return isValidJSValue(value, type.ofType);
}
if ((0, _isNullish2.default)(value)) {
return [];
}
// Lists accept a non-list value as a list of one.
if (type instanceof _definition.GraphQLList) {
var _ret = function () {
var itemType = type.ofType;
if ((0, _iterall.isCollection)(value)) {
var _ret2 = function () {
var errors = [];
(0, _iterall.forEach)(value, function (item, index) {
errors.push.apply(errors, isValidJSValue(item, itemType).map(function (error) {
return 'In element #' + index + ': ' + error;
}));
});
return {
v: {
v: errors
}
};
}();
if (typeof _ret2 === "object") return _ret2.v;
}
return {
v: isValidJSValue(value, itemType)
};
}();
if (typeof _ret === "object") return _ret.v;
}
// Input objects check each defined field.
if (type instanceof _definition.GraphQLInputObjectType) {
var _ret3 = function () {
if (typeof value !== 'object' || value === null) {
return {
v: ['Expected "' + type.name + '", found not an object.']
};
}
var fields = type.getFields();
var errors = [];
// Ensure every provided field is defined.
Object.keys(value).forEach(function (providedField) {
if (!fields[providedField]) {
errors.push('In field "' + providedField + '": Unknown field.');
}
});
// Ensure every defined field is valid.
Object.keys(fields).forEach(function (fieldName) {
var newErrors = isValidJSValue(value[fieldName], fields[fieldName].type);
errors.push.apply(errors, newErrors.map(function (error) {
return 'In field "' + fieldName + '": ' + error;
}));
});
return {
v: errors
};
}();
if (typeof _ret3 === "object") return _ret3.v;
}
(0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
// Scalar/Enum input checks to ensure the type can parse the value to
// a non-null value.
try {
var parseResult = type.parseValue(value);
if ((0, _isNullish2.default)(parseResult)) {
return ['Expected type "' + type.name + '", found ' + JSON.stringify(value) + '.'];
}
} catch (error) {
return ['Expected type "' + type.name + '", found ' + JSON.stringify(value) + ': ' + error.message];
}
return [];
}
/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.specifiedRules = undefined;
var _UniqueOperationNames = __webpack_require__(77);
var _LoneAnonymousOperation = __webpack_require__(64);
var _KnownTypeNames = __webpack_require__(63);
var _FragmentsOnCompositeTypes = __webpack_require__(59);
var _VariablesAreInputTypes = __webpack_require__(79);
var _ScalarLeafs = __webpack_require__(72);
var _FieldsOnCorrectType = __webpack_require__(58);
var _UniqueFragmentNames = __webpack_require__(75);
var _KnownFragmentNames = __webpack_require__(62);
var _NoUnusedFragments = __webpack_require__(67);
var _PossibleFragmentSpreads = __webpack_require__(70);
var _NoFragmentCycles = __webpack_require__(65);
var _UniqueVariableNames = __webpack_require__(78);
var _NoUndefinedVariables = __webpack_require__(66);
var _NoUnusedVariables = __webpack_require__(68);
var _KnownDirectives = __webpack_require__(61);
var _UniqueDirectivesPerLocation = __webpack_require__(74);
var _KnownArgumentNames = __webpack_require__(60);
var _UniqueArgumentNames = __webpack_require__(73);
var _ArgumentsOfCorrectType = __webpack_require__(56);
var _ProvidedNonNullArguments = __webpack_require__(71);
var _DefaultValuesOfCorrectType = __webpack_require__(57);
var _VariablesInAllowedPosition = __webpack_require__(80);
var _OverlappingFieldsCanBeMerged = __webpack_require__(69);
var _UniqueInputFieldNames = __webpack_require__(76);
/**
* This set includes all validation rules defined by the GraphQL spec.
*/
// Spec Section: "Field Selection Merging"
// Spec Section: "Variable Default Values Are Correctly Typed"
// Spec Section: "Argument Values Type Correctness"
// Spec Section: "Argument Names"
// Spec Section: "Directives Are Defined"
// Spec Section: "All Variable Used Defined"
// Spec Section: "Fragments must not form cycles"
// Spec Section: "Fragments must be used"
// Spec Section: "Fragment Name Uniqueness"
// Spec Section: "Leaf Field Selections"
// Spec Section: "Fragments on Composite Types"
// Spec Section: "Lone Anonymous Operation"
var specifiedRules = exports.specifiedRules = [_UniqueOperationNames.UniqueOperationNames, _LoneAnonymousOperation.LoneAnonymousOperation, _KnownTypeNames.KnownTypeNames, _FragmentsOnCompositeTypes.FragmentsOnCompositeTypes, _VariablesAreInputTypes.VariablesAreInputTypes, _ScalarLeafs.ScalarLeafs, _FieldsOnCorrectType.FieldsOnCorrectType, _UniqueFragmentNames.UniqueFragmentNames, _KnownFragmentNames.KnownFragmentNames, _NoUnusedFragments.NoUnusedFragments, _PossibleFragmentSpreads.PossibleFragmentSpreads, _NoFragmentCycles.NoFragmentCycles, _UniqueVariableNames.UniqueVariableNames, _NoUndefinedVariables.NoUndefinedVariables, _NoUnusedVariables.NoUnusedVariables, _KnownDirectives.KnownDirectives, _UniqueDirectivesPerLocation.UniqueDirectivesPerLocation, _KnownArgumentNames.KnownArgumentNames, _UniqueArgumentNames.UniqueArgumentNames, _ArgumentsOfCorrectType.ArgumentsOfCorrectType, _ProvidedNonNullArguments.ProvidedNonNullArguments, _DefaultValuesOfCorrectType.DefaultValuesOfCorrectType, _VariablesInAllowedPosition.VariablesInAllowedPosition, _OverlappingFieldsCanBeMerged.OverlappingFieldsCanBeMerged, _UniqueInputFieldNames.UniqueInputFieldNames];
// Spec Section: "Input Object Field Uniqueness"
// Spec Section: "All Variable Usages Are Allowed"
// Spec Section: "Argument Optionality"
// Spec Section: "Argument Uniqueness"
// Spec Section: "Directives Are Unique Per Location"
// Spec Section: "All Variables Used"
// Spec Section: "Variable Uniqueness"
// Spec Section: "Fragment spread is possible"
// Spec Section: "Fragment spread target defined"
// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
// Spec Section: "Variables are Input Types"
// Spec Section: "Fragment Spread Type Existence"
/**
* Copyright (c) 2015, 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.
*/
// Spec Section: "Operation Name Uniqueness"
/***/ }),
/* 35 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ValidationContext = undefined;
exports.validate = validate;
exports.visitUsingRules = visitUsingRules;
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _error = __webpack_require__(0);
var _visitor = __webpack_require__(15);
var _kinds = __webpack_require__(2);
var Kind = _interopRequireWildcard(_kinds);
var _schema = __webpack_require__(8);
var _TypeInfo = __webpack_require__(27);
var _specifiedRules = __webpack_require__(34);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2015, 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.
*/
/**
* Implements the "Validation" section of the spec.
*
* Validation runs synchronously, returning an array of encountered errors, or
* an empty array if no errors were encountered and the document is valid.
*
* A list of specific validation rules may be provided. If not provided, the
* default list of rules defined by the GraphQL specification will be used.
*
* Each validation rules is a function which returns a visitor
* (see the language/visitor API). Visitor methods are expected to return
* GraphQLErrors, or Arrays of GraphQLErrors when invalid.
*/
function validate(schema, ast, rules) {
(0, _invariant2.default)(schema, 'Must provide schema');
(0, _invariant2.default)(ast, 'Must provide document');
(0, _invariant2.default)(schema instanceof _schema.GraphQLSchema, 'Schema must be an instance of GraphQLSchema. Also ensure that there are ' + 'not multiple versions of GraphQL installed in your node_modules directory.');
var typeInfo = new _TypeInfo.TypeInfo(schema);
return visitUsingRules(schema, typeInfo, ast, rules || _specifiedRules.specifiedRules);
}
/**
* This uses a specialized visitor which runs multiple visitors in parallel,
* while maintaining the visitor skip and break API.
*
* @internal
*/
function visitUsingRules(schema, typeInfo, documentAST, rules) {
var context = new ValidationContext(schema, documentAST, typeInfo);
var visitors = rules.map(function (rule) {
return rule(context);
});
// Visit the whole document with each instance of all provided rules.
(0, _visitor.visit)(documentAST, (0, _visitor.visitWithTypeInfo)(typeInfo, (0, _visitor.visitInParallel)(visitors)));
return context.getErrors();
}
/**
* An instance of this class is passed as the "this" context to all validators,
* allowing access to commonly useful contextual information from within a
* validation rule.
*/
var ValidationContext = exports.ValidationContext = function () {
function ValidationContext(schema, ast, typeInfo) {
_classCallCheck(this, ValidationContext);
this._schema = schema;
this._ast = ast;
this._typeInfo = typeInfo;
this._errors = [];
this._fragmentSpreads = new Map();
this._recursivelyReferencedFragments = new Map();
this._variableUsages = new Map();
this._recursiveVariableUsages = new Map();
}
ValidationContext.prototype.reportError = function reportError(error) {
this._errors.push(error);
};
ValidationContext.prototype.getErrors = function getErrors() {
return this._errors;
};
ValidationContext.prototype.getSchema = function getSchema() {
return this._schema;
};
ValidationContext.prototype.getDocument = function getDocument() {
return this._ast;
};
ValidationContext.prototype.getFragment = function getFragment(name) {
var fragments = this._fragments;
if (!fragments) {
this._fragments = fragments = this.getDocument().definitions.reduce(function (frags, statement) {
if (statement.kind === Kind.FRAGMENT_DEFINITION) {
frags[statement.name.value] = statement;
}
return frags;
}, {});
}
return fragments[name];
};
ValidationContext.prototype.getFragmentSpreads = function getFragmentSpreads(node) {
var spreads = this._fragmentSpreads.get(node);
if (!spreads) {
spreads = [];
var setsToVisit = [node];
while (setsToVisit.length !== 0) {
var set = setsToVisit.pop();
for (var i = 0; i < set.selections.length; i++) {
var selection = set.selections[i];
if (selection.kind === Kind.FRAGMENT_SPREAD) {
spreads.push(selection);
} else if (selection.selectionSet) {
setsToVisit.push(selection.selectionSet);
}
}
}
this._fragmentSpreads.set(node, spreads);
}
return spreads;
};
ValidationContext.prototype.getRecursivelyReferencedFragments = function getRecursivelyReferencedFragments(operation) {
var fragments = this._recursivelyReferencedFragments.get(operation);
if (!fragments) {
fragments = [];
var collectedNames = Object.create(null);
var nodesToVisit = [operation.selectionSet];
while (nodesToVisit.length !== 0) {
var _node = nodesToVisit.pop();
var spreads = this.getFragmentSpreads(_node);
for (var i = 0; i < spreads.length; i++) {
var fragName = spreads[i].name.value;
if (collectedNames[fragName] !== true) {
collectedNames[fragName] = true;
var fragment = this.getFragment(fragName);
if (fragment) {
fragments.push(fragment);
nodesToVisit.push(fragment.selectionSet);
}
}
}
}
this._recursivelyReferencedFragments.set(operation, fragments);
}
return fragments;
};
ValidationContext.prototype.getVariableUsages = function getVariableUsages(node) {
var _this = this;
var usages = this._variableUsages.get(node);
if (!usages) {
(function () {
var newUsages = [];
var typeInfo = new _TypeInfo.TypeInfo(_this._schema);
(0, _visitor.visit)(node, (0, _visitor.visitWithTypeInfo)(typeInfo, {
VariableDefinition: function VariableDefinition() {
return false;
},
Variable: function Variable(variable) {
newUsages.push({ node: variable, type: typeInfo.getInputType() });
}
}));
usages = newUsages;
_this._variableUsages.set(node, usages);
})();
}
return usages;
};
ValidationContext.prototype.getRecursiveVariableUsages = function getRecursiveVariableUsages(operation) {
var usages = this._recursiveVariableUsages.get(operation);
if (!usages) {
usages = this.getVariableUsages(operation);
var fragments = this.getRecursivelyReferencedFragments(operation);
for (var i = 0; i < fragments.length; i++) {
Array.prototype.push.apply(usages, this.getVariableUsages(fragments[i]));
}
this._recursiveVariableUsages.set(operation, usages);
}
return usages;
};
ValidationContext.prototype.getType = function getType() {
return this._typeInfo.getType();
};
ValidationContext.prototype.getParentType = function getParentType() {
return this._typeInfo.getParentType();
};
ValidationContext.prototype.getInputType = function getInputType() {
return this._typeInfo.getInputType();
};
ValidationContext.prototype.getFieldDef = function getFieldDef() {
return this._typeInfo.getFieldDef();
};
ValidationContext.prototype.getDirective = function getDirective() {
return this._typeInfo.getDirective();
};
ValidationContext.prototype.getArgument = function getArgument() {
return this._typeInfo.getArgument();
};
return ValidationContext;
}();
/***/ }),
/* 36 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _graphql = __webpack_require__(42);
Object.defineProperty(exports, 'graphql', {
enumerable: true,
get: function get() {
return _graphql.graphql;
}
});
var _type = __webpack_require__(44);
Object.defineProperty(exports, 'GraphQLSchema', {
enumerable: true,
get: function get() {
return _type.GraphQLSchema;
}
});
Object.defineProperty(exports, 'GraphQLScalarType', {
enumerable: true,
get: function get() {
return _type.GraphQLScalarType;
}
});
Object.defineProperty(exports, 'GraphQLObjectType', {
enumerable: true,
get: function get() {
return _type.GraphQLObjectType;
}
});
Object.defineProperty(exports, 'GraphQLInterfaceType', {
enumerable: true,
get: function get() {
return _type.GraphQLInterfaceType;
}
});
Object.defineProperty(exports, 'GraphQLUnionType', {
enumerable: true,
get: function get() {
return _type.GraphQLUnionType;
}
});
Object.defineProperty(exports, 'GraphQLEnumType', {
enumerable: true,
get: function get() {
return _type.GraphQLEnumType;
}
});
Object.defineProperty(exports, 'GraphQLInputObjectType', {
enumerable: true,
get: function get() {
return _type.GraphQLInputObjectType;
}
});
Object.defineProperty(exports, 'GraphQLList', {
enumerable: true,
get: function get() {
return _type.GraphQLList;
}
});
Object.defineProperty(exports, 'GraphQLNonNull', {
enumerable: true,
get: function get() {
return _type.GraphQLNonNull;
}
});
Object.defineProperty(exports, 'GraphQLDirective', {
enumerable: true,
get: function get() {
return _type.GraphQLDirective;
}
});
Object.defineProperty(exports, 'TypeKind', {
enumerable: true,
get: function get() {
return _type.TypeKind;
}
});
Object.defineProperty(exports, 'DirectiveLocation', {
enumerable: true,
get: function get() {
return _type.DirectiveLocation;
}
});
Object.defineProperty(exports, 'GraphQLInt', {
enumerable: true,
get: function get() {
return _type.GraphQLInt;
}
});
Object.defineProperty(exports, 'GraphQLFloat', {
enumerable: true,
get: function get() {
return _type.GraphQLFloat;
}
});
Object.defineProperty(exports, 'GraphQLString', {
enumerable: true,
get: function get() {
return _type.GraphQLString;
}
});
Object.defineProperty(exports, 'GraphQLBoolean', {
enumerable: true,
get: function get() {
return _type.GraphQLBoolean;
}
});
Object.defineProperty(exports, 'GraphQLID', {
enumerable: true,
get: function get() {
return _type.GraphQLID;
}
});
Object.defineProperty(exports, 'specifiedDirectives', {
enumerable: true,
get: function get() {
return _type.specifiedDirectives;
}
});
Object.defineProperty(exports, 'GraphQLIncludeDirective', {
enumerable: true,
get: function get() {
return _type.GraphQLIncludeDirective;
}
});
Object.defineProperty(exports, 'GraphQLSkipDirective', {
enumerable: true,
get: function get() {
return _type.GraphQLSkipDirective;
}
});
Object.defineProperty(exports, 'GraphQLDeprecatedDirective', {
enumerable: true,
get: function get() {
return _type.GraphQLDeprecatedDirective;
}
});
Object.defineProperty(exports, 'DEFAULT_DEPRECATION_REASON', {
enumerable: true,
get: function get() {
return _type.DEFAULT_DEPRECATION_REASON;
}
});
Object.defineProperty(exports, 'SchemaMetaFieldDef', {
enumerable: true,
get: function get() {
return _type.SchemaMetaFieldDef;
}
});
Object.defineProperty(exports, 'TypeMetaFieldDef', {
enumerable: true,
get: function get() {
return _type.TypeMetaFieldDef;
}
});
Object.defineProperty(exports, 'TypeNameMetaFieldDef', {
enumerable: true,
get: function get() {
return _type.TypeNameMetaFieldDef;
}
});
Object.defineProperty(exports, '__Schema', {
enumerable: true,
get: function get() {
return _type.__Schema;
}
});
Object.defineProperty(exports, '__Directive', {
enumerable: true,
get: function get() {
return _type.__Directive;
}
});
Object.defineProperty(exports, '__DirectiveLocation', {
enumerable: true,
get: function get() {
return _type.__DirectiveLocation;
}
});
Object.defineProperty(exports, '__Type', {
enumerable: true,
get: function get() {
return _type.__Type;
}
});
Object.defineProperty(exports, '__Field', {
enumerable: true,
get: function get() {
return _type.__Field;
}
});
Object.defineProperty(exports, '__InputValue', {
enumerable: true,
get: function get() {
return _type.__InputValue;
}
});
Object.defineProperty(exports, '__EnumValue', {
enumerable: true,
get: function get() {
return _type.__EnumValue;
}
});
Object.defineProperty(exports, '__TypeKind', {
enumerable: true,
get: function get() {
return _type.__TypeKind;
}
});
Object.defineProperty(exports, 'isType', {
enumerable: true,
get: function get() {
return _type.isType;
}
});
Object.defineProperty(exports, 'isInputType', {
enumerable: true,
get: function get() {
return _type.isInputType;
}
});
Object.defineProperty(exports, 'isOutputType', {
enumerable: true,
get: function get() {
return _type.isOutputType;
}
});
Object.defineProperty(exports, 'isLeafType', {
enumerable: true,
get: function get() {
return _type.isLeafType;
}
});
Object.defineProperty(exports, 'isCompositeType', {
enumerable: true,
get: function get() {
return _type.isCompositeType;
}
});
Object.defineProperty(exports, 'isAbstractType', {
enumerable: true,
get: function get() {
return _type.isAbstractType;
}
});
Object.defineProperty(exports, 'isNamedType', {
enumerable: true,
get: function get() {
return _type.isNamedType;
}
});
Object.defineProperty(exports, 'assertType', {
enumerable: true,
get: function get() {
return _type.assertType;
}
});
Object.defineProperty(exports, 'assertInputType', {
enumerable: true,
get: function get() {
return _type.assertInputType;
}
});
Object.defineProperty(exports, 'assertOutputType', {
enumerable: true,
get: function get() {
return _type.assertOutputType;
}
});
Object.defineProperty(exports, 'assertLeafType', {
enumerable: true,
get: function get() {
return _type.assertLeafType;
}
});
Object.defineProperty(exports, 'assertCompositeType', {
enumerable: true,
get: function get() {
return _type.assertCompositeType;
}
});
Object.defineProperty(exports, 'assertAbstractType', {
enumerable: true,
get: function get() {
return _type.assertAbstractType;
}
});
Object.defineProperty(exports, 'assertNamedType', {
enumerable: true,
get: function get() {
return _type.assertNamedType;
}
});
Object.defineProperty(exports, 'getNullableType', {
enumerable: true,
get: function get() {
return _type.getNullableType;
}
});
Object.defineProperty(exports, 'getNamedType', {
enumerable: true,
get: function get() {
return _type.getNamedType;
}
});
var _language = __webpack_require__(43);
Object.defineProperty(exports, 'Source', {
enumerable: true,
get: function get() {
return _language.Source;
}
});
Object.defineProperty(exports, 'getLocation', {
enumerable: true,
get: function get() {
return _language.getLocation;
}
});
Object.defineProperty(exports, 'parse', {
enumerable: true,
get: function get() {
return _language.parse;
}
});
Object.defineProperty(exports, 'parseValue', {
enumerable: true,
get: function get() {
return _language.parseValue;
}
});
Object.defineProperty(exports, 'parseType', {
enumerable: true,
get: function get() {
return _language.parseType;
}
});
Object.defineProperty(exports, 'print', {
enumerable: true,
get: function get() {
return _language.print;
}
});
Object.defineProperty(exports, 'visit', {
enumerable: true,
get: function get() {
return _language.visit;
}
});
Object.defineProperty(exports, 'visitInParallel', {
enumerable: true,
get: function get() {
return _language.visitInParallel;
}
});
Object.defineProperty(exports, 'visitWithTypeInfo', {
enumerable: true,
get: function get() {
return _language.visitWithTypeInfo;
}
});
Object.defineProperty(exports, 'Kind', {
enumerable: true,
get: function get() {
return _language.Kind;
}
});
Object.defineProperty(exports, 'TokenKind', {
enumerable: true,
get: function get() {
return _language.TokenKind;
}
});
Object.defineProperty(exports, 'BREAK', {
enumerable: true,
get: function get() {
return _language.BREAK;
}
});
var _execution = __webpack_require__(41);
Object.defineProperty(exports, 'execute', {
enumerable: true,
get: function get() {
return _execution.execute;
}
});
Object.defineProperty(exports, 'defaultFieldResolver', {
enumerable: true,
get: function get() {
return _execution.defaultFieldResolver;
}
});
Object.defineProperty(exports, 'responsePathAsArray', {
enumerable: true,
get: function get() {
return _execution.responsePathAsArray;
}
});
var _validation = __webpack_require__(55);
Object.defineProperty(exports, 'validate', {
enumerable: true,
get: function get() {
return _validation.validate;
}
});
Object.defineProperty(exports, 'ValidationContext', {
enumerable: true,
get: function get() {
return _validation.ValidationContext;
}
});
Object.defineProperty(exports, 'specifiedRules', {
enumerable: true,
get: function get() {
return _validation.specifiedRules;
}
});
var _error = __webpack_require__(0);
Object.defineProperty(exports, 'GraphQLError', {
enumerable: true,
get: function get() {
return _error.GraphQLError;
}
});
Object.defineProperty(exports, 'formatError', {
enumerable: true,
get: function get() {
return _error.formatError;
}
});
var _utilities = __webpack_require__(51);
Object.defineProperty(exports, 'introspectionQuery', {
enumerable: true,
get: function get() {
return _utilities.introspectionQuery;
}
});
Object.defineProperty(exports, 'getOperationAST', {
enumerable: true,
get: function get() {
return _utilities.getOperationAST;
}
});
Object.defineProperty(exports, 'buildClientSchema', {
enumerable: true,
get: function get() {
return _utilities.buildClientSchema;
}
});
Object.defineProperty(exports, 'buildASTSchema', {
enumerable: true,
get: function get() {
return _utilities.buildASTSchema;
}
});
Object.defineProperty(exports, 'buildSchema', {
enumerable: true,
get: function get() {
return _utilities.buildSchema;
}
});
Object.defineProperty(exports, 'extendSchema', {
enumerable: true,
get: function get() {
return _utilities.extendSchema;
}
});
Object.defineProperty(exports, 'printSchema', {
enumerable: true,
get: function get() {
return _utilities.printSchema;
}
});
Object.defineProperty(exports, 'printType', {
enumerable: true,
get: function get() {
return _utilities.printType;
}
});
Object.defineProperty(exports, 'typeFromAST', {
enumerable: true,
get: function get() {
return _utilities.typeFromAST;
}
});
Object.defineProperty(exports, 'valueFromAST', {
enumerable: true,
get: function get() {
return _utilities.valueFromAST;
}
});
Object.defineProperty(exports, 'astFromValue', {
enumerable: true,
get: function get() {
return _utilities.astFromValue;
}
});
Object.defineProperty(exports, 'TypeInfo', {
enumerable: true,
get: function get() {
return _utilities.TypeInfo;
}
});
Object.defineProperty(exports, 'isValidJSValue', {
enumerable: true,
get: function get() {
return _utilities.isValidJSValue;
}
});
Object.defineProperty(exports, 'isValidLiteralValue', {
enumerable: true,
get: function get() {
return _utilities.isValidLiteralValue;
}
});
Object.defineProperty(exports, 'concatAST', {
enumerable: true,
get: function get() {
return _utilities.concatAST;
}
});
Object.defineProperty(exports, 'separateOperations', {
enumerable: true,
get: function get() {
return _utilities.separateOperations;
}
});
Object.defineProperty(exports, 'isEqualType', {
enumerable: true,
get: function get() {
return _utilities.isEqualType;
}
});
Object.defineProperty(exports, 'isTypeSubTypeOf', {
enumerable: true,
get: function get() {
return _utilities.isTypeSubTypeOf;
}
});
Object.defineProperty(exports, 'doTypesOverlap', {
enumerable: true,
get: function get() {
return _utilities.doTypesOverlap;
}
});
Object.defineProperty(exports, 'assertValidName', {
enumerable: true,
get: function get() {
return _utilities.assertValidName;
}
});
Object.defineProperty(exports, 'findBreakingChanges', {
enumerable: true,
get: function get() {
return _utilities.findBreakingChanges;
}
});
Object.defineProperty(exports, 'findDeprecatedUsages', {
enumerable: true,
get: function get() {
return _utilities.findDeprecatedUsages;
}
});
/***/ }),
/* 37 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = __webpack_require__(36);
var hasSubscriptionOperation = function (graphQlParams) {
var queryDoc = graphql_1.parse(graphQlParams.query);
for (var _i = 0, _a = queryDoc.definitions; _i < _a.length; _i++) {
var definition = _a[_i];
if (definition.kind === 'OperationDefinition') {
var operation = definition.operation;
if (operation === 'subscription') {
return true;
}
}
}
return false;
};
exports.graphQLFetcher = function (subscriptionsClient, fallbackFetcher) {
var activeSubscriptionId = null;
return function (graphQLParams) {
if (subscriptionsClient && activeSubscriptionId !== null) {
subscriptionsClient.unsubscribe(activeSubscriptionId);
activeSubscriptionId = null;
}
if (subscriptionsClient && (hasSubscriptionOperation(graphQLParams) || (undefined === fallbackFetcher))) {
return subscriptionsClient.request({
query: graphQLParams.query,
variables: graphQLParams.variables,
operationName: graphQLParams.operationName
});
}
else {
return fallbackFetcher(graphQLParams);
}
};
};
//# sourceMappingURL=fetcher.js.map
/***/ }),
/* 38 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatError = formatError;
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Given a GraphQLError, format it according to the rules described by the
* Response Format, Errors section of the GraphQL Specification.
*/
function formatError(error) {
(0, _invariant2.default)(error, 'Received null or undefined error.');
return {
message: error.message,
locations: error.locations,
path: error.path
};
}
/**
* Copyright (c) 2015, 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.
*/
/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.locatedError = locatedError;
var _GraphQLError = __webpack_require__(13);
/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
* GraphQL operation, produce a new GraphQLError aware of the location in the
* document responsible for the original Error.
*/
function locatedError(originalError, nodes, path) {
// Note: this uses a brand-check to support GraphQL errors originating from
// other contexts.
if (originalError && originalError.path) {
return originalError;
}
var message = originalError ? originalError.message || String(originalError) : 'An unknown error occurred.';
return new _GraphQLError.GraphQLError(message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
}
/**
* Copyright (c) 2015, 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.
*/
/***/ }),
/* 40 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.syntaxError = syntaxError;
var _location = __webpack_require__(25);
var _GraphQLError = __webpack_require__(13);
/**
* Produces a GraphQLError representing a syntax error, containing useful
* descriptive information about the syntax error's position in the source.
*/
/**
* Copyright (c) 2015, 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.
*/
function syntaxError(source, position, description) {
var location = (0, _location.getLocation)(source, position);
var error = new _GraphQLError.GraphQLError('Syntax Error ' + source.name + ' (' + location.line + ':' + location.column + ') ' + description + '\n\n' + highlightSourceAtLocation(source, location), undefined, source, [position]);
return error;
}
/**
* Render a helpful description of the location of the error in the GraphQL
* Source document.
*/
function highlightSourceAtLocation(source, location) {
var line = location.line;
var prevLineNum = (line - 1).toString();
var lineNum = line.toString();
var nextLineNum = (line + 1).toString();
var padLen = nextLineNum.length;
var lines = source.body.split(/\r\n|[\n\r]/g);
return (line >= 2 ? lpad(padLen, prevLineNum) + ': ' + lines[line - 2] + '\n' : '') + lpad(padLen, lineNum) + ': ' + lines[line - 1] + '\n' + Array(2 + padLen + location.column).join(' ') + '^\n' + (line < lines.length ? lpad(padLen, nextLineNum) + ': ' + lines[line] + '\n' : '');
}
function lpad(len, str) {
return Array(len - str.length + 1).join(' ') + str;
}
/***/ }),
/* 41 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _execute = __webpack_require__(30);
Object.defineProperty(exports, 'execute', {
enumerable: true,
get: function get() {
return _execute.execute;
}
});
Object.defineProperty(exports, 'defaultFieldResolver', {
enumerable: true,
get: function get() {
return _execute.defaultFieldResolver;
}
});
Object.defineProperty(exports, 'responsePathAsArray', {
enumerable: true,
get: function get() {
return _execute.responsePathAsArray;
}
});
/***/ }),
/* 42 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.graphql = graphql;
var _source = __webpack_require__(26);
var _parser = __webpack_require__(17);
var _validate = __webpack_require__(35);
var _execute = __webpack_require__(30);
/**
* This is the primary entry point function for fulfilling GraphQL operations
* by parsing, validating, and executing a GraphQL document along side a
* GraphQL schema.
*
* More sophisticated GraphQL servers, such as those which persist queries,
* may wish to separate the validation and execution phases to a static time
* tooling step, and a server runtime step.
*
* schema:
* The GraphQL type system to use when validating and executing a query.
* requestString:
* A GraphQL language formatted string representing the requested operation.
* rootValue:
* The value provided as the first argument to resolver functions on the top
* level type (e.g. the query object type).
* variableValues:
* A mapping of variable name to runtime value to use for all variables
* defined in the requestString.
* operationName:
* The name of the operation to use if requestString contains multiple
* possible operations. Can be omitted if requestString contains only
* one operation.
*/
/**
* Copyright (c) 2015, 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.
*/
function graphql(schema, requestString, rootValue, contextValue, variableValues, operationName) {
return new Promise(function (resolve) {
var source = new _source.Source(requestString || '', 'GraphQL request');
var documentAST = (0, _parser.parse)(source);
var validationErrors = (0, _validate.validate)(schema, documentAST);
if (validationErrors.length > 0) {
resolve({ errors: validationErrors });
} else {
resolve((0, _execute.execute)(schema, documentAST, rootValue, contextValue, variableValues, operationName));
}
}).then(undefined, function (error) {
return { errors: [error] };
});
}
/***/ }),
/* 43 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BREAK = exports.visitWithTypeInfo = exports.visitInParallel = exports.visit = exports.Source = exports.print = exports.parseType = exports.parseValue = exports.parse = exports.TokenKind = exports.createLexer = exports.Kind = exports.getLocation = undefined;
var _location = __webpack_require__(25);
Object.defineProperty(exports, 'getLocation', {
enumerable: true,
get: function get() {
return _location.getLocation;
}
});
var _lexer = __webpack_require__(24);
Object.defineProperty(exports, 'createLexer', {
enumerable: true,
get: function get() {
return _lexer.createLexer;
}
});
Object.defineProperty(exports, 'TokenKind', {
enumerable: true,
get: function get() {
return _lexer.TokenKind;
}
});
var _parser = __webpack_require__(17);
Object.defineProperty(exports, 'parse', {
enumerable: true,
get: function get() {
return _parser.parse;
}
});
Object.defineProperty(exports, 'parseValue', {
enumerable: true,
get: function get() {
return _parser.parseValue;
}
});
Object.defineProperty(exports, 'parseType', {
enumerable: true,
get: function get() {
return _parser.parseType;
}
});
var _printer = __webpack_require__(4);
Object.defineProperty(exports, 'print', {
enumerable: true,
get: function get() {
return _printer.print;
}
});
var _source = __webpack_require__(26);
Object.defineProperty(exports, 'Source', {
enumerable: true,
get: function get() {
return _source.Source;
}
});
var _visitor = __webpack_require__(15);
Object.defineProperty(exports, 'visit', {
enumerable: true,
get: function get() {
return _visitor.visit;
}
});
Object.defineProperty(exports, 'visitInParallel', {
enumerable: true,
get: function get() {
return _visitor.visitInParallel;
}
});
Object.defineProperty(exports, 'visitWithTypeInfo', {
enumerable: true,
get: function get() {
return _visitor.visitWithTypeInfo;
}
});
Object.defineProperty(exports, 'BREAK', {
enumerable: true,
get: function get() {
return _visitor.BREAK;
}
});
var _kinds = __webpack_require__(2);
var Kind = _interopRequireWildcard(_kinds);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
exports.Kind = Kind;
/***/ }),
/* 44 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _schema = __webpack_require__(8);
Object.defineProperty(exports, 'GraphQLSchema', {
enumerable: true,
get: function get() {
return _schema.GraphQLSchema;
}
});
var _definition = __webpack_require__(1);
Object.defineProperty(exports, 'isType', {
enumerable: true,
get: function get() {
return _definition.isType;
}
});
Object.defineProperty(exports, 'isInputType', {
enumerable: true,
get: function get() {
return _definition.isInputType;
}
});
Object.defineProperty(exports, 'isOutputType', {
enumerable: true,
get: function get() {
return _definition.isOutputType;
}
});
Object.defineProperty(exports, 'isLeafType', {
enumerable: true,
get: function get() {
return _definition.isLeafType;
}
});
Object.defineProperty(exports, 'isCompositeType', {
enumerable: true,
get: function get() {
return _definition.isCompositeType;
}
});
Object.defineProperty(exports, 'isAbstractType', {
enumerable: true,
get: function get() {
return _definition.isAbstractType;
}
});
Object.defineProperty(exports, 'isNamedType', {
enumerable: true,
get: function get() {
return _definition.isNamedType;
}
});
Object.defineProperty(exports, 'assertType', {
enumerable: true,
get: function get() {
return _definition.assertType;
}
});
Object.defineProperty(exports, 'assertInputType', {
enumerable: true,
get: function get() {
return _definition.assertInputType;
}
});
Object.defineProperty(exports, 'assertOutputType', {
enumerable: true,
get: function get() {
return _definition.assertOutputType;
}
});
Object.defineProperty(exports, 'assertLeafType', {
enumerable: true,
get: function get() {
return _definition.assertLeafType;
}
});
Object.defineProperty(exports, 'assertCompositeType', {
enumerable: true,
get: function get() {
return _definition.assertCompositeType;
}
});
Object.defineProperty(exports, 'assertAbstractType', {
enumerable: true,
get: function get() {
return _definition.assertAbstractType;
}
});
Object.defineProperty(exports, 'assertNamedType', {
enumerable: true,
get: function get() {
return _definition.assertNamedType;
}
});
Object.defineProperty(exports, 'getNullableType', {
enumerable: true,
get: function get() {
return _definition.getNullableType;
}
});
Object.defineProperty(exports, 'getNamedType', {
enumerable: true,
get: function get() {
return _definition.getNamedType;
}
});
Object.defineProperty(exports, 'GraphQLScalarType', {
enumerable: true,
get: function get() {
return _definition.GraphQLScalarType;
}
});
Object.defineProperty(exports, 'GraphQLObjectType', {
enumerable: true,
get: function get() {
return _definition.GraphQLObjectType;
}
});
Object.defineProperty(exports, 'GraphQLInterfaceType', {
enumerable: true,
get: function get() {
return _definition.GraphQLInterfaceType;
}
});
Object.defineProperty(exports, 'GraphQLUnionType', {
enumerable: true,
get: function get() {
return _definition.GraphQLUnionType;
}
});
Object.defineProperty(exports, 'GraphQLEnumType', {
enumerable: true,
get: function get() {
return _definition.GraphQLEnumType;
}
});
Object.defineProperty(exports, 'GraphQLInputObjectType', {
enumerable: true,
get: function get() {
return _definition.GraphQLInputObjectType;
}
});
Object.defineProperty(exports, 'GraphQLList', {
enumerable: true,
get: function get() {
return _definition.GraphQLList;
}
});
Object.defineProperty(exports, 'GraphQLNonNull', {
enumerable: true,
get: function get() {
return _definition.GraphQLNonNull;
}
});
var _directives = __webpack_require__(5);
Object.defineProperty(exports, 'DirectiveLocation', {
enumerable: true,
get: function get() {
return _directives.DirectiveLocation;
}
});
Object.defineProperty(exports, 'GraphQLDirective', {
enumerable: true,
get: function get() {
return _directives.GraphQLDirective;
}
});
Object.defineProperty(exports, 'specifiedDirectives', {
enumerable: true,
get: function get() {
return _directives.specifiedDirectives;
}
});
Object.defineProperty(exports, 'GraphQLIncludeDirective', {
enumerable: true,
get: function get() {
return _directives.GraphQLIncludeDirective;
}
});
Object.defineProperty(exports, 'GraphQLSkipDirective', {
enumerable: true,
get: function get() {
return _directives.GraphQLSkipDirective;
}
});
Object.defineProperty(exports, 'GraphQLDeprecatedDirective', {
enumerable: true,
get: function get() {
return _directives.GraphQLDeprecatedDirective;
}
});
Object.defineProperty(exports, 'DEFAULT_DEPRECATION_REASON', {
enumerable: true,
get: function get() {
return _directives.DEFAULT_DEPRECATION_REASON;
}
});
var _scalars = __webpack_require__(7);
Object.defineProperty(exports, 'GraphQLInt', {
enumerable: true,
get: function get() {
return _scalars.GraphQLInt;
}
});
Object.defineProperty(exports, 'GraphQLFloat', {
enumerable: true,
get: function get() {
return _scalars.GraphQLFloat;
}
});
Object.defineProperty(exports, 'GraphQLString', {
enumerable: true,
get: function get() {
return _scalars.GraphQLString;
}
});
Object.defineProperty(exports, 'GraphQLBoolean', {
enumerable: true,
get: function get() {
return _scalars.GraphQLBoolean;
}
});
Object.defineProperty(exports, 'GraphQLID', {
enumerable: true,
get: function get() {
return _scalars.GraphQLID;
}
});
var _introspection = __webpack_require__(11);
Object.defineProperty(exports, 'TypeKind', {
enumerable: true,
get: function get() {
return _introspection.TypeKind;
}
});
Object.defineProperty(exports, '__Schema', {
enumerable: true,
get: function get() {
return _introspection.__Schema;
}
});
Object.defineProperty(exports, '__Directive', {
enumerable: true,
get: function get() {
return _introspection.__Directive;
}
});
Object.defineProperty(exports, '__DirectiveLocation', {
enumerable: true,
get: function get() {
return _introspection.__DirectiveLocation;
}
});
Object.defineProperty(exports, '__Type', {
enumerable: true,
get: function get() {
return _introspection.__Type;
}
});
Object.defineProperty(exports, '__Field', {
enumerable: true,
get: function get() {
return _introspection.__Field;
}
});
Object.defineProperty(exports, '__InputValue', {
enumerable: true,
get: function get() {
return _introspection.__InputValue;
}
});
Object.defineProperty(exports, '__EnumValue', {
enumerable: true,
get: function get() {
return _introspection.__EnumValue;
}
});
Object.defineProperty(exports, '__TypeKind', {
enumerable: true,
get: function get() {
return _introspection.__TypeKind;
}
});
Object.defineProperty(exports, 'SchemaMetaFieldDef', {
enumerable: true,
get: function get() {
return _introspection.SchemaMetaFieldDef;
}
});
Object.defineProperty(exports, 'TypeMetaFieldDef', {
enumerable: true,
get: function get() {
return _introspection.TypeMetaFieldDef;
}
});
Object.defineProperty(exports, 'TypeNameMetaFieldDef', {
enumerable: true,
get: function get() {
return _introspection.TypeNameMetaFieldDef;
}
});
/***/ }),
/* 45 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildClientSchema = buildClientSchema;
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _keyMap = __webpack_require__(12);
var _keyMap2 = _interopRequireDefault(_keyMap);
var _keyValMap = __webpack_require__(21);
var _keyValMap2 = _interopRequireDefault(_keyValMap);
var _valueFromAST = __webpack_require__(16);
var _parser = __webpack_require__(17);
var _schema = __webpack_require__(8);
var _definition = __webpack_require__(1);
var _introspection = __webpack_require__(11);
var _scalars = __webpack_require__(7);
var _directives = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Build a GraphQLSchema for use by client tools.
*
* Given the result of a client running the introspection query, creates and
* returns a GraphQLSchema instance which can be then used with all graphql-js
* tools, but cannot be used to execute a query, as introspection does not
* represent the "resolver", "parse" or "serialize" functions or any other
* server-internal mechanisms.
*/
function buildClientSchema(introspection) {
// Get the schema from the introspection result.
var schemaIntrospection = introspection.__schema;
// Converts the list of types into a keyMap based on the type names.
var typeIntrospectionMap = (0, _keyMap2.default)(schemaIntrospection.types, function (type) {
return type.name;
});
// A cache to use to store the actual GraphQLType definition objects by name.
// Initialize to the GraphQL built in scalars. All functions below are inline
// so that this type def cache is within the scope of the closure.
var typeDefCache = {
String: _scalars.GraphQLString,
Int: _scalars.GraphQLInt,
Float: _scalars.GraphQLFloat,
Boolean: _scalars.GraphQLBoolean,
ID: _scalars.GraphQLID,
__Schema: _introspection.__Schema,
__Directive: _introspection.__Directive,
__DirectiveLocation: _introspection.__DirectiveLocation,
__Type: _introspection.__Type,
__Field: _introspection.__Field,
__InputValue: _introspection.__InputValue,
__EnumValue: _introspection.__EnumValue,
__TypeKind: _introspection.__TypeKind
};
// Given a type reference in introspection, return the GraphQLType instance.
// preferring cached instances before building new instances.
function getType(typeRef) {
if (typeRef.kind === _introspection.TypeKind.LIST) {
var itemRef = typeRef.ofType;
if (!itemRef) {
throw new Error('Decorated type deeper than introspection query.');
}
return new _definition.GraphQLList(getType(itemRef));
}
if (typeRef.kind === _introspection.TypeKind.NON_NULL) {
var nullableRef = typeRef.ofType;
if (!nullableRef) {
throw new Error('Decorated type deeper than introspection query.');
}
var nullableType = getType(nullableRef);
(0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'No nesting nonnull.');
return new _definition.GraphQLNonNull(nullableType);
}
return getNamedType(typeRef.name);
}
function getNamedType(typeName) {
if (typeDefCache[typeName]) {
return typeDefCache[typeName];
}
var typeIntrospection = typeIntrospectionMap[typeName];
if (!typeIntrospection) {
throw new Error('Invalid or incomplete schema, unknown type: ' + typeName + '. Ensure ' + 'that a full introspection query is used in order to build a ' + 'client schema.');
}
var typeDef = buildType(typeIntrospection);
typeDefCache[typeName] = typeDef;
return typeDef;
}
function getInputType(typeRef) {
var type = getType(typeRef);
(0, _invariant2.default)((0, _definition.isInputType)(type), 'Introspection must provide input type for arguments.');
return type;
}
function getOutputType(typeRef) {
var type = getType(typeRef);
(0, _invariant2.default)((0, _definition.isOutputType)(type), 'Introspection must provide output type for fields.');
return type;
}
function getObjectType(typeRef) {
var type = getType(typeRef);
(0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Introspection must provide object type for possibleTypes.');
return type;
}
function getInterfaceType(typeRef) {
var type = getType(typeRef);
(0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Introspection must provide interface type for interfaces.');
return type;
}
// Given a type's introspection result, construct the correct
// GraphQLType instance.
function buildType(type) {
switch (type.kind) {
case _introspection.TypeKind.SCALAR:
return buildScalarDef(type);
case _introspection.TypeKind.OBJECT:
return buildObjectDef(type);
case _introspection.TypeKind.INTERFACE:
return buildInterfaceDef(type);
case _introspection.TypeKind.UNION:
return buildUnionDef(type);
case _introspection.TypeKind.ENUM:
return buildEnumDef(type);
case _introspection.TypeKind.INPUT_OBJECT:
return buildInputObjectDef(type);
default:
throw new Error('Invalid or incomplete schema, unknown kind: ' + type.kind + '. Ensure ' + 'that a full introspection query is used in order to build a ' + 'client schema.');
}
}
function buildScalarDef(scalarIntrospection) {
return new _definition.GraphQLScalarType({
name: scalarIntrospection.name,
description: scalarIntrospection.description,
serialize: function serialize(id) {
return id;
},
// Note: validation calls the parse functions to determine if a
// literal value is correct. Returning null would cause use of custom
// scalars to always fail validation. Returning false causes them to
// always pass validation.
parseValue: function parseValue() {
return false;
},
parseLiteral: function parseLiteral() {
return false;
}
});
}
function buildObjectDef(objectIntrospection) {
return new _definition.GraphQLObjectType({
name: objectIntrospection.name,
description: objectIntrospection.description,
interfaces: objectIntrospection.interfaces.map(getInterfaceType),
fields: function fields() {
return buildFieldDefMap(objectIntrospection);
}
});
}
function buildInterfaceDef(interfaceIntrospection) {
return new _definition.GraphQLInterfaceType({
name: interfaceIntrospection.name,
description: interfaceIntrospection.description,
fields: function fields() {
return buildFieldDefMap(interfaceIntrospection);
},
resolveType: cannotExecuteClientSchema
});
}
function buildUnionDef(unionIntrospection) {
return new _definition.GraphQLUnionType({
name: unionIntrospection.name,
description: unionIntrospection.description,
types: unionIntrospection.possibleTypes.map(getObjectType),
resolveType: cannotExecuteClientSchema
});
}
function buildEnumDef(enumIntrospection) {
return new _definition.GraphQLEnumType({
name: enumIntrospection.name,
description: enumIntrospection.description,
values: (0, _keyValMap2.default)(enumIntrospection.enumValues, function (valueIntrospection) {
return valueIntrospection.name;
}, function (valueIntrospection) {
return {
description: valueIntrospection.description,
deprecationReason: valueIntrospection.deprecationReason
};
})
});
}
function buildInputObjectDef(inputObjectIntrospection) {
return new _definition.GraphQLInputObjectType({
name: inputObjectIntrospection.name,
description: inputObjectIntrospection.description,
fields: function fields() {
return buildInputValueDefMap(inputObjectIntrospection.inputFields);
}
});
}
function buildFieldDefMap(typeIntrospection) {
return (0, _keyValMap2.default)(typeIntrospection.fields, function (fieldIntrospection) {
return fieldIntrospection.name;
}, function (fieldIntrospection) {
return {
description: fieldIntrospection.description,
deprecationReason: fieldIntrospection.deprecationReason,
type: getOutputType(fieldIntrospection.type),
args: buildInputValueDefMap(fieldIntrospection.args)
};
});
}
function buildInputValueDefMap(inputValueIntrospections) {
return (0, _keyValMap2.default)(inputValueIntrospections, function (inputValue) {
return inputValue.name;
}, buildInputValue);
}
function buildInputValue(inputValueIntrospection) {
var type = getInputType(inputValueIntrospection.type);
var defaultValue = inputValueIntrospection.defaultValue ? (0, _valueFromAST.valueFromAST)((0, _parser.parseValue)(inputValueIntrospection.defaultValue), type) : undefined;
return {
name: inputValueIntrospection.name,
description: inputValueIntrospection.description,
type: type,
defaultValue: defaultValue
};
}
function buildDirective(directiveIntrospection) {
// Support deprecated `on****` fields for building `locations`, as this
// is used by GraphiQL which may need to support outdated servers.
var locations = directiveIntrospection.locations ? directiveIntrospection.locations.slice() : [].concat(!directiveIntrospection.onField ? [] : [_directives.DirectiveLocation.FIELD], !directiveIntrospection.onOperation ? [] : [_directives.DirectiveLocation.QUERY, _directives.DirectiveLocation.MUTATION, _directives.DirectiveLocation.SUBSCRIPTION], !directiveIntrospection.onFragment ? [] : [_directives.DirectiveLocation.FRAGMENT_DEFINITION, _directives.DirectiveLocation.FRAGMENT_SPREAD, _directives.DirectiveLocation.INLINE_FRAGMENT]);
return new _directives.GraphQLDirective({
name: directiveIntrospection.name,
description: directiveIntrospection.description,
locations: locations,
args: buildInputValueDefMap(directiveIntrospection.args)
});
}
// Iterate through all types, getting the type definition for each, ensuring
// that any type not directly referenced by a field will get created.
var types = schemaIntrospection.types.map(function (typeIntrospection) {
return getNamedType(typeIntrospection.name);
});
// Get the root Query, Mutation, and Subscription types.
var queryType = getObjectType(schemaIntrospection.queryType);
var mutationType = schemaIntrospection.mutationType ? getObjectType(schemaIntrospection.mutationType) : null;
var subscriptionType = schemaIntrospection.subscriptionType ? getObjectType(schemaIntrospection.subscriptionType) : null;
// Get the directives supported by Introspection, assuming empty-set if
// directives were not queried for.
var directives = schemaIntrospection.directives ? schemaIntrospection.directives.map(buildDirective) : [];
// Then produce and return a Schema with these types.
return new _schema.GraphQLSchema({
query: queryType,
mutation: mutationType,
subscription: subscriptionType,
types: types,
directives: directives
});
}
/**
* Copyright (c) 2015, 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.
*/
function cannotExecuteClientSchema() {
throw new Error('Client Schema cannot use Interface or Union types for execution.');
}
/***/ }),
/* 46 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.concatAST = concatAST;
/**
* Provided a collection of ASTs, presumably each from different files,
* concatenate the ASTs together into batched AST, useful for validating many
* GraphQL source files which together represent one conceptual application.
*/
function concatAST(asts) {
var batchDefinitions = [];
for (var i = 0; i < asts.length; i++) {
var definitions = asts[i].definitions;
for (var j = 0; j < definitions.length; j++) {
batchDefinitions.push(definitions[j]);
}
}
return {
kind: 'Document',
definitions: batchDefinitions
};
}
/**
* Copyright (c) 2015, 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.
*/
/***/ }),
/* 47 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.extendSchema = extendSchema;
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _keyMap = __webpack_require__(12);
var _keyMap2 = _interopRequireDefault(_keyMap);
var _keyValMap = __webpack_require__(21);
var _keyValMap2 = _interopRequireDefault(_keyValMap);
var _buildASTSchema = __webpack_require__(32);
var _valueFromAST = __webpack_require__(16);
var _GraphQLError = __webpack_require__(13);
var _schema = __webpack_require__(8);
var _definition = __webpack_require__(1);
var _directives = __webpack_require__(5);
var _introspection = __webpack_require__(11);
var _scalars = __webpack_require__(7);
var _kinds = __webpack_require__(2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Produces a new schema given an existing schema and a document which may
* contain GraphQL type extensions and definitions. The original schema will
* remain unaltered.
*
* Because a schema represents a graph of references, a schema cannot be
* extended without effectively making an entire copy. We do not know until it's
* too late if subgraphs remain unchanged.
*
* This algorithm copies the provided schema, applying extensions while
* producing the copy. The original schema remains unaltered.
*/
/**
* Copyright (c) 2015, 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.
*/
function extendSchema(schema, documentAST) {
(0, _invariant2.default)(schema instanceof _schema.GraphQLSchema, 'Must provide valid GraphQLSchema');
(0, _invariant2.default)(documentAST && documentAST.kind === _kinds.DOCUMENT, 'Must provide valid Document AST');
// Collect the type definitions and extensions found in the document.
var typeDefinitionMap = {};
var typeExtensionsMap = {};
// New directives and types are separate because a directives and types can
// have the same name. For example, a type named "skip".
var directiveDefinitions = [];
for (var i = 0; i < documentAST.definitions.length; i++) {
var def = documentAST.definitions[i];
switch (def.kind) {
case _kinds.OBJECT_TYPE_DEFINITION:
case _kinds.INTERFACE_TYPE_DEFINITION:
case _kinds.ENUM_TYPE_DEFINITION:
case _kinds.UNION_TYPE_DEFINITION:
case _kinds.SCALAR_TYPE_DEFINITION:
case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
// Sanity check that none of the defined types conflict with the
// schema's existing types.
var typeName = def.name.value;
if (schema.getType(typeName)) {
throw new _GraphQLError.GraphQLError('Type "' + typeName + '" already exists in the schema. It cannot also ' + 'be defined in this type definition.', [def]);
}
typeDefinitionMap[typeName] = def;
break;
case _kinds.TYPE_EXTENSION_DEFINITION:
// Sanity check that this type extension exists within the
// schema's existing types.
var extendedTypeName = def.definition.name.value;
var existingType = schema.getType(extendedTypeName);
if (!existingType) {
throw new _GraphQLError.GraphQLError('Cannot extend type "' + extendedTypeName + '" because it does not ' + 'exist in the existing schema.', [def.definition]);
}
if (!(existingType instanceof _definition.GraphQLObjectType)) {
throw new _GraphQLError.GraphQLError('Cannot extend non-object type "' + extendedTypeName + '".', [def.definition]);
}
var extensions = typeExtensionsMap[extendedTypeName];
if (extensions) {
extensions.push(def);
} else {
extensions = [def];
}
typeExtensionsMap[extendedTypeName] = extensions;
break;
case _kinds.DIRECTIVE_DEFINITION:
var directiveName = def.name.value;
var existingDirective = schema.getDirective(directiveName);
if (existingDirective) {
throw new _GraphQLError.GraphQLError('Directive "' + directiveName + '" already exists in the schema. It ' + 'cannot be redefined.', [def]);
}
directiveDefinitions.push(def);
break;
}
}
// If this document contains no new types, extensions, or directives then
// return the same unmodified GraphQLSchema instance.
if (Object.keys(typeExtensionsMap).length === 0 && Object.keys(typeDefinitionMap).length === 0 && directiveDefinitions.length === 0) {
return schema;
}
// A cache to use to store the actual GraphQLType definition objects by name.
// Initialize to the GraphQL built in scalars and introspection types. All
// functions below are inline so that this type def cache is within the scope
// of the closure.
var typeDefCache = {
String: _scalars.GraphQLString,
Int: _scalars.GraphQLInt,
Float: _scalars.GraphQLFloat,
Boolean: _scalars.GraphQLBoolean,
ID: _scalars.GraphQLID,
__Schema: _introspection.__Schema,
__Directive: _introspection.__Directive,
__DirectiveLocation: _introspection.__DirectiveLocation,
__Type: _introspection.__Type,
__Field: _introspection.__Field,
__InputValue: _introspection.__InputValue,
__EnumValue: _introspection.__EnumValue,
__TypeKind: _introspection.__TypeKind
};
// Get the root Query, Mutation, and Subscription object types.
var queryType = getTypeFromDef(schema.getQueryType());
var existingMutationType = schema.getMutationType();
var mutationType = existingMutationType ? getTypeFromDef(existingMutationType) : null;
var existingSubscriptionType = schema.getSubscriptionType();
var subscriptionType = existingSubscriptionType ? getTypeFromDef(existingSubscriptionType) : null;
// Iterate through all types, getting the type definition for each, ensuring
// that any type not directly referenced by a field will get created.
var typeMap = schema.getTypeMap();
var types = Object.keys(typeMap).map(function (typeName) {
return getTypeFromDef(typeMap[typeName]);
});
// Do the same with new types, appending to the list of defined types.
Object.keys(typeDefinitionMap).forEach(function (typeName) {
types.push(getTypeFromAST(typeDefinitionMap[typeName]));
});
// Then produce and return a Schema with these types.
return new _schema.GraphQLSchema({
query: queryType,
mutation: mutationType,
subscription: subscriptionType,
types: types,
directives: getMergedDirectives()
});
// Below are functions used for producing this schema that have closed over
// this scope and have access to the schema, cache, and newly defined types.
function getMergedDirectives() {
var existingDirectives = schema.getDirectives();
(0, _invariant2.default)(existingDirectives, 'schema must have default directives');
var newDirectives = directiveDefinitions.map(function (directiveNode) {
return getDirective(directiveNode);
});
return existingDirectives.concat(newDirectives);
}
function getTypeFromDef(typeDef) {
var type = _getNamedType(typeDef.name);
(0, _invariant2.default)(type, 'Missing type from schema');
return type;
}
function getTypeFromAST(node) {
var type = _getNamedType(node.name.value);
if (!type) {
throw new _GraphQLError.GraphQLError('Unknown type: "' + node.name.value + '". Ensure that this type exists ' + 'either in the original schema, or is added in a type definition.', [node]);
}
return type;
}
function getObjectTypeFromAST(node) {
var type = getTypeFromAST(node);
(0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Must be Object type.');
return type;
}
function getInterfaceTypeFromAST(node) {
var type = getTypeFromAST(node);
(0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Must be Interface type.');
return type;
}
function getInputTypeFromAST(node) {
var type = getTypeFromAST(node);
(0, _invariant2.default)((0, _definition.isInputType)(type), 'Must be Input type.');
return type;
}
function getOutputTypeFromAST(node) {
var type = getTypeFromAST(node);
(0, _invariant2.default)((0, _definition.isOutputType)(type), 'Must be Output type.');
return type;
}
// Given a name, returns a type from either the existing schema or an
// added type.
function _getNamedType(typeName) {
var cachedTypeDef = typeDefCache[typeName];
if (cachedTypeDef) {
return cachedTypeDef;
}
var existingType = schema.getType(typeName);
if (existingType) {
var typeDef = extendType(existingType);
typeDefCache[typeName] = typeDef;
return typeDef;
}
var typeNode = typeDefinitionMap[typeName];
if (typeNode) {
var _typeDef = buildType(typeNode);
typeDefCache[typeName] = _typeDef;
return _typeDef;
}
}
// Given a type's introspection result, construct the correct
// GraphQLType instance.
function extendType(type) {
if (type instanceof _definition.GraphQLObjectType) {
return extendObjectType(type);
}
if (type instanceof _definition.GraphQLInterfaceType) {
return extendInterfaceType(type);
}
if (type instanceof _definition.GraphQLUnionType) {
return extendUnionType(type);
}
return type;
}
function extendObjectType(type) {
return new _definition.GraphQLObjectType({
name: type.name,
description: type.description,
interfaces: function interfaces() {
return extendImplementedInterfaces(type);
},
fields: function fields() {
return extendFieldMap(type);
},
isTypeOf: type.isTypeOf
});
}
function extendInterfaceType(type) {
return new _definition.GraphQLInterfaceType({
name: type.name,
description: type.description,
fields: function fields() {
return extendFieldMap(type);
},
resolveType: type.resolveType
});
}
function extendUnionType(type) {
return new _definition.GraphQLUnionType({
name: type.name,
description: type.description,
types: type.getTypes().map(getTypeFromDef),
resolveType: type.resolveType
});
}
function extendImplementedInterfaces(type) {
var interfaces = type.getInterfaces().map(getTypeFromDef);
// If there are any extensions to the interfaces, apply those here.
var extensions = typeExtensionsMap[type.name];
if (extensions) {
extensions.forEach(function (extension) {
extension.definition.interfaces.forEach(function (namedType) {
var interfaceName = namedType.name.value;
if (interfaces.some(function (def) {
return def.name === interfaceName;
})) {
throw new _GraphQLError.GraphQLError('Type "' + type.name + '" already implements "' + interfaceName + '". ' + 'It cannot also be implemented in this type extension.', [namedType]);
}
interfaces.push(getInterfaceTypeFromAST(namedType));
});
});
}
return interfaces;
}
function extendFieldMap(type) {
var newFieldMap = {};
var oldFieldMap = type.getFields();
Object.keys(oldFieldMap).forEach(function (fieldName) {
var field = oldFieldMap[fieldName];
newFieldMap[fieldName] = {
description: field.description,
deprecationReason: field.deprecationReason,
type: extendFieldType(field.type),
args: (0, _keyMap2.default)(field.args, function (arg) {
return arg.name;
}),
resolve: field.resolve
};
});
// If there are any extensions to the fields, apply those here.
var extensions = typeExtensionsMap[type.name];
if (extensions) {
extensions.forEach(function (extension) {
extension.definition.fields.forEach(function (field) {
var fieldName = field.name.value;
if (oldFieldMap[fieldName]) {
throw new _GraphQLError.GraphQLError('Field "' + type.name + '.' + fieldName + '" already exists in the ' + 'schema. It cannot also be defined in this type extension.', [field]);
}
newFieldMap[fieldName] = {
description: (0, _buildASTSchema.getDescription)(field),
type: buildOutputFieldType(field.type),
args: buildInputValues(field.arguments)
};
});
});
}
return newFieldMap;
}
function extendFieldType(typeDef) {
if (typeDef instanceof _definition.GraphQLList) {
return new _definition.GraphQLList(extendFieldType(typeDef.ofType));
}
if (typeDef instanceof _definition.GraphQLNonNull) {
return new _definition.GraphQLNonNull(extendFieldType(typeDef.ofType));
}
return getTypeFromDef(typeDef);
}
function buildType(typeNode) {
switch (typeNode.kind) {
case _kinds.OBJECT_TYPE_DEFINITION:
return buildObjectType(typeNode);
case _kinds.INTERFACE_TYPE_DEFINITION:
return buildInterfaceType(typeNode);
case _kinds.UNION_TYPE_DEFINITION:
return buildUnionType(typeNode);
case _kinds.SCALAR_TYPE_DEFINITION:
return buildScalarType(typeNode);
case _kinds.ENUM_TYPE_DEFINITION:
return buildEnumType(typeNode);
case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
return buildInputObjectType(typeNode);
}
throw new TypeError('Unknown type kind ' + typeNode.kind);
}
function buildObjectType(typeNode) {
return new _definition.GraphQLObjectType({
name: typeNode.name.value,
description: (0, _buildASTSchema.getDescription)(typeNode),
interfaces: function interfaces() {
return buildImplementedInterfaces(typeNode);
},
fields: function fields() {
return buildFieldMap(typeNode);
}
});
}
function buildInterfaceType(typeNode) {
return new _definition.GraphQLInterfaceType({
name: typeNode.name.value,
description: (0, _buildASTSchema.getDescription)(typeNode),
fields: function fields() {
return buildFieldMap(typeNode);
},
resolveType: cannotExecuteExtendedSchema
});
}
function buildUnionType(typeNode) {
return new _definition.GraphQLUnionType({
name: typeNode.name.value,
description: (0, _buildASTSchema.getDescription)(typeNode),
types: typeNode.types.map(getObjectTypeFromAST),
resolveType: cannotExecuteExtendedSchema
});
}
function buildScalarType(typeNode) {
return new _definition.GraphQLScalarType({
name: typeNode.name.value,
description: (0, _buildASTSchema.getDescription)(typeNode),
serialize: function serialize(id) {
return id;
},
// Note: validation calls the parse functions to determine if a
// literal value is correct. Returning null would cause use of custom
// scalars to always fail validation. Returning false causes them to
// always pass validation.
parseValue: function parseValue() {
return false;
},
parseLiteral: function parseLiteral() {
return false;
}
});
}
function buildEnumType(typeNode) {
return new _definition.GraphQLEnumType({
name: typeNode.name.value,
description: (0, _buildASTSchema.getDescription)(typeNode),
values: (0, _keyValMap2.default)(typeNode.values, function (v) {
return v.name.value;
}, function () {
return {};
})
});
}
function buildInputObjectType(typeNode) {
return new _definition.GraphQLInputObjectType({
name: typeNode.name.value,
description: (0, _buildASTSchema.getDescription)(typeNode),
fields: function fields() {
return buildInputValues(typeNode.fields);
}
});
}
function getDirective(directiveNode) {
return new _directives.GraphQLDirective({
name: directiveNode.name.value,
locations: directiveNode.locations.map(function (node) {
return node.value;
}),
args: directiveNode.arguments && buildInputValues(directiveNode.arguments)
});
}
function buildImplementedInterfaces(typeNode) {
return typeNode.interfaces && typeNode.interfaces.map(getInterfaceTypeFromAST);
}
function buildFieldMap(typeNode) {
return (0, _keyValMap2.default)(typeNode.fields, function (field) {
return field.name.value;
}, function (field) {
return {
type: buildOutputFieldType(field.type),
description: (0, _buildASTSchema.getDescription)(field),
args: buildInputValues(field.arguments)
};
});
}
function buildInputValues(values) {
return (0, _keyValMap2.default)(values, function (value) {
return value.name.value;
}, function (value) {
var type = buildInputFieldType(value.type);
return {
type: type,
description: (0, _buildASTSchema.getDescription)(value),
defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type)
};
});
}
function buildInputFieldType(typeNode) {
if (typeNode.kind === _kinds.LIST_TYPE) {
return new _definition.GraphQLList(buildInputFieldType(typeNode.type));
}
if (typeNode.kind === _kinds.NON_NULL_TYPE) {
var nullableType = buildInputFieldType(typeNode.type);
(0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'Must be nullable');
return new _definition.GraphQLNonNull(nullableType);
}
return getInputTypeFromAST(typeNode);
}
function buildOutputFieldType(typeNode) {
if (typeNode.kind === _kinds.LIST_TYPE) {
return new _definition.GraphQLList(buildOutputFieldType(typeNode.type));
}
if (typeNode.kind === _kinds.NON_NULL_TYPE) {
var nullableType = buildOutputFieldType(typeNode.type);
(0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'Must be nullable');
return new _definition.GraphQLNonNull(nullableType);
}
return getOutputTypeFromAST(typeNode);
}
}
function cannotExecuteExtendedSchema() {
throw new Error('Extended Schema cannot use Interface or Union types for execution.');
}
/***/ }),
/* 48 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BreakingChangeType = undefined;
exports.findBreakingChanges = findBreakingChanges;
exports.findRemovedTypes = findRemovedTypes;
exports.findTypesThatChangedKind = findTypesThatChangedKind;
exports.findFieldsThatChangedType = findFieldsThatChangedType;
exports.findTypesRemovedFromUnions = findTypesRemovedFromUnions;
exports.findValuesRemovedFromEnums = findValuesRemovedFromEnums;
var _definition = __webpack_require__(1);
var _schema = __webpack_require__(8);
/**
* Copyright (c) 2016, 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.
*/
var BreakingChangeType = exports.BreakingChangeType = {
FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND',
FIELD_REMOVED: 'FIELD_REMOVED',
TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND',
TYPE_REMOVED: 'TYPE_REMOVED',
TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION',
VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM'
};
/**
* Given two schemas, returns an Array containing descriptions of all the types
* of breaking changes covered by the other functions down below.
*/
function findBreakingChanges(oldSchema, newSchema) {
return [].concat(findRemovedTypes(oldSchema, newSchema), findTypesThatChangedKind(oldSchema, newSchema), findFieldsThatChangedType(oldSchema, newSchema), findTypesRemovedFromUnions(oldSchema, newSchema), findValuesRemovedFromEnums(oldSchema, newSchema));
}
/**
* Given two schemas, returns an Array containing descriptions of any breaking
* changes in the newSchema related to removing an entire type.
*/
function findRemovedTypes(oldSchema, newSchema) {
var oldTypeMap = oldSchema.getTypeMap();
var newTypeMap = newSchema.getTypeMap();
var breakingChanges = [];
Object.keys(oldTypeMap).forEach(function (typeName) {
if (!newTypeMap[typeName]) {
breakingChanges.push({
type: BreakingChangeType.TYPE_REMOVED,
description: typeName + ' was removed.'
});
}
});
return breakingChanges;
}
/**
* Given two schemas, returns an Array containing descriptions of any breaking
* changes in the newSchema related to changing the type of a type.
*/
function findTypesThatChangedKind(oldSchema, newSchema) {
var oldTypeMap = oldSchema.getTypeMap();
var newTypeMap = newSchema.getTypeMap();
var breakingChanges = [];
Object.keys(oldTypeMap).forEach(function (typeName) {
if (!newTypeMap[typeName]) {
return;
}
var oldType = oldTypeMap[typeName];
var newType = newTypeMap[typeName];
if (!(oldType instanceof newType.constructor)) {
breakingChanges.push({
type: BreakingChangeType.TYPE_CHANGED_KIND,
description: typeName + ' changed from ' + (typeKindName(oldType) + ' to ' + typeKindName(newType) + '.')
});
}
});
return breakingChanges;
}
function typeKindName(type) {
if (type instanceof _definition.GraphQLScalarType) {
return 'a Scalar type';
}
if (type instanceof _definition.GraphQLObjectType) {
return 'an Object type';
}
if (type instanceof _definition.GraphQLInterfaceType) {
return 'an Interface type';
}
if (type instanceof _definition.GraphQLUnionType) {
return 'a Union type';
}
if (type instanceof _definition.GraphQLEnumType) {
return 'an Enum type';
}
if (type instanceof _definition.GraphQLInputObjectType) {
return 'an Input type';
}
throw new TypeError('Unknown type ' + type.constructor.name);
}
/**
* Given two schemas, returns an Array containing descriptions of any breaking
* changes in the newSchema related to the fields on a type. This includes if
* a field has been removed from a type or if a field has changed type.
*/
function findFieldsThatChangedType(oldSchema, newSchema) {
var oldTypeMap = oldSchema.getTypeMap();
var newTypeMap = newSchema.getTypeMap();
var breakingFieldChanges = [];
Object.keys(oldTypeMap).forEach(function (typeName) {
var oldType = oldTypeMap[typeName];
var newType = newTypeMap[typeName];
if (!(oldType instanceof _definition.GraphQLObjectType || oldType instanceof _definition.GraphQLInterfaceType || oldType instanceof _definition.GraphQLInputObjectType) || !(newType instanceof oldType.constructor)) {
return;
}
var oldTypeFieldsDef = oldType.getFields();
var newTypeFieldsDef = newType.getFields();
Object.keys(oldTypeFieldsDef).forEach(function (fieldName) {
// Check if the field is missing on the type in the new schema.
if (!(fieldName in newTypeFieldsDef)) {
breakingFieldChanges.push({
type: BreakingChangeType.FIELD_REMOVED,
description: typeName + '.' + fieldName + ' was removed.'
});
} else {
// Check if the field's type has changed in the new schema.
var oldFieldType = (0, _definition.getNamedType)(oldTypeFieldsDef[fieldName].type);
var newFieldType = (0, _definition.getNamedType)(newTypeFieldsDef[fieldName].type);
if (oldFieldType && newFieldType && oldFieldType.name !== newFieldType.name) {
breakingFieldChanges.push({
type: BreakingChangeType.FIELD_CHANGED_KIND,
description: typeName + '.' + fieldName + ' changed type from ' + (oldFieldType.name + ' to ' + newFieldType.name + '.')
});
}
}
});
});
return breakingFieldChanges;
}
/**
* Given two schemas, returns an Array containing descriptions of any breaking
* changes in the newSchema related to removing types from a union type.
*/
function findTypesRemovedFromUnions(oldSchema, newSchema) {
var oldTypeMap = oldSchema.getTypeMap();
var newTypeMap = newSchema.getTypeMap();
var typesRemovedFromUnion = [];
Object.keys(oldTypeMap).forEach(function (typeName) {
var oldType = oldTypeMap[typeName];
var newType = newTypeMap[typeName];
if (!(oldType instanceof _definition.GraphQLUnionType) || !(newType instanceof _definition.GraphQLUnionType)) {
return;
}
var typeNamesInNewUnion = Object.create(null);
newType.getTypes().forEach(function (type) {
typeNamesInNewUnion[type.name] = true;
});
oldType.getTypes().forEach(function (type) {
if (!typeNamesInNewUnion[type.name]) {
typesRemovedFromUnion.push({
type: BreakingChangeType.TYPE_REMOVED_FROM_UNION,
description: type.name + ' was removed from union type ' + typeName + '.'
});
}
});
});
return typesRemovedFromUnion;
}
/**
* Given two schemas, returns an Array containing descriptions of any breaking
* changes in the newSchema related to removing values from an enum type.
*/
function findValuesRemovedFromEnums(oldSchema, newSchema) {
var oldTypeMap = oldSchema.getTypeMap();
var newTypeMap = newSchema.getTypeMap();
var valuesRemovedFromEnums = [];
Object.keys(oldTypeMap).forEach(function (typeName) {
var oldType = oldTypeMap[typeName];
var newType = newTypeMap[typeName];
if (!(oldType instanceof _definition.GraphQLEnumType) || !(newType instanceof _definition.GraphQLEnumType)) {
return;
}
var valuesInNewEnum = Object.create(null);
newType.getValues().forEach(function (value) {
valuesInNewEnum[value.name] = true;
});
oldType.getValues().forEach(function (value) {
if (!valuesInNewEnum[value.name]) {
valuesRemovedFromEnums.push({
type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM,
description: value.name + ' was removed from enum type ' + typeName + '.'
});
}
});
});
return valuesRemovedFromEnums;
}
/***/ }),
/* 49 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findDeprecatedUsages = findDeprecatedUsages;
var _GraphQLError = __webpack_require__(13);
var _visitor = __webpack_require__(15);
var _definition = __webpack_require__(1);
var _schema = __webpack_require__(8);
var _TypeInfo = __webpack_require__(27);
/**
* A validation rule which reports deprecated usages.
*
* Returns a list of GraphQLError instances describing each deprecated use.
*/
function findDeprecatedUsages(schema, ast) {
var errors = [];
var typeInfo = new _TypeInfo.TypeInfo(schema);
(0, _visitor.visit)(ast, (0, _visitor.visitWithTypeInfo)(typeInfo, {
Field: function Field(node) {
var fieldDef = typeInfo.getFieldDef();
if (fieldDef && fieldDef.isDeprecated) {
var parentType = typeInfo.getParentType();
if (parentType) {
var reason = fieldDef.deprecationReason;
errors.push(new _GraphQLError.GraphQLError('The field ' + parentType.name + '.' + fieldDef.name + ' is deprecated.' + (reason ? ' ' + reason : ''), [node]));
}
}
},
EnumValue: function EnumValue(node) {
var enumVal = typeInfo.getEnumValue();
if (enumVal && enumVal.isDeprecated) {
var type = (0, _definition.getNamedType)(typeInfo.getInputType());
if (type) {
var reason = enumVal.deprecationReason;
errors.push(new _GraphQLError.GraphQLError('The enum value ' + type.name + '.' + enumVal.name + ' is deprecated.' + (reason ? ' ' + reason : ''), [node]));
}
}
}
}));
return errors;
}
/**
* Copyright (c) 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.
*/
/***/ }),
/* 50 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getOperationAST = getOperationAST;
var _kinds = __webpack_require__(2);
/**
* Returns an operation AST given a document AST and optionally an operation
* name. If a name is not provided, an operation is only returned if only one is
* provided in the document.
*/
function getOperationAST(documentAST, operationName) {
var operation = null;
for (var i = 0; i < documentAST.definitions.length; i++) {
var definition = documentAST.definitions[i];
if (definition.kind === _kinds.OPERATION_DEFINITION) {
if (!operationName) {
// If no operation name was provided, only return an Operation if there
// is one defined in the document. Upon encountering the second, return
// null.
if (operation) {
return null;
}
operation = definition;
} else if (definition.name && definition.name.value === operationName) {
return definition;
}
}
}
return operation;
}
/**
* Copyright (c) 2015, 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.
*/
/***/ }),
/* 51 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _introspectionQuery = __webpack_require__(52);
Object.defineProperty(exports, 'introspectionQuery', {
enumerable: true,
get: function get() {
return _introspectionQuery.introspectionQuery;
}
});
var _getOperationAST = __webpack_require__(50);
Object.defineProperty(exports, 'getOperationAST', {
enumerable: true,
get: function get() {
return _getOperationAST.getOperationAST;
}
});
var _buildClientSchema = __webpack_require__(45);
Object.defineProperty(exports, 'buildClientSchema', {
enumerable: true,
get: function get() {
return _buildClientSchema.buildClientSchema;
}
});
var _buildASTSchema = __webpack_require__(32);
Object.defineProperty(exports, 'buildASTSchema', {
enumerable: true,
get: function get() {
return _buildASTSchema.buildASTSchema;
}
});
Object.defineProperty(exports, 'buildSchema', {
enumerable: true,
get: function get() {
return _buildASTSchema.buildSchema;
}
});
var _extendSchema = __webpack_require__(47);
Object.defineProperty(exports, 'extendSchema', {
enumerable: true,
get: function get() {
return _extendSchema.extendSchema;
}
});
var _schemaPrinter = __webpack_require__(53);
Object.defineProperty(exports, 'printSchema', {
enumerable: true,
get: function get() {
return _schemaPrinter.printSchema;
}
});
Object.defineProperty(exports, 'printType', {
enumerable: true,
get: function get() {
return _schemaPrinter.printType;
}
});
Object.defineProperty(exports, 'printIntrospectionSchema', {
enumerable: true,
get: function get() {
return _schemaPrinter.printIntrospectionSchema;
}
});
var _typeFromAST = __webpack_require__(9);
Object.defineProperty(exports, 'typeFromAST', {
enumerable: true,
get: function get() {
return _typeFromAST.typeFromAST;
}
});
var _valueFromAST = __webpack_require__(16);
Object.defineProperty(exports, 'valueFromAST', {
enumerable: true,
get: function get() {
return _valueFromAST.valueFromAST;
}
});
var _astFromValue = __webpack_require__(29);
Object.defineProperty(exports, 'astFromValue', {
enumerable: true,
get: function get() {
return _astFromValue.astFromValue;
}
});
var _TypeInfo = __webpack_require__(27);
Object.defineProperty(exports, 'TypeInfo', {
enumerable: true,
get: function get() {
return _TypeInfo.TypeInfo;
}
});
var _isValidJSValue = __webpack_require__(33);
Object.defineProperty(exports, 'isValidJSValue', {
enumerable: true,
get: function get() {
return _isValidJSValue.isValidJSValue;
}
});
var _isValidLiteralValue = __webpack_require__(18);
Object.defineProperty(exports, 'isValidLiteralValue', {
enumerable: true,
get: function get() {
return _isValidLiteralValue.isValidLiteralValue;
}
});
var _concatAST = __webpack_require__(46);
Object.defineProperty(exports, 'concatAST', {
enumerable: true,
get: function get() {
return _concatAST.concatAST;
}
});
var _separateOperations = __webpack_require__(54);
Object.defineProperty(exports, 'separateOperations', {
enumerable: true,
get: function get() {
return _separateOperations.separateOperations;
}
});
var _typeComparators = __webpack_require__(19);
Object.defineProperty(exports, 'isEqualType', {
enumerable: true,
get: function get() {
return _typeComparators.isEqualType;
}
});
Object.defineProperty(exports, 'isTypeSubTypeOf', {
enumerable: true,
get: function get() {
return _typeComparators.isTypeSubTypeOf;
}
});
Object.defineProperty(exports, 'doTypesOverlap', {
enumerable: true,
get: function get() {
return _typeComparators.doTypesOverlap;
}
});
var _assertValidName = __webpack_require__(28);
Object.defineProperty(exports, 'assertValidName', {
enumerable: true,
get: function get() {
return _assertValidName.assertValidName;
}
});
var _findBreakingChanges = __webpack_require__(48);
Object.defineProperty(exports, 'findBreakingChanges', {
enumerable: true,
get: function get() {
return _findBreakingChanges.findBreakingChanges;
}
});
var _findDeprecatedUsages = __webpack_require__(49);
Object.defineProperty(exports, 'findDeprecatedUsages', {
enumerable: true,
get: function get() {
return _findDeprecatedUsages.findDeprecatedUsages;
}
});
/***/ }),
/* 52 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var introspectionQuery = exports.introspectionQuery = '\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n description\n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n description\n type { ...TypeRef }\n defaultValue\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n';
/**
* Copyright (c) 2015, 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.
*/
/***/ }),
/* 53 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.printSchema = printSchema;
exports.printIntrospectionSchema = printIntrospectionSchema;
exports.printType = printType;
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _isNullish = __webpack_require__(6);
var _isNullish2 = _interopRequireDefault(_isNullish);
var _isInvalid = __webpack_require__(14);
var _isInvalid2 = _interopRequireDefault(_isInvalid);
var _astFromValue = __webpack_require__(29);
var _printer = __webpack_require__(4);
var _definition = __webpack_require__(1);
var _scalars = __webpack_require__(7);
var _directives = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Copyright (c) 2015, 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.
*/
function printSchema(schema) {
return printFilteredSchema(schema, function (n) {
return !isSpecDirective(n);
}, isDefinedType);
}
function printIntrospectionSchema(schema) {
return printFilteredSchema(schema, isSpecDirective, isIntrospectionType);
}
function isSpecDirective(directiveName) {
return directiveName === 'skip' || directiveName === 'include' || directiveName === 'deprecated';
}
function isDefinedType(typename) {
return !isIntrospectionType(typename) && !isBuiltInScalar(typename);
}
function isIntrospectionType(typename) {
return typename.indexOf('__') === 0;
}
function isBuiltInScalar(typename) {
return typename === 'String' || typename === 'Boolean' || typename === 'Int' || typename === 'Float' || typename === 'ID';
}
function printFilteredSchema(schema, directiveFilter, typeFilter) {
var directives = schema.getDirectives().filter(function (directive) {
return directiveFilter(directive.name);
});
var typeMap = schema.getTypeMap();
var types = Object.keys(typeMap).filter(typeFilter).sort(function (name1, name2) {
return name1.localeCompare(name2);
}).map(function (typeName) {
return typeMap[typeName];
});
return [printSchemaDefinition(schema)].concat(directives.map(printDirective), types.map(printType)).filter(Boolean).join('\n\n') + '\n';
}
function printSchemaDefinition(schema) {
if (isSchemaOfCommonNames(schema)) {
return;
}
var operationTypes = [];
var queryType = schema.getQueryType();
if (queryType) {
operationTypes.push(' query: ' + queryType.name);
}
var mutationType = schema.getMutationType();
if (mutationType) {
operationTypes.push(' mutation: ' + mutationType.name);
}
var subscriptionType = schema.getSubscriptionType();
if (subscriptionType) {
operationTypes.push(' subscription: ' + subscriptionType.name);
}
return 'schema {\n' + operationTypes.join('\n') + '\n}';
}
/**
* GraphQL schema define root types for each type of operation. These types are
* the same as any other type and can be named in any manner, however there is
* a common naming convention:
*
* schema {
* query: Query
* mutation: Mutation
* }
*
* When using this naming convention, the schema description can be omitted.
*/
function isSchemaOfCommonNames(schema) {
var queryType = schema.getQueryType();
if (queryType && queryType.name !== 'Query') {
return false;
}
var mutationType = schema.getMutationType();
if (mutationType && mutationType.name !== 'Mutation') {
return false;
}
var subscriptionType = schema.getSubscriptionType();
if (subscriptionType && subscriptionType.name !== 'Subscription') {
return false;
}
return true;
}
function printType(type) {
if (type instanceof _definition.GraphQLScalarType) {
return printScalar(type);
} else if (type instanceof _definition.GraphQLObjectType) {
return printObject(type);
} else if (type instanceof _definition.GraphQLInterfaceType) {
return printInterface(type);
} else if (type instanceof _definition.GraphQLUnionType) {
return printUnion(type);
} else if (type instanceof _definition.GraphQLEnumType) {
return printEnum(type);
}
(0, _invariant2.default)(type instanceof _definition.GraphQLInputObjectType);
return printInputObject(type);
}
function printScalar(type) {
return printDescription(type) + ('scalar ' + type.name);
}
function printObject(type) {
var interfaces = type.getInterfaces();
var implementedInterfaces = interfaces.length ? ' implements ' + interfaces.map(function (i) {
return i.name;
}).join(', ') : '';
return printDescription(type) + ('type ' + type.name + implementedInterfaces + ' {\n') + printFields(type) + '\n' + '}';
}
function printInterface(type) {
return printDescription(type) + ('interface ' + type.name + ' {\n') + printFields(type) + '\n' + '}';
}
function printUnion(type) {
return printDescription(type) + ('union ' + type.name + ' = ' + type.getTypes().join(' | '));
}
function printEnum(type) {
return printDescription(type) + ('enum ' + type.name + ' {\n') + printEnumValues(type.getValues()) + '\n' + '}';
}
function printEnumValues(values) {
return values.map(function (value, i) {
return printDescription(value, ' ', !i) + ' ' + value.name + printDeprecated(value);
}).join('\n');
}
function printInputObject(type) {
var fieldMap = type.getFields();
var fields = Object.keys(fieldMap).map(function (fieldName) {
return fieldMap[fieldName];
});
return printDescription(type) + ('input ' + type.name + ' {\n') + fields.map(function (f, i) {
return printDescription(f, ' ', !i) + ' ' + printInputValue(f);
}).join('\n') + '\n' + '}';
}
function printFields(type) {
var fieldMap = type.getFields();
var fields = Object.keys(fieldMap).map(function (fieldName) {
return fieldMap[fieldName];
});
return fields.map(function (f, i) {
return printDescription(f, ' ', !i) + ' ' + f.name + printArgs(f.args, ' ') + ': ' + String(f.type) + printDeprecated(f);
}).join('\n');
}
function printArgs(args) {
var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
if (args.length === 0) {
return '';
}
// If every arg does not have a description, print them on one line.
if (args.every(function (arg) {
return !arg.description;
})) {
return '(' + args.map(printInputValue).join(', ') + ')';
}
return '(\n' + args.map(function (arg, i) {
return printDescription(arg, ' ' + indentation, !i) + ' ' + indentation + printInputValue(arg);
}).join('\n') + '\n' + indentation + ')';
}
function printInputValue(arg) {
var argDecl = arg.name + ': ' + String(arg.type);
if (!(0, _isInvalid2.default)(arg.defaultValue)) {
argDecl += ' = ' + (0, _printer.print)((0, _astFromValue.astFromValue)(arg.defaultValue, arg.type));
}
return argDecl;
}
function printDirective(directive) {
return printDescription(directive) + 'directive @' + directive.name + printArgs(directive.args) + ' on ' + directive.locations.join(' | ');
}
function printDeprecated(fieldOrEnumVal) {
var reason = fieldOrEnumVal.deprecationReason;
if ((0, _isNullish2.default)(reason)) {
return '';
}
if (reason === '' || reason === _directives.DEFAULT_DEPRECATION_REASON) {
return ' @deprecated';
}
return ' @deprecated(reason: ' + (0, _printer.print)((0, _astFromValue.astFromValue)(reason, _scalars.GraphQLString)) + ')';
}
function printDescription(def) {
var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var firstInBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
if (!def.description) {
return '';
}
var lines = def.description.split('\n');
var description = indentation && !firstInBlock ? '\n' : '';
for (var i = 0; i < lines.length; i++) {
if (lines[i] === '') {
description += indentation + '#\n';
} else {
// For > 120 character long lines, cut at space boundaries into sublines
// of ~80 chars.
var sublines = breakLine(lines[i], 120 - indentation.length);
for (var j = 0; j < sublines.length; j++) {
description += indentation + '# ' + sublines[j] + '\n';
}
}
}
return description;
}
function breakLine(line, len) {
if (line.length < len + 5) {
return [line];
}
var parts = line.split(new RegExp('((?: |^).{15,' + (len - 40) + '}(?= |$))'));
if (parts.length < 4) {
return [line];
}
var sublines = [parts[0] + parts[1] + parts[2]];
for (var i = 3; i < parts.length; i += 2) {
sublines.push(parts[i].slice(1) + parts[i + 1]);
}
return sublines;
}
/***/ }),
/* 54 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.separateOperations = separateOperations;
var _visitor = __webpack_require__(15);
/**
* separateOperations accepts a single AST document which may contain many
* operations and fragments and returns a collection of AST documents each of
* which contains a single operation as well the fragment definitions it
* refers to.
*/
function separateOperations(documentAST) {
var operations = [];
var depGraph = Object.create(null);
var fromName = void 0;
// Populate the list of operations and build a dependency graph.
(0, _visitor.visit)(documentAST, {
OperationDefinition: function OperationDefinition(node) {
operations.push(node);
fromName = opName(node);
},
FragmentDefinition: function FragmentDefinition(node) {
fromName = node.name.value;
},
FragmentSpread: function FragmentSpread(node) {
var toName = node.name.value;
(depGraph[fromName] || (depGraph[fromName] = Object.create(null)))[toName] = true;
}
});
// For each operation, produce a new synthesized AST which includes only what
// is necessary for completing that operation.
var separatedDocumentASTs = Object.create(null);
operations.forEach(function (operation) {
var operationName = opName(operation);
var dependencies = Object.create(null);
collectTransitiveDependencies(dependencies, depGraph, operationName);
separatedDocumentASTs[operationName] = {
kind: 'Document',
definitions: documentAST.definitions.filter(function (def) {
return def === operation || def.kind === 'FragmentDefinition' && dependencies[def.name.value];
})
};
});
return separatedDocumentASTs;
}
/**
* Copyright (c) 2015, 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.
*/
// Provides the empty string for anonymous operations.
function opName(operation) {
return operation.name ? operation.name.value : '';
}
// From a dependency graph, collects a list of transitive dependencies by
// recursing through a dependency graph.
function collectTransitiveDependencies(collected, depGraph, fromName) {
var immediateDeps = depGraph[fromName];
if (immediateDeps) {
Object.keys(immediateDeps).forEach(function (toName) {
if (!collected[toName]) {
collected[toName] = true;
collectTransitiveDependencies(collected, depGraph, toName);
}
});
}
}
/***/ }),
/* 55 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _validate = __webpack_require__(35);
Object.defineProperty(exports, 'validate', {
enumerable: true,
get: function get() {
return _validate.validate;
}
});
Object.defineProperty(exports, 'ValidationContext', {
enumerable: true,
get: function get() {
return _validate.ValidationContext;
}
});
var _specifiedRules = __webpack_require__(34);
Object.defineProperty(exports, 'specifiedRules', {
enumerable: true,
get: function get() {
return _specifiedRules.specifiedRules;
}
});
/***/ }),
/* 56 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.badValueMessage = badValueMessage;
exports.ArgumentsOfCorrectType = ArgumentsOfCorrectType;
var _error = __webpack_require__(0);
var _printer = __webpack_require__(4);
var _isValidLiteralValue = __webpack_require__(18);
/**
* Copyright (c) 2015, 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.
*/
function badValueMessage(argName, type, value, verboseErrors) {
var message = verboseErrors ? '\n' + verboseErrors.join('\n') : '';
return 'Argument "' + argName + '" has invalid value ' + value + '.' + message;
}
/**
* Argument values of correct type
*
* A GraphQL document is only valid if all field argument literal values are
* of the type expected by their position.
*/
function ArgumentsOfCorrectType(context) {
return {
Argument: function Argument(node) {
var argDef = context.getArgument();
if (argDef) {
var errors = (0, _isValidLiteralValue.isValidLiteralValue)(argDef.type, node.value);
if (errors && errors.length > 0) {
context.reportError(new _error.GraphQLError(badValueMessage(node.name.value, argDef.type, (0, _printer.print)(node.value), errors), [node.value]));
}
}
return false;
}
};
}
/***/ }),
/* 57 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defaultForNonNullArgMessage = defaultForNonNullArgMessage;
exports.badValueForDefaultArgMessage = badValueForDefaultArgMessage;
exports.DefaultValuesOfCorrectType = DefaultValuesOfCorrectType;
var _error = __webpack_require__(0);
var _printer = __webpack_require__(4);
var _definition = __webpack_require__(1);
var _isValidLiteralValue = __webpack_require__(18);
function defaultForNonNullArgMessage(varName, type, guessType) {
return 'Variable "$' + varName + '" of type "' + String(type) + '" is required and ' + 'will not use the default value. ' + ('Perhaps you meant to use type "' + String(guessType) + '".');
}
/**
* Copyright (c) 2015, 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.
*/
function badValueForDefaultArgMessage(varName, type, value, verboseErrors) {
var message = verboseErrors ? '\n' + verboseErrors.join('\n') : '';
return 'Variable "$' + varName + '" of type "' + String(type) + '" has invalid ' + ('default value ' + value + '.' + message);
}
/**
* Variable default values of correct type
*
* A GraphQL document is only valid if all variable default values are of the
* type expected by their definition.
*/
function DefaultValuesOfCorrectType(context) {
return {
VariableDefinition: function VariableDefinition(node) {
var name = node.variable.name.value;
var defaultValue = node.defaultValue;
var type = context.getInputType();
if (type instanceof _definition.GraphQLNonNull && defaultValue) {
context.reportError(new _error.GraphQLError(defaultForNonNullArgMessage(name, type, type.ofType), [defaultValue]));
}
if (type && defaultValue) {
var errors = (0, _isValidLiteralValue.isValidLiteralValue)(type, defaultValue);
if (errors && errors.length > 0) {
context.reportError(new _error.GraphQLError(badValueForDefaultArgMessage(name, type, (0, _printer.print)(defaultValue), errors), [defaultValue]));
}
}
return false;
},
SelectionSet: function SelectionSet() {
return false;
},
FragmentDefinition: function FragmentDefinition() {
return false;
}
};
}
/***/ }),
/* 58 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.undefinedFieldMessage = undefinedFieldMessage;
exports.FieldsOnCorrectType = FieldsOnCorrectType;
var _error = __webpack_require__(0);
var _suggestionList = __webpack_require__(23);
var _suggestionList2 = _interopRequireDefault(_suggestionList);
var _quotedOrList = __webpack_require__(22);
var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
var _definition = __webpack_require__(1);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function undefinedFieldMessage(fieldName, type, suggestedTypeNames, suggestedFieldNames) {
var message = 'Cannot query field "' + fieldName + '" on type "' + type + '".';
if (suggestedTypeNames.length !== 0) {
var suggestions = (0, _quotedOrList2.default)(suggestedTypeNames);
message += ' Did you mean to use an inline fragment on ' + suggestions + '?';
} else if (suggestedFieldNames.length !== 0) {
message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedFieldNames) + '?';
}
return message;
}
/**
* Fields on correct type
*
* A GraphQL document is only valid if all fields selected are defined by the
* parent type, or are an allowed meta field such as __typename.
*/
/**
* Copyright (c) 2015, 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.
*/
function FieldsOnCorrectType(context) {
return {
Field: function Field(node) {
var type = context.getParentType();
if (type) {
var fieldDef = context.getFieldDef();
if (!fieldDef) {
// This field doesn't exist, lets look for suggestions.
var schema = context.getSchema();
var fieldName = node.name.value;
// First determine if there are any suggested types to condition on.
var suggestedTypeNames = getSuggestedTypeNames(schema, type, fieldName);
// If there are no suggested types, then perhaps this was a typo?
var suggestedFieldNames = suggestedTypeNames.length !== 0 ? [] : getSuggestedFieldNames(schema, type, fieldName);
// Report an error, including helpful suggestions.
context.reportError(new _error.GraphQLError(undefinedFieldMessage(fieldName, type.name, suggestedTypeNames, suggestedFieldNames), [node]));
}
}
}
};
}
/**
* Go through all of the implementations of type, as well as the interfaces
* that they implement. If any of those types include the provided field,
* suggest them, sorted by how often the type is referenced, starting
* with Interfaces.
*/
function getSuggestedTypeNames(schema, type, fieldName) {
if (type instanceof _definition.GraphQLInterfaceType || type instanceof _definition.GraphQLUnionType) {
var _ret = function () {
var suggestedObjectTypes = [];
var interfaceUsageCount = Object.create(null);
schema.getPossibleTypes(type).forEach(function (possibleType) {
if (!possibleType.getFields()[fieldName]) {
return;
}
// This object type defines this field.
suggestedObjectTypes.push(possibleType.name);
possibleType.getInterfaces().forEach(function (possibleInterface) {
if (!possibleInterface.getFields()[fieldName]) {
return;
}
// This interface type defines this field.
interfaceUsageCount[possibleInterface.name] = (interfaceUsageCount[possibleInterface.name] || 0) + 1;
});
});
// Suggest interface types based on how common they are.
var suggestedInterfaceTypes = Object.keys(interfaceUsageCount).sort(function (a, b) {
return interfaceUsageCount[b] - interfaceUsageCount[a];
});
// Suggest both interface and object types.
return {
v: suggestedInterfaceTypes.concat(suggestedObjectTypes)
};
}();
if (typeof _ret === "object") return _ret.v;
}
// Otherwise, must be an Object type, which does not have possible fields.
return [];
}
/**
* For the field name provided, determine if there are any similar field names
* that may be the result of a typo.
*/
function getSuggestedFieldNames(schema, type, fieldName) {
if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
var possibleFieldNames = Object.keys(type.getFields());
return (0, _suggestionList2.default)(fieldName, possibleFieldNames);
}
// Otherwise, must be a Union type, which does not define fields.
return [];
}
/***/ }),
/* 59 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.inlineFragmentOnNonCompositeErrorMessage = inlineFragmentOnNonCompositeErrorMessage;
exports.fragmentOnNonCompositeErrorMessage = fragmentOnNonCompositeErrorMessage;
exports.FragmentsOnCompositeTypes = FragmentsOnCompositeTypes;
var _error = __webpack_require__(0);
var _printer = __webpack_require__(4);
var _definition = __webpack_require__(1);
/**
* Copyright (c) 2015, 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.
*/
function inlineFragmentOnNonCompositeErrorMessage(type) {
return 'Fragment cannot condition on non composite type "' + String(type) + '".';
}
function fragmentOnNonCompositeErrorMessage(fragName, type) {
return 'Fragment "' + fragName + '" cannot condition on non composite ' + ('type "' + String(type) + '".');
}
/**
* Fragments on composite type
*
* Fragments use a type condition to determine if they apply, since fragments
* can only be spread into a composite type (object, interface, or union), the
* type condition must also be a composite type.
*/
function FragmentsOnCompositeTypes(context) {
return {
InlineFragment: function InlineFragment(node) {
var type = context.getType();
if (node.typeCondition && type && !(0, _definition.isCompositeType)(type)) {
context.reportError(new _error.GraphQLError(inlineFragmentOnNonCompositeErrorMessage((0, _printer.print)(node.typeCondition)), [node.typeCondition]));
}
},
FragmentDefinition: function FragmentDefinition(node) {
var type = context.getType();
if (type && !(0, _definition.isCompositeType)(type)) {
context.reportError(new _error.GraphQLError(fragmentOnNonCompositeErrorMessage(node.name.value, (0, _printer.print)(node.typeCondition)), [node.typeCondition]));
}
}
};
}
/***/ }),
/* 60 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unknownArgMessage = unknownArgMessage;
exports.unknownDirectiveArgMessage = unknownDirectiveArgMessage;
exports.KnownArgumentNames = KnownArgumentNames;
var _error = __webpack_require__(0);
var _find = __webpack_require__(10);
var _find2 = _interopRequireDefault(_find);
var _invariant = __webpack_require__(3);
var _invariant2 = _interopRequireDefault(_invariant);
var _suggestionList = __webpack_require__(23);
var _suggestionList2 = _interopRequireDefault(_suggestionList);
var _quotedOrList = __webpack_require__(22);
var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
var _kinds = __webpack_require__(2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function unknownArgMessage(argName, fieldName, type, suggestedArgs) {
var message = 'Unknown argument "' + argName + '" on field "' + fieldName + '" of ' + ('type "' + String(type) + '".');
if (suggestedArgs.length) {
message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedArgs) + '?';
}
return message;
}
/**
* Copyright (c) 2015, 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.
*/
function unknownDirectiveArgMessage(argName, directiveName, suggestedArgs) {
var message = 'Unknown argument "' + argName + '" on directive "@' + directiveName + '".';
if (suggestedArgs.length) {
message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedArgs) + '?';
}
return message;
}
/**
* Known argument names
*
* A GraphQL field is only valid if all supplied arguments are defined by
* that field.
*/
function KnownArgumentNames(context) {
return {
Argument: function Argument(node, key, parent, path, ancestors) {
var argumentOf = ancestors[ancestors.length - 1];
if (argumentOf.kind === _kinds.FIELD) {
var fieldDef = context.getFieldDef();
if (fieldDef) {
var fieldArgDef = (0, _find2.default)(fieldDef.args, function (arg) {
return arg.name === node.name.value;
});
if (!fieldArgDef) {
var parentType = context.getParentType();
(0, _invariant2.default)(parentType);
context.reportError(new _error.GraphQLError(unknownArgMessage(node.name.value, fieldDef.name, parentType.name, (0, _suggestionList2.default)(node.name.value, fieldDef.args.map(function (arg) {
return arg.name;
}))), [node]));
}
}
} else if (argumentOf.kind === _kinds.DIRECTIVE) {
var directive = context.getDirective();
if (directive) {
var directiveArgDef = (0, _find2.default)(directive.args, function (arg) {
return arg.name === node.name.value;
});
if (!directiveArgDef) {
context.reportError(new _error.GraphQLError(unknownDirectiveArgMessage(node.name.value, directive.name, (0, _suggestionList2.default)(node.name.value, directive.args.map(function (arg) {
return arg.name;
}))), [node]));
}
}
}
}
};
}
/***/ }),
/* 61 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unknownDirectiveMessage = unknownDirectiveMessage;
exports.misplacedDirectiveMessage = misplacedDirectiveMessage;
exports.KnownDirectives = KnownDirectives;
var _error = __webpack_require__(0);
var _find = __webpack_require__(10);
var _find2 = _interopRequireDefault(_find);
var _kinds = __webpack_require__(2);
var _directives = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function unknownDirectiveMessage(directiveName) {
return 'Unknown directive "' + directiveName + '".';
}
/**
* Copyright (c) 2015, 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.
*/
function misplacedDirectiveMessage(directiveName, location) {
return 'Directive "' + directiveName + '" may not be used on ' + location + '.';
}
/**
* Known directives
*
* A GraphQL document is only valid if all `@directives` are known by the
* schema and legally positioned.
*/
function KnownDirectives(context) {
return {
Directive: function Directive(node, key, parent, path, ancestors) {
var directiveDef = (0, _find2.default)(context.getSchema().getDirectives(), function (def) {
return def.name === node.name.value;
});
if (!directiveDef) {
context.reportError(new _error.GraphQLError(unknownDirectiveMessage(node.name.value), [node]));
return;
}
var candidateLocation = getDirectiveLocationForASTPath(ancestors);
if (!candidateLocation) {
context.reportError(new _error.GraphQLError(misplacedDirectiveMessage(node.name.value, node.type), [node]));
} else if (directiveDef.locations.indexOf(candidateLocation) === -1) {
context.reportError(new _error.GraphQLError(misplacedDirectiveMessage(node.name.value, candidateLocation), [node]));
}
}
};
}
function getDirectiveLocationForASTPath(ancestors) {
var appliedTo = ancestors[ancestors.length - 1];
switch (appliedTo.kind) {
case _kinds.OPERATION_DEFINITION:
switch (appliedTo.operation) {
case 'query':
return _directives.DirectiveLocation.QUERY;
case 'mutation':
return _directives.DirectiveLocation.MUTATION;
case 'subscription':
return _directives.DirectiveLocation.SUBSCRIPTION;
}
break;
case _kinds.FIELD:
return _directives.DirectiveLocation.FIELD;
case _kinds.FRAGMENT_SPREAD:
return _directives.DirectiveLocation.FRAGMENT_SPREAD;
case _kinds.INLINE_FRAGMENT:
return _directives.DirectiveLocation.INLINE_FRAGMENT;
case _kinds.FRAGMENT_DEFINITION:
return _directives.DirectiveLocation.FRAGMENT_DEFINITION;
case _kinds.SCHEMA_DEFINITION:
return _directives.DirectiveLocation.SCHEMA;
case _kinds.SCALAR_TYPE_DEFINITION:
return _directives.DirectiveLocation.SCALAR;
case _kinds.OBJECT_TYPE_DEFINITION:
return _directives.DirectiveLocation.OBJECT;
case _kinds.FIELD_DEFINITION:
return _directives.DirectiveLocation.FIELD_DEFINITION;
case _kinds.INTERFACE_TYPE_DEFINITION:
return _directives.DirectiveLocation.INTERFACE;
case _kinds.UNION_TYPE_DEFINITION:
return _directives.DirectiveLocation.UNION;
case _kinds.ENUM_TYPE_DEFINITION:
return _directives.DirectiveLocation.ENUM;
case _kinds.ENUM_VALUE_DEFINITION:
return _directives.DirectiveLocation.ENUM_VALUE;
case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
return _directives.DirectiveLocation.INPUT_OBJECT;
case _kinds.INPUT_VALUE_DEFINITION:
var parentNode = ancestors[ancestors.length - 3];
return parentNode.kind === _kinds.INPUT_OBJECT_TYPE_DEFINITION ? _directives.DirectiveLocation.INPUT_FIELD_DEFINITION : _directives.DirectiveLocation.ARGUMENT_DEFINITION;
}
}
/***/ }),
/* 62 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unknownFragmentMessage = unknownFragmentMessage;
exports.KnownFragmentNames = KnownFragmentNames;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function unknownFragmentMessage(fragName) {
return 'Unknown fragment "' + fragName + '".';
}
/**
* Known fragment names
*
* A GraphQL document is only valid if all `...Fragment` fragment spreads refer
* to fragments defined in the same document.
*/
function KnownFragmentNames(context) {
return {
FragmentSpread: function FragmentSpread(node) {
var fragmentName = node.name.value;
var fragment = context.getFragment(fragmentName);
if (!fragment) {
context.reportError(new _error.GraphQLError(unknownFragmentMessage(fragmentName), [node.name]));
}
}
};
}
/***/ }),
/* 63 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unknownTypeMessage = unknownTypeMessage;
exports.KnownTypeNames = KnownTypeNames;
var _error = __webpack_require__(0);
var _suggestionList = __webpack_require__(23);
var _suggestionList2 = _interopRequireDefault(_suggestionList);
var _quotedOrList = __webpack_require__(22);
var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Copyright (c) 2015, 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.
*/
function unknownTypeMessage(type, suggestedTypes) {
var message = 'Unknown type "' + String(type) + '".';
if (suggestedTypes.length) {
message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedTypes) + '?';
}
return message;
}
/**
* Known type names
*
* A GraphQL document is only valid if referenced types (specifically
* variable definitions and fragment conditions) are defined by the type schema.
*/
function KnownTypeNames(context) {
return {
// TODO: when validating IDL, re-enable these. Experimental version does not
// add unreferenced types, resulting in false-positive errors. Squelched
// errors for now.
ObjectTypeDefinition: function ObjectTypeDefinition() {
return false;
},
InterfaceTypeDefinition: function InterfaceTypeDefinition() {
return false;
},
UnionTypeDefinition: function UnionTypeDefinition() {
return false;
},
InputObjectTypeDefinition: function InputObjectTypeDefinition() {
return false;
},
NamedType: function NamedType(node) {
var schema = context.getSchema();
var typeName = node.name.value;
var type = schema.getType(typeName);
if (!type) {
context.reportError(new _error.GraphQLError(unknownTypeMessage(typeName, (0, _suggestionList2.default)(typeName, Object.keys(schema.getTypeMap()))), [node]));
}
}
};
}
/***/ }),
/* 64 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.anonOperationNotAloneMessage = anonOperationNotAloneMessage;
exports.LoneAnonymousOperation = LoneAnonymousOperation;
var _error = __webpack_require__(0);
var _kinds = __webpack_require__(2);
function anonOperationNotAloneMessage() {
return 'This anonymous operation must be the only defined operation.';
}
/**
* Lone anonymous operation
*
* A GraphQL document is only valid if when it contains an anonymous operation
* (the query short-hand) that it contains only that one operation definition.
*/
/**
* Copyright (c) 2015, 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.
*/
function LoneAnonymousOperation(context) {
var operationCount = 0;
return {
Document: function Document(node) {
operationCount = node.definitions.filter(function (definition) {
return definition.kind === _kinds.OPERATION_DEFINITION;
}).length;
},
OperationDefinition: function OperationDefinition(node) {
if (!node.name && operationCount > 1) {
context.reportError(new _error.GraphQLError(anonOperationNotAloneMessage(), [node]));
}
}
};
}
/***/ }),
/* 65 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cycleErrorMessage = cycleErrorMessage;
exports.NoFragmentCycles = NoFragmentCycles;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function cycleErrorMessage(fragName, spreadNames) {
var via = spreadNames.length ? ' via ' + spreadNames.join(', ') : '';
return 'Cannot spread fragment "' + fragName + '" within itself' + via + '.';
}
function NoFragmentCycles(context) {
// Tracks already visited fragments to maintain O(N) and to ensure that cycles
// are not redundantly reported.
var visitedFrags = Object.create(null);
// Array of AST nodes used to produce meaningful errors
var spreadPath = [];
// Position in the spread path
var spreadPathIndexByName = Object.create(null);
return {
OperationDefinition: function OperationDefinition() {
return false;
},
FragmentDefinition: function FragmentDefinition(node) {
if (!visitedFrags[node.name.value]) {
detectCycleRecursive(node);
}
return false;
}
};
// This does a straight-forward DFS to find cycles.
// It does not terminate when a cycle was found but continues to explore
// the graph to find all possible cycles.
function detectCycleRecursive(fragment) {
var fragmentName = fragment.name.value;
visitedFrags[fragmentName] = true;
var spreadNodes = context.getFragmentSpreads(fragment.selectionSet);
if (spreadNodes.length === 0) {
return;
}
spreadPathIndexByName[fragmentName] = spreadPath.length;
for (var i = 0; i < spreadNodes.length; i++) {
var spreadNode = spreadNodes[i];
var spreadName = spreadNode.name.value;
var cycleIndex = spreadPathIndexByName[spreadName];
if (cycleIndex === undefined) {
spreadPath.push(spreadNode);
if (!visitedFrags[spreadName]) {
var spreadFragment = context.getFragment(spreadName);
if (spreadFragment) {
detectCycleRecursive(spreadFragment);
}
}
spreadPath.pop();
} else {
var cyclePath = spreadPath.slice(cycleIndex);
context.reportError(new _error.GraphQLError(cycleErrorMessage(spreadName, cyclePath.map(function (s) {
return s.name.value;
})), cyclePath.concat(spreadNode)));
}
}
spreadPathIndexByName[fragmentName] = undefined;
}
}
/***/ }),
/* 66 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.undefinedVarMessage = undefinedVarMessage;
exports.NoUndefinedVariables = NoUndefinedVariables;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function undefinedVarMessage(varName, opName) {
return opName ? 'Variable "$' + varName + '" is not defined by operation "' + opName + '".' : 'Variable "$' + varName + '" is not defined.';
}
/**
* No undefined variables
*
* A GraphQL operation is only valid if all variables encountered, both directly
* and via fragment spreads, are defined by that operation.
*/
function NoUndefinedVariables(context) {
var variableNameDefined = Object.create(null);
return {
OperationDefinition: {
enter: function enter() {
variableNameDefined = Object.create(null);
},
leave: function leave(operation) {
var usages = context.getRecursiveVariableUsages(operation);
usages.forEach(function (_ref) {
var node = _ref.node;
var varName = node.name.value;
if (variableNameDefined[varName] !== true) {
context.reportError(new _error.GraphQLError(undefinedVarMessage(varName, operation.name && operation.name.value), [node, operation]));
}
});
}
},
VariableDefinition: function VariableDefinition(node) {
variableNameDefined[node.variable.name.value] = true;
}
};
}
/***/ }),
/* 67 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unusedFragMessage = unusedFragMessage;
exports.NoUnusedFragments = NoUnusedFragments;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function unusedFragMessage(fragName) {
return 'Fragment "' + fragName + '" is never used.';
}
/**
* No unused fragments
*
* A GraphQL document is only valid if all fragment definitions are spread
* within operations, or spread within other fragments spread within operations.
*/
function NoUnusedFragments(context) {
var operationDefs = [];
var fragmentDefs = [];
return {
OperationDefinition: function OperationDefinition(node) {
operationDefs.push(node);
return false;
},
FragmentDefinition: function FragmentDefinition(node) {
fragmentDefs.push(node);
return false;
},
Document: {
leave: function leave() {
var fragmentNameUsed = Object.create(null);
operationDefs.forEach(function (operation) {
context.getRecursivelyReferencedFragments(operation).forEach(function (fragment) {
fragmentNameUsed[fragment.name.value] = true;
});
});
fragmentDefs.forEach(function (fragmentDef) {
var fragName = fragmentDef.name.value;
if (fragmentNameUsed[fragName] !== true) {
context.reportError(new _error.GraphQLError(unusedFragMessage(fragName), [fragmentDef]));
}
});
}
}
};
}
/***/ }),
/* 68 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unusedVariableMessage = unusedVariableMessage;
exports.NoUnusedVariables = NoUnusedVariables;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function unusedVariableMessage(varName, opName) {
return opName ? 'Variable "$' + varName + '" is never used in operation "' + opName + '".' : 'Variable "$' + varName + '" is never used.';
}
/**
* No unused variables
*
* A GraphQL operation is only valid if all variables defined by an operation
* are used, either directly or within a spread fragment.
*/
function NoUnusedVariables(context) {
var variableDefs = [];
return {
OperationDefinition: {
enter: function enter() {
variableDefs = [];
},
leave: function leave(operation) {
var variableNameUsed = Object.create(null);
var usages = context.getRecursiveVariableUsages(operation);
var opName = operation.name ? operation.name.value : null;
usages.forEach(function (_ref) {
var node = _ref.node;
variableNameUsed[node.name.value] = true;
});
variableDefs.forEach(function (variableDef) {
var variableName = variableDef.variable.name.value;
if (variableNameUsed[variableName] !== true) {
context.reportError(new _error.GraphQLError(unusedVariableMessage(variableName, opName), [variableDef]));
}
});
}
},
VariableDefinition: function VariableDefinition(def) {
variableDefs.push(def);
}
};
}
/***/ }),
/* 69 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fieldsConflictMessage = fieldsConflictMessage;
exports.OverlappingFieldsCanBeMerged = OverlappingFieldsCanBeMerged;
var _error = __webpack_require__(0);
var _find = __webpack_require__(10);
var _find2 = _interopRequireDefault(_find);
var _kinds = __webpack_require__(2);
var _printer = __webpack_require__(4);
var _definition = __webpack_require__(1);
var _typeFromAST = __webpack_require__(9);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2015, 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.
*/
function fieldsConflictMessage(responseName, reason) {
return 'Fields "' + responseName + '" conflict because ' + reasonMessage(reason) + '. Use different aliases on the fields to fetch both if this was ' + 'intentional.';
}
function reasonMessage(reason) {
if (Array.isArray(reason)) {
return reason.map(function (_ref) {
var responseName = _ref[0],
subreason = _ref[1];
return 'subfields "' + responseName + '" conflict because ' + reasonMessage(subreason);
}).join(' and ');
}
return reason;
}
/**
* Overlapping fields can be merged
*
* A selection set is only valid if all fields (including spreading any
* fragments) either correspond to distinct response names or can be merged
* without ambiguity.
*/
function OverlappingFieldsCanBeMerged(context) {
// A memoization for when two fragments are compared "between" each other for
// conflicts. Two fragments may be compared many times, so memoizing this can
// dramatically improve the performance of this validator.
var comparedFragments = new PairSet();
// A cache for the "field map" and list of fragment names found in any given
// selection set. Selection sets may be asked for this information multiple
// times, so this improves the performance of this validator.
var cachedFieldsAndFragmentNames = new Map();
return {
SelectionSet: function SelectionSet(selectionSet) {
var conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragments, context.getParentType(), selectionSet);
conflicts.forEach(function (_ref2) {
var _ref2$ = _ref2[0],
responseName = _ref2$[0],
reason = _ref2$[1],
fields1 = _ref2[1],
fields2 = _ref2[2];
return context.reportError(new _error.GraphQLError(fieldsConflictMessage(responseName, reason), fields1.concat(fields2)));
});
}
};
}
// Field name and reason.
// Reason is a string, or a nested list of conflicts.
// Tuple defining a field node in a context.
// Map of array of those.
/**
* Algorithm:
*
* Conflicts occur when two fields exist in a query which will produce the same
* response name, but represent differing values, thus creating a conflict.
* The algorithm below finds all conflicts via making a series of comparisons
* between fields. In order to compare as few fields as possible, this makes
* a series of comparisons "within" sets of fields and "between" sets of fields.
*
* Given any selection set, a collection produces both a set of fields by
* also including all inline fragments, as well as a list of fragments
* referenced by fragment spreads.
*
* A) Each selection set represented in the document first compares "within" its
* collected set of fields, finding any conflicts between every pair of
* overlapping fields.
* Note: This is the *only time* that a the fields "within" a set are compared
* to each other. After this only fields "between" sets are compared.
*
* B) Also, if any fragment is referenced in a selection set, then a
* comparison is made "between" the original set of fields and the
* referenced fragment.
*
* C) Also, if multiple fragments are referenced, then comparisons
* are made "between" each referenced fragment.
*
* D) When comparing "between" a set of fields and a referenced fragment, first
* a comparison is made between each field in the original set of fields and
* each field in the the referenced set of fields.
*
* E) Also, if any fragment is referenced in the referenced selection set,
* then a comparison is made "between" the original set of fields and the
* referenced fragment (recursively referring to step D).
*
* F) When comparing "between" two fragments, first a comparison is made between
* each field in the first referenced set of fields and each field in the the
* second referenced set of fields.
*
* G) Also, any fragments referenced by the first must be compared to the
* second, and any fragments referenced by the second must be compared to the
* first (recursively referring to step F).
*
* H) When comparing two fields, if both have selection sets, then a comparison
* is made "between" both selection sets, first comparing the set of fields in
* the first selection set with the set of fields in the second.
*
* I) Also, if any fragment is referenced in either selection set, then a
* comparison is made "between" the other set of fields and the
* referenced fragment.
*
* J) Also, if two fragments are referenced in both selection sets, then a
* comparison is made "between" the two fragments.
*
*/
// Find all conflicts found "within" a selection set, including those found
// via spreading in fragments. Called when visiting each SelectionSet in the
// GraphQL Document.
function findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragments, parentType, selectionSet) {
var conflicts = [];
var _getFieldsAndFragment = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet),
fieldMap = _getFieldsAndFragment[0],
fragmentNames = _getFieldsAndFragment[1];
// (A) Find find all conflicts "within" the fields of this selection set.
// Note: this is the *only place* `collectConflictsWithin` is called.
collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, fieldMap);
// (B) Then collect conflicts between these fields and those represented by
// each spread fragment name found.
for (var i = 0; i < fragmentNames.length; i++) {
collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, false, fieldMap, fragmentNames[i]);
// (C) Then compare this fragment with all other fragments found in this
// selection set to collect conflicts between fragments spread together.
// This compares each item in the list of fragment names to every other item
// in that same list (except for itself).
for (var j = i + 1; j < fragmentNames.length; j++) {
collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, false, fragmentNames[i], fragmentNames[j]);
}
}
return conflicts;
}
// Collect all conflicts found between a set of fields and a fragment reference
// including via spreading in any nested fragments.
function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fragmentName) {
var fragment = context.getFragment(fragmentName);
if (!fragment) {
return;
}
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment),
fieldMap2 = _getReferencedFieldsA[0],
fragmentNames2 = _getReferencedFieldsA[1];
// (D) First collect any conflicts between the provided collection of fields
// and the collection of fields represented by the given fragment.
collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fieldMap2);
// (E) Then collect any conflicts between the provided collection of fields
// and any fragment names found in the given fragment.
for (var i = 0; i < fragmentNames2.length; i++) {
collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fragmentNames2[i]);
}
}
// Collect all conflicts found between two fragments, including via spreading in
// any nested fragments.
function collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentName1, fragmentName2) {
var fragment1 = context.getFragment(fragmentName1);
var fragment2 = context.getFragment(fragmentName2);
if (!fragment1 || !fragment2) {
return;
}
// No need to compare a fragment to itself.
if (fragment1 === fragment2) {
return;
}
// Memoize so two fragments are not compared for conflicts more than once.
if (comparedFragments.has(fragmentName1, fragmentName2, areMutuallyExclusive)) {
return;
}
comparedFragments.add(fragmentName1, fragmentName2, areMutuallyExclusive);
var _getReferencedFieldsA2 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment1),
fieldMap1 = _getReferencedFieldsA2[0],
fragmentNames1 = _getReferencedFieldsA2[1];
var _getReferencedFieldsA3 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2),
fieldMap2 = _getReferencedFieldsA3[0],
fragmentNames2 = _getReferencedFieldsA3[1];
// (F) First, collect all conflicts between these two collections of fields
// (not including any nested fragments).
collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fieldMap2);
// (G) Then collect conflicts between the first fragment and any nested
// fragments spread in the second fragment.
for (var j = 0; j < fragmentNames2.length; j++) {
collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentName1, fragmentNames2[j]);
}
// (G) Then collect conflicts between the second fragment and any nested
// fragments spread in the first fragment.
for (var i = 0; i < fragmentNames1.length; i++) {
collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentNames1[i], fragmentName2);
}
}
// Find all conflicts found between two selection sets, including those found
// via spreading in fragments. Called when determining if conflicts exist
// between the sub-fields of two overlapping fields.
function findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, parentType1, selectionSet1, parentType2, selectionSet2) {
var conflicts = [];
var _getFieldsAndFragment2 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType1, selectionSet1),
fieldMap1 = _getFieldsAndFragment2[0],
fragmentNames1 = _getFieldsAndFragment2[1];
var _getFieldsAndFragment3 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType2, selectionSet2),
fieldMap2 = _getFieldsAndFragment3[0],
fragmentNames2 = _getFieldsAndFragment3[1];
// (H) First, collect all conflicts between these two collections of field.
collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fieldMap2);
// (I) Then collect conflicts between the first collection of fields and
// those referenced by each fragment name associated with the second.
for (var j = 0; j < fragmentNames2.length; j++) {
collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fragmentNames2[j]);
}
// (I) Then collect conflicts between the second collection of fields and
// those referenced by each fragment name associated with the first.
for (var i = 0; i < fragmentNames1.length; i++) {
collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap2, fragmentNames1[i]);
}
// (J) Also collect conflicts between any fragment names by the first and
// fragment names by the second. This compares each item in the first set of
// names to each item in the second set of names.
for (var _i = 0; _i < fragmentNames1.length; _i++) {
for (var _j = 0; _j < fragmentNames2.length; _j++) {
collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentNames1[_i], fragmentNames2[_j]);
}
}
return conflicts;
}
// Collect all Conflicts "within" one collection of fields.
function collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, fieldMap) {
// A field map is a keyed collection, where each key represents a response
// name and the value at that key is a list of all fields which provide that
// response name. For every response name, if there are multiple fields, they
// must be compared to find a potential conflict.
Object.keys(fieldMap).forEach(function (responseName) {
var fields = fieldMap[responseName];
// This compares every field in the list to every other field in this list
// (except to itself). If the list only has one item, nothing needs to
// be compared.
if (fields.length > 1) {
for (var i = 0; i < fields.length; i++) {
for (var j = i + 1; j < fields.length; j++) {
var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, false, // within one collection is never mutually exclusive
responseName, fields[i], fields[j]);
if (conflict) {
conflicts.push(conflict);
}
}
}
}
});
}
// Collect all Conflicts between two collections of fields. This is similar to,
// but different from the `collectConflictsWithin` function above. This check
// assumes that `collectConflictsWithin` has already been called on each
// provided collection of fields. This is true because this validator traverses
// each individual selection set.
function collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, fieldMap1, fieldMap2) {
// A field map is a keyed collection, where each key represents a response
// name and the value at that key is a list of all fields which provide that
// response name. For any response name which appears in both provided field
// maps, each field from the first field map must be compared to every field
// in the second field map to find potential conflicts.
Object.keys(fieldMap1).forEach(function (responseName) {
var fields2 = fieldMap2[responseName];
if (fields2) {
var fields1 = fieldMap1[responseName];
for (var i = 0; i < fields1.length; i++) {
for (var j = 0; j < fields2.length; j++) {
var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, responseName, fields1[i], fields2[j]);
if (conflict) {
conflicts.push(conflict);
}
}
}
}
});
}
// Determines if there is a conflict between two particular fields, including
// comparing their sub-fields.
function findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, responseName, field1, field2) {
var parentType1 = field1[0],
node1 = field1[1],
def1 = field1[2];
var parentType2 = field2[0],
node2 = field2[1],
def2 = field2[2];
// If it is known that two fields could not possibly apply at the same
// time, due to the parent types, then it is safe to permit them to diverge
// in aliased field or arguments used as they will not present any ambiguity
// by differing.
// It is known that two parent types could never overlap if they are
// different Object types. Interface or Union types might overlap - if not
// in the current state of the schema, then perhaps in some future version,
// thus may not safely diverge.
var areMutuallyExclusive = parentFieldsAreMutuallyExclusive || parentType1 !== parentType2 && parentType1 instanceof _definition.GraphQLObjectType && parentType2 instanceof _definition.GraphQLObjectType;
// The return type for each field.
var type1 = def1 && def1.type;
var type2 = def2 && def2.type;
if (!areMutuallyExclusive) {
// Two aliases must refer to the same field.
var name1 = node1.name.value;
var name2 = node2.name.value;
if (name1 !== name2) {
return [[responseName, name1 + ' and ' + name2 + ' are different fields'], [node1], [node2]];
}
// Two field calls must have the same arguments.
if (!sameArguments(node1.arguments || [], node2.arguments || [])) {
return [[responseName, 'they have differing arguments'], [node1], [node2]];
}
}
if (type1 && type2 && doTypesConflict(type1, type2)) {
return [[responseName, 'they return conflicting types ' + String(type1) + ' and ' + String(type2)], [node1], [node2]];
}
// Collect and compare sub-fields. Use the same "visited fragment names" list
// for both collections so fields in a fragment reference are never
// compared to themselves.
var selectionSet1 = node1.selectionSet;
var selectionSet2 = node2.selectionSet;
if (selectionSet1 && selectionSet2) {
var conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, (0, _definition.getNamedType)(type1), selectionSet1, (0, _definition.getNamedType)(type2), selectionSet2);
return subfieldConflicts(conflicts, responseName, node1, node2);
}
}
function sameArguments(arguments1, arguments2) {
if (arguments1.length !== arguments2.length) {
return false;
}
return arguments1.every(function (argument1) {
var argument2 = (0, _find2.default)(arguments2, function (argument) {
return argument.name.value === argument1.name.value;
});
if (!argument2) {
return false;
}
return sameValue(argument1.value, argument2.value);
});
}
function sameValue(value1, value2) {
return !value1 && !value2 || (0, _printer.print)(value1) === (0, _printer.print)(value2);
}
// Two types conflict if both types could not apply to a value simultaneously.
// Composite types are ignored as their individual field types will be compared
// later recursively. However List and Non-Null types must match.
function doTypesConflict(type1, type2) {
if (type1 instanceof _definition.GraphQLList) {
return type2 instanceof _definition.GraphQLList ? doTypesConflict(type1.ofType, type2.ofType) : true;
}
if (type2 instanceof _definition.GraphQLList) {
return type1 instanceof _definition.GraphQLList ? doTypesConflict(type1.ofType, type2.ofType) : true;
}
if (type1 instanceof _definition.GraphQLNonNull) {
return type2 instanceof _definition.GraphQLNonNull ? doTypesConflict(type1.ofType, type2.ofType) : true;
}
if (type2 instanceof _definition.GraphQLNonNull) {
return type1 instanceof _definition.GraphQLNonNull ? doTypesConflict(type1.ofType, type2.ofType) : true;
}
if ((0, _definition.isLeafType)(type1) || (0, _definition.isLeafType)(type2)) {
return type1 !== type2;
}
return false;
}
// Given a selection set, return the collection of fields (a mapping of response
// name to field nodes and definitions) as well as a list of fragment names
// referenced via fragment spreads.
function getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet) {
var cached = cachedFieldsAndFragmentNames.get(selectionSet);
if (!cached) {
var nodeAndDefs = {};
var fragmentNames = {};
_collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames);
cached = [nodeAndDefs, Object.keys(fragmentNames)];
cachedFieldsAndFragmentNames.set(selectionSet, cached);
}
return cached;
}
// Given a reference to a fragment, return the represented collection of fields
// as well as a list of nested fragment names referenced via fragment spreads.
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment) {
// Short-circuit building a type from the node if possible.
var cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet);
if (cached) {
return cached;
}
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment.typeCondition);
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment.selectionSet);
}
function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
for (var i = 0; i < selectionSet.selections.length; i++) {
var selection = selectionSet.selections[i];
switch (selection.kind) {
case _kinds.FIELD:
var fieldName = selection.name.value;
var fieldDef = void 0;
if (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType) {
fieldDef = parentType.getFields()[fieldName];
}
var responseName = selection.alias ? selection.alias.value : fieldName;
if (!nodeAndDefs[responseName]) {
nodeAndDefs[responseName] = [];
}
nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
break;
case _kinds.FRAGMENT_SPREAD:
fragmentNames[selection.name.value] = true;
break;
case _kinds.INLINE_FRAGMENT:
var typeCondition = selection.typeCondition;
var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
_collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
break;
}
}
}
// Given a series of Conflicts which occurred between two sub-fields, generate
// a single Conflict.
function subfieldConflicts(conflicts, responseName, node1, node2) {
if (conflicts.length > 0) {
return [[responseName, conflicts.map(function (_ref3) {
var reason = _ref3[0];
return reason;
})], conflicts.reduce(function (allFields, _ref4) {
var fields1 = _ref4[1];
return allFields.concat(fields1);
}, [node1]), conflicts.reduce(function (allFields, _ref5) {
var fields2 = _ref5[2];
return allFields.concat(fields2);
}, [node2])];
}
}
/**
* A way to keep track of pairs of things when the ordering of the pair does
* not matter. We do this by maintaining a sort of double adjacency sets.
*/
var PairSet = function () {
function PairSet() {
_classCallCheck(this, PairSet);
this._data = Object.create(null);
}
PairSet.prototype.has = function has(a, b, areMutuallyExclusive) {
var first = this._data[a];
var result = first && first[b];
if (result === undefined) {
return false;
}
// areMutuallyExclusive being false is a superset of being true,
// hence if we want to know if this PairSet "has" these two with no
// exclusivity, we have to ensure it was added as such.
if (areMutuallyExclusive === false) {
return result === false;
}
return true;
};
PairSet.prototype.add = function add(a, b, areMutuallyExclusive) {
_pairSetAdd(this._data, a, b, areMutuallyExclusive);
_pairSetAdd(this._data, b, a, areMutuallyExclusive);
};
return PairSet;
}();
function _pairSetAdd(data, a, b, areMutuallyExclusive) {
var map = data[a];
if (!map) {
map = Object.create(null);
data[a] = map;
}
map[b] = areMutuallyExclusive;
}
/***/ }),
/* 70 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.typeIncompatibleSpreadMessage = typeIncompatibleSpreadMessage;
exports.typeIncompatibleAnonSpreadMessage = typeIncompatibleAnonSpreadMessage;
exports.PossibleFragmentSpreads = PossibleFragmentSpreads;
var _error = __webpack_require__(0);
var _typeComparators = __webpack_require__(19);
var _typeFromAST = __webpack_require__(9);
/**
* Copyright (c) 2015, 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.
*/
function typeIncompatibleSpreadMessage(fragName, parentType, fragType) {
return 'Fragment "' + fragName + '" cannot be spread here as objects of ' + ('type "' + String(parentType) + '" can never be of type "' + String(fragType) + '".');
}
function typeIncompatibleAnonSpreadMessage(parentType, fragType) {
return 'Fragment cannot be spread here as objects of ' + ('type "' + String(parentType) + '" can never be of type "' + String(fragType) + '".');
}
/**
* Possible fragment spread
*
* A fragment spread is only valid if the type condition could ever possibly
* be true: if there is a non-empty intersection of the possible parent types,
* and possible types which pass the type condition.
*/
function PossibleFragmentSpreads(context) {
return {
InlineFragment: function InlineFragment(node) {
var fragType = context.getType();
var parentType = context.getParentType();
if (fragType && parentType && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
context.reportError(new _error.GraphQLError(typeIncompatibleAnonSpreadMessage(parentType, fragType), [node]));
}
},
FragmentSpread: function FragmentSpread(node) {
var fragName = node.name.value;
var fragType = getFragmentType(context, fragName);
var parentType = context.getParentType();
if (fragType && parentType && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
context.reportError(new _error.GraphQLError(typeIncompatibleSpreadMessage(fragName, parentType, fragType), [node]));
}
}
};
}
function getFragmentType(context, name) {
var frag = context.getFragment(name);
return frag && (0, _typeFromAST.typeFromAST)(context.getSchema(), frag.typeCondition);
}
/***/ }),
/* 71 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.missingFieldArgMessage = missingFieldArgMessage;
exports.missingDirectiveArgMessage = missingDirectiveArgMessage;
exports.ProvidedNonNullArguments = ProvidedNonNullArguments;
var _error = __webpack_require__(0);
var _keyMap = __webpack_require__(12);
var _keyMap2 = _interopRequireDefault(_keyMap);
var _definition = __webpack_require__(1);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Copyright (c) 2015, 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.
*/
function missingFieldArgMessage(fieldName, argName, type) {
return 'Field "' + fieldName + '" argument "' + argName + '" of type ' + ('"' + String(type) + '" is required but not provided.');
}
function missingDirectiveArgMessage(directiveName, argName, type) {
return 'Directive "@' + directiveName + '" argument "' + argName + '" of type ' + ('"' + String(type) + '" is required but not provided.');
}
/**
* Provided required arguments
*
* A field or directive is only valid if all required (non-null) field arguments
* have been provided.
*/
function ProvidedNonNullArguments(context) {
return {
Field: {
// Validate on leave to allow for deeper errors to appear first.
leave: function leave(node) {
var fieldDef = context.getFieldDef();
if (!fieldDef) {
return false;
}
var argNodes = node.arguments || [];
var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
return arg.name.value;
});
fieldDef.args.forEach(function (argDef) {
var argNode = argNodeMap[argDef.name];
if (!argNode && argDef.type instanceof _definition.GraphQLNonNull) {
context.reportError(new _error.GraphQLError(missingFieldArgMessage(node.name.value, argDef.name, argDef.type), [node]));
}
});
}
},
Directive: {
// Validate on leave to allow for deeper errors to appear first.
leave: function leave(node) {
var directiveDef = context.getDirective();
if (!directiveDef) {
return false;
}
var argNodes = node.arguments || [];
var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
return arg.name.value;
});
directiveDef.args.forEach(function (argDef) {
var argNode = argNodeMap[argDef.name];
if (!argNode && argDef.type instanceof _definition.GraphQLNonNull) {
context.reportError(new _error.GraphQLError(missingDirectiveArgMessage(node.name.value, argDef.name, argDef.type), [node]));
}
});
}
}
};
}
/***/ }),
/* 72 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.noSubselectionAllowedMessage = noSubselectionAllowedMessage;
exports.requiredSubselectionMessage = requiredSubselectionMessage;
exports.ScalarLeafs = ScalarLeafs;
var _error = __webpack_require__(0);
var _definition = __webpack_require__(1);
function noSubselectionAllowedMessage(fieldName, type) {
return 'Field "' + fieldName + '" must not have a selection since ' + ('type "' + String(type) + '" has no subfields.');
}
/**
* Copyright (c) 2015, 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.
*/
function requiredSubselectionMessage(fieldName, type) {
return 'Field "' + fieldName + '" of type "' + String(type) + '" must have a ' + ('selection of subfields. Did you mean "' + fieldName + ' { ... }"?');
}
/**
* Scalar leafs
*
* A GraphQL document is valid only if all leaf fields (fields without
* sub selections) are of scalar or enum types.
*/
function ScalarLeafs(context) {
return {
Field: function Field(node) {
var type = context.getType();
if (type) {
if ((0, _definition.isLeafType)(type)) {
if (node.selectionSet) {
context.reportError(new _error.GraphQLError(noSubselectionAllowedMessage(node.name.value, type), [node.selectionSet]));
}
} else if (!node.selectionSet) {
context.reportError(new _error.GraphQLError(requiredSubselectionMessage(node.name.value, type), [node]));
}
}
}
};
}
/***/ }),
/* 73 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.duplicateArgMessage = duplicateArgMessage;
exports.UniqueArgumentNames = UniqueArgumentNames;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function duplicateArgMessage(argName) {
return 'There can be only one argument named "' + argName + '".';
}
/**
* Unique argument names
*
* A GraphQL field or directive is only valid if all supplied arguments are
* uniquely named.
*/
function UniqueArgumentNames(context) {
var knownArgNames = Object.create(null);
return {
Field: function Field() {
knownArgNames = Object.create(null);
},
Directive: function Directive() {
knownArgNames = Object.create(null);
},
Argument: function Argument(node) {
var argName = node.name.value;
if (knownArgNames[argName]) {
context.reportError(new _error.GraphQLError(duplicateArgMessage(argName), [knownArgNames[argName], node.name]));
} else {
knownArgNames[argName] = node.name;
}
return false;
}
};
}
/***/ }),
/* 74 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.duplicateDirectiveMessage = duplicateDirectiveMessage;
exports.UniqueDirectivesPerLocation = UniqueDirectivesPerLocation;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function duplicateDirectiveMessage(directiveName) {
return 'The directive "' + directiveName + '" can only be used once at ' + 'this location.';
}
/**
* Unique directive names per location
*
* A GraphQL document is only valid if all directives at a given location
* are uniquely named.
*/
function UniqueDirectivesPerLocation(context) {
return {
// Many different AST nodes may contain directives. Rather than listing
// them all, just listen for entering any node, and check to see if it
// defines any directives.
enter: function enter(node) {
if (node.directives) {
(function () {
var knownDirectives = Object.create(null);
node.directives.forEach(function (directive) {
var directiveName = directive.name.value;
if (knownDirectives[directiveName]) {
context.reportError(new _error.GraphQLError(duplicateDirectiveMessage(directiveName), [knownDirectives[directiveName], directive]));
} else {
knownDirectives[directiveName] = directive;
}
});
})();
}
}
};
}
/***/ }),
/* 75 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.duplicateFragmentNameMessage = duplicateFragmentNameMessage;
exports.UniqueFragmentNames = UniqueFragmentNames;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function duplicateFragmentNameMessage(fragName) {
return 'There can only be one fragment named "' + fragName + '".';
}
/**
* Unique fragment names
*
* A GraphQL document is only valid if all defined fragments have unique names.
*/
function UniqueFragmentNames(context) {
var knownFragmentNames = Object.create(null);
return {
OperationDefinition: function OperationDefinition() {
return false;
},
FragmentDefinition: function FragmentDefinition(node) {
var fragmentName = node.name.value;
if (knownFragmentNames[fragmentName]) {
context.reportError(new _error.GraphQLError(duplicateFragmentNameMessage(fragmentName), [knownFragmentNames[fragmentName], node.name]));
} else {
knownFragmentNames[fragmentName] = node.name;
}
return false;
}
};
}
/***/ }),
/* 76 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.duplicateInputFieldMessage = duplicateInputFieldMessage;
exports.UniqueInputFieldNames = UniqueInputFieldNames;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function duplicateInputFieldMessage(fieldName) {
return 'There can be only one input field named "' + fieldName + '".';
}
/**
* Unique input field names
*
* A GraphQL input object value is only valid if all supplied fields are
* uniquely named.
*/
function UniqueInputFieldNames(context) {
var knownNameStack = [];
var knownNames = Object.create(null);
return {
ObjectValue: {
enter: function enter() {
knownNameStack.push(knownNames);
knownNames = Object.create(null);
},
leave: function leave() {
knownNames = knownNameStack.pop();
}
},
ObjectField: function ObjectField(node) {
var fieldName = node.name.value;
if (knownNames[fieldName]) {
context.reportError(new _error.GraphQLError(duplicateInputFieldMessage(fieldName), [knownNames[fieldName], node.name]));
} else {
knownNames[fieldName] = node.name;
}
return false;
}
};
}
/***/ }),
/* 77 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.duplicateOperationNameMessage = duplicateOperationNameMessage;
exports.UniqueOperationNames = UniqueOperationNames;
var _error = __webpack_require__(0);
/**
* Copyright (c) 2015, 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.
*/
function duplicateOperationNameMessage(operationName) {
return 'There can only be one operation named "' + operationName + '".';
}
/**
* Unique operation names
*
* A GraphQL document is only valid if all defined operations have unique names.
*/
function UniqueOperationNames(context) {
var knownOperationNames = Object.create(null);
return {
OperationDefinition: function OperationDefinition(node) {
var operationName = node.name;
if (operationName) {
if (knownOperationNames[operationName.value]) {
context.reportError(new _error.GraphQLError(duplicateOperationNameMessage(operationName.value), [knownOperationNames[operationName.value], operationName]));
} else {
knownOperationNames[operationName.value] = operationName;
}
}
return false;
},
FragmentDefinition: function FragmentDefinition() {
return false;
}
};
}
/***/ }),
/* 78 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.duplicateVariableMessage = duplicateVariableMessage;
exports.UniqueVariableNames = UniqueVariableNames;
var _error = __webpack_require__(0);
function duplicateVariableMessage(variableName) {
return 'There can be only one variable named "' + variableName + '".';
}
/**
* Unique variable names
*
* A GraphQL operation is only valid if all its variables are uniquely named.
*/
/**
* Copyright (c) 2015, 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.
*/
function UniqueVariableNames(context) {
var knownVariableNames = Object.create(null);
return {
OperationDefinition: function OperationDefinition() {
knownVariableNames = Object.create(null);
},
VariableDefinition: function VariableDefinition(node) {
var variableName = node.variable.name.value;
if (knownVariableNames[variableName]) {
context.reportError(new _error.GraphQLError(duplicateVariableMessage(variableName), [knownVariableNames[variableName], node.variable.name]));
} else {
knownVariableNames[variableName] = node.variable.name;
}
}
};
}
/***/ }),
/* 79 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.nonInputTypeOnVarMessage = nonInputTypeOnVarMessage;
exports.VariablesAreInputTypes = VariablesAreInputTypes;
var _error = __webpack_require__(0);
var _printer = __webpack_require__(4);
var _definition = __webpack_require__(1);
var _typeFromAST = __webpack_require__(9);
function nonInputTypeOnVarMessage(variableName, typeName) {
return 'Variable "$' + variableName + '" cannot be non-input type "' + typeName + '".';
}
/**
* Variables are input types
*
* A GraphQL operation is only valid if all the variables it defines are of
* input types (scalar, enum, or input object).
*/
/**
* Copyright (c) 2015, 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.
*/
function VariablesAreInputTypes(context) {
return {
VariableDefinition: function VariableDefinition(node) {
var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.type);
// If the variable type is not an input type, return an error.
if (type && !(0, _definition.isInputType)(type)) {
var variableName = node.variable.name.value;
context.reportError(new _error.GraphQLError(nonInputTypeOnVarMessage(variableName, (0, _printer.print)(node.type)), [node.type]));
}
}
};
}
/***/ }),
/* 80 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.badVarPosMessage = badVarPosMessage;
exports.VariablesInAllowedPosition = VariablesInAllowedPosition;
var _error = __webpack_require__(0);
var _definition = __webpack_require__(1);
var _typeComparators = __webpack_require__(19);
var _typeFromAST = __webpack_require__(9);
function badVarPosMessage(varName, varType, expectedType) {
return 'Variable "$' + varName + '" of type "' + String(varType) + '" used in ' + ('position expecting type "' + String(expectedType) + '".');
}
/**
* Variables passed to field arguments conform to type
*/
/**
* Copyright (c) 2015, 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.
*/
function VariablesInAllowedPosition(context) {
var varDefMap = Object.create(null);
return {
OperationDefinition: {
enter: function enter() {
varDefMap = Object.create(null);
},
leave: function leave(operation) {
var usages = context.getRecursiveVariableUsages(operation);
usages.forEach(function (_ref) {
var node = _ref.node,
type = _ref.type;
var varName = node.name.value;
var varDef = varDefMap[varName];
if (varDef && type) {
// A var type is allowed if it is the same or more strict (e.g. is
// a subtype of) than the expected type. It can be more strict if
// the variable type is non-null when the expected type is nullable.
// If both are list types, the variable item type can be more strict
// than the expected item type (contravariant).
var schema = context.getSchema();
var varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type);
if (varType && !(0, _typeComparators.isTypeSubTypeOf)(schema, effectiveType(varType, varDef), type)) {
context.reportError(new _error.GraphQLError(badVarPosMessage(varName, varType, type), [varDef, node]));
}
}
});
}
},
VariableDefinition: function VariableDefinition(node) {
varDefMap[node.variable.name.value] = node;
}
};
}
// If a variable definition has a default value, it's effectively non-null.
function effectiveType(varType, varDef) {
return !varDef.defaultValue || varType instanceof _definition.GraphQLNonNull ? varType : new _definition.GraphQLNonNull(varType);
}
/***/ })
/******/ ]);