Initial Save

This commit is contained in:
jackbeeby
2025-03-28 12:30:19 +11:00
parent e381994f19
commit d8773925e8
9910 changed files with 982718 additions and 0 deletions

146
node_modules/graphql-tools/dist/Interfaces.d.ts generated vendored Normal file
View File

@@ -0,0 +1,146 @@
import { GraphQLSchema, GraphQLField, ExecutionResult, GraphQLType, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLIsTypeOfFn, GraphQLTypeResolver, GraphQLScalarType, GraphQLNamedType, DocumentNode, ASTNode } from 'graphql';
import { SchemaDirectiveVisitor } from './schemaVisitor';
export declare type UnitOrList<Type> = Type | Array<Type>;
export interface IResolverValidationOptions {
requireResolversForArgs?: boolean;
requireResolversForNonScalar?: boolean;
requireResolversForAllFields?: boolean;
requireResolversForResolveType?: boolean;
allowResolversNotInSchema?: boolean;
}
export interface IAddResolveFunctionsToSchemaOptions {
schema: GraphQLSchema;
resolvers: IResolvers;
resolverValidationOptions?: IResolverValidationOptions;
inheritResolversFromInterfaces?: boolean;
}
export interface IResolverOptions<TSource = any, TContext = any, TArgs = any> {
fragment?: string;
resolve?: IFieldResolver<TSource, TContext, TArgs>;
subscribe?: IFieldResolver<TSource, TContext, TArgs>;
__resolveType?: GraphQLTypeResolver<TSource, TContext>;
__isTypeOf?: GraphQLIsTypeOfFn<TSource, TContext>;
}
export declare type Transform = {
transformSchema?: (schema: GraphQLSchema) => GraphQLSchema;
transformRequest?: (originalRequest: Request) => Request;
transformResult?: (result: Result) => Result;
};
export interface IGraphQLToolsResolveInfo extends GraphQLResolveInfo {
mergeInfo?: MergeInfo;
}
export interface IDelegateToSchemaOptions<TContext = {
[key: string]: any;
}> {
schema: GraphQLSchema;
operation: Operation;
fieldName: string;
args?: {
[key: string]: any;
};
context: TContext;
info: IGraphQLToolsResolveInfo;
transforms?: Array<Transform>;
skipValidation?: boolean;
}
export declare type MergeInfo = {
delegate: (type: 'query' | 'mutation' | 'subscription', fieldName: string, args: {
[key: string]: any;
}, context: {
[key: string]: any;
}, info: GraphQLResolveInfo, transforms?: Array<Transform>) => any;
delegateToSchema<TContext>(options: IDelegateToSchemaOptions<TContext>): any;
fragments: Array<{
field: string;
fragment: string;
}>;
};
export declare type IFieldResolver<TSource, TContext, TArgs = Record<string, any>> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo & {
mergeInfo: MergeInfo;
}) => any;
export declare type ITypedef = (() => ITypedef[]) | string | DocumentNode | ASTNode;
export declare type ITypeDefinitions = ITypedef | ITypedef[];
export declare type IResolverObject<TSource = any, TContext = any, TArgs = any> = {
[key: string]: IFieldResolver<TSource, TContext, TArgs> | IResolverOptions<TSource, TContext> | IResolverObject<TSource, TContext>;
};
export declare type IEnumResolver = {
[key: string]: string | number;
};
export interface IResolvers<TSource = any, TContext = any> {
[key: string]: (() => any) | IResolverObject<TSource, TContext> | IResolverOptions<TSource, TContext> | GraphQLScalarType | IEnumResolver;
}
export declare type IResolversParameter = Array<IResolvers | ((mergeInfo: MergeInfo) => IResolvers)> | IResolvers | ((mergeInfo: MergeInfo) => IResolvers);
export interface ILogger {
log: (message: string | Error) => void;
}
export interface IConnectorCls<TContext = any> {
new (context?: TContext): any;
}
export declare type IConnectorFn<TContext = any> = (context?: TContext) => any;
export declare type IConnector<TContext = any> = IConnectorCls<TContext> | IConnectorFn<TContext>;
export declare type IConnectors<TContext = any> = {
[key: string]: IConnector<TContext>;
};
export interface IExecutableSchemaDefinition<TContext = any> {
typeDefs: ITypeDefinitions;
resolvers?: IResolvers<any, TContext> | Array<IResolvers<any, TContext>>;
connectors?: IConnectors<TContext>;
logger?: ILogger;
allowUndefinedInResolve?: boolean;
resolverValidationOptions?: IResolverValidationOptions;
directiveResolvers?: IDirectiveResolvers<any, TContext>;
schemaDirectives?: {
[name: string]: typeof SchemaDirectiveVisitor;
};
parseOptions?: GraphQLParseOptions;
inheritResolversFromInterfaces?: boolean;
}
export declare type IFieldIteratorFn = (fieldDef: GraphQLField<any, any>, typeName: string, fieldName: string) => void;
export declare type NextResolverFn = () => Promise<any>;
export declare type DirectiveResolverFn<TSource = any, TContext = any> = (next: NextResolverFn, source: TSource, args: {
[argName: string]: any;
}, context: TContext, info: GraphQLResolveInfo) => any;
export interface IDirectiveResolvers<TSource = any, TContext = any> {
[directiveName: string]: DirectiveResolverFn<TSource, TContext>;
}
export declare type IMockFn = GraphQLFieldResolver<any, any>;
export declare type IMocks = {
[key: string]: IMockFn;
};
export declare type IMockTypeFn = (type: GraphQLType, typeName?: string, fieldName?: string) => GraphQLFieldResolver<any, any>;
export interface IMockOptions {
schema: GraphQLSchema;
mocks?: IMocks;
preserveResolvers?: boolean;
}
export interface IMockServer {
query: (query: string, vars?: {
[key: string]: any;
}) => Promise<ExecutionResult>;
}
export declare type MergeTypeCandidate = {
schema?: GraphQLSchema;
type: GraphQLNamedType;
};
export declare type TypeWithResolvers = {
type: GraphQLNamedType;
resolvers?: IResolvers;
};
export declare type VisitTypeResult = GraphQLNamedType | TypeWithResolvers | null;
export declare type VisitType = (name: string, candidates: Array<MergeTypeCandidate>) => VisitTypeResult;
export declare type Operation = 'query' | 'mutation' | 'subscription';
export declare type Request = {
document: DocumentNode;
variables: Record<string, any>;
extensions?: Record<string, any>;
};
export declare type Result = ExecutionResult & {
extensions?: Record<string, any>;
};
export declare type ResolveType<T extends GraphQLType> = (type: T) => T;
export declare type GraphQLParseOptions = {
noLocation?: boolean;
allowLegacySDLEmptyFields?: boolean;
allowLegacySDLImplementsInterfaces?: boolean;
experimentalFragmentVariables?: boolean;
};

2
node_modules/graphql-tools/dist/Interfaces.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Interfaces.js.map

1
node_modules/graphql-tools/dist/Interfaces.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../src/Interfaces.ts"],"names":[],"mappings":""}

10
node_modules/graphql-tools/dist/Logger.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import { ILogger } from './Interfaces';
export declare class Logger implements ILogger {
errors: Error[];
name: string;
private callback;
constructor(name?: string, callback?: Function);
log(err: Error): void;
printOneError(e: Error): string;
printAllErrors(): string;
}

28
node_modules/graphql-tools/dist/Logger.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/*
* A very simple class for logging errors
*/
Object.defineProperty(exports, "__esModule", { value: true });
var Logger = /** @class */ (function () {
function Logger(name, callback) {
this.name = name;
this.errors = [];
this.callback = callback;
// TODO: should assert that callback is a function
}
Logger.prototype.log = function (err) {
this.errors.push(err);
if (typeof this.callback === 'function') {
this.callback(err);
}
};
Logger.prototype.printOneError = function (e) {
return e.stack;
};
Logger.prototype.printAllErrors = function () {
var _this = this;
return this.errors.reduce(function (agg, e) { return agg + "\n" + _this.printOneError(e); }, '');
};
return Logger;
}());
exports.Logger = Logger;
//# sourceMappingURL=Logger.js.map

1
node_modules/graphql-tools/dist/Logger.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../src/Logger.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAIH;IAKE,gBAAY,IAAa,EAAE,QAAmB;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,kDAAkD;IACpD,CAAC;IAEM,oBAAG,GAAV,UAAW,GAAU;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAE;YACvC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SACpB;IACH,CAAC;IAEM,8BAAa,GAApB,UAAqB,CAAQ;QAC3B,OAAO,CAAC,CAAC,KAAK,CAAC;IACjB,CAAC;IAEM,+BAAc,GAArB;QAAA,iBAKC;QAJC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CACvB,UAAC,GAAG,EAAE,CAAC,IAAK,OAAG,GAAG,UAAK,KAAI,CAAC,aAAa,CAAC,CAAC,CAAG,EAAlC,CAAkC,EAC9C,EAAE,CACH,CAAC;IACJ,CAAC;IACH,aAAC;AAAD,CAAC,AA7BD,IA6BC;AA7BY,wBAAM"}

View File

@@ -0,0 +1,4 @@
export default class SchemaError extends Error {
message: string;
constructor(message: string);
}

View File

@@ -0,0 +1,28 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
// @schemaDefinition: A GraphQL type schema in shorthand
// @resolvers: Definitions for resolvers to be merged with schema
var SchemaError = /** @class */ (function (_super) {
__extends(SchemaError, _super);
function SchemaError(message) {
var _this = _super.call(this, message) || this;
_this.message = message;
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return SchemaError;
}(Error));
exports.default = SchemaError;
//# sourceMappingURL=SchemaError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SchemaError.js","sourceRoot":"","sources":["../../src/generate/SchemaError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,wDAAwD;AACxD,iEAAiE;AACjE;IAAyC,+BAAK;IAG5C,qBAAY,OAAe;QAA3B,YACE,kBAAM,OAAO,CAAC,SAGf;QAFC,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,KAAK,CAAC,iBAAiB,CAAC,KAAI,EAAE,KAAI,CAAC,WAAW,CAAC,CAAC;;IAClD,CAAC;IACH,kBAAC;AAAD,CAAC,AARD,CAAyC,KAAK,GAQ7C"}

View File

@@ -0,0 +1,4 @@
import { GraphQLSchema } from 'graphql';
import { IResolvers, IResolverValidationOptions, IAddResolveFunctionsToSchemaOptions } from '../Interfaces';
declare function addResolveFunctionsToSchema(options: IAddResolveFunctionsToSchemaOptions | GraphQLSchema, legacyInputResolvers?: IResolvers, legacyInputValidationOptions?: IResolverValidationOptions): GraphQLSchema;
export default addResolveFunctionsToSchema;

View File

@@ -0,0 +1,119 @@
Object.defineProperty(exports, "__esModule", { value: true });
var _1 = require(".");
var graphql_1 = require("graphql");
var transforms_1 = require("../transforms/transforms");
var _2 = require(".");
var ConvertEnumValues_1 = require("../transforms/ConvertEnumValues");
function addResolveFunctionsToSchema(options, legacyInputResolvers, legacyInputValidationOptions) {
if (options instanceof graphql_1.GraphQLSchema) {
console.warn('The addResolveFunctionsToSchema function takes named options now; see IAddResolveFunctionsToSchemaOptions');
options = {
schema: options,
resolvers: legacyInputResolvers,
resolverValidationOptions: legacyInputValidationOptions,
};
}
var schema = options.schema, inputResolvers = options.resolvers, _a = options.resolverValidationOptions, resolverValidationOptions = _a === void 0 ? {} : _a, _b = options.inheritResolversFromInterfaces, inheritResolversFromInterfaces = _b === void 0 ? false : _b;
var _c = resolverValidationOptions.allowResolversNotInSchema, allowResolversNotInSchema = _c === void 0 ? false : _c, requireResolversForResolveType = resolverValidationOptions.requireResolversForResolveType;
var resolvers = inheritResolversFromInterfaces
? _2.extendResolversFromInterfaces(schema, inputResolvers)
: inputResolvers;
// Used to map the external value of an enum to its internal value, when
// that internal value is provided by a resolver.
var enumValueMap = Object.create(null);
Object.keys(resolvers).forEach(function (typeName) {
var resolverValue = resolvers[typeName];
var resolverType = typeof resolverValue;
if (resolverType !== 'object' && resolverType !== 'function') {
throw new _1.SchemaError("\"" + typeName + "\" defined in resolvers, but has invalid value \"" + resolverValue + "\". A resolver's value " +
"must be of type object or function.");
}
var type = schema.getType(typeName);
if (!type && typeName !== '__schema') {
if (allowResolversNotInSchema) {
return;
}
throw new _1.SchemaError("\"" + typeName + "\" defined in resolvers, but not in schema");
}
Object.keys(resolverValue).forEach(function (fieldName) {
if (fieldName.startsWith('__')) {
// this is for isTypeOf and resolveType and all the other stuff.
type[fieldName.substring(2)] = resolverValue[fieldName];
return;
}
if (type instanceof graphql_1.GraphQLScalarType) {
type[fieldName] = resolverValue[fieldName];
return;
}
if (type instanceof graphql_1.GraphQLEnumType) {
if (!type.getValue(fieldName)) {
if (allowResolversNotInSchema) {
return;
}
throw new _1.SchemaError(typeName + "." + fieldName + " was defined in resolvers, but enum is not in schema");
}
// We've encountered an enum resolver that is being used to provide an
// internal enum value.
// Reference: https://www.apollographql.com/docs/graphql-tools/scalars.html#internal-values
//
// We're storing a map of the current enums external facing value to
// its resolver provided internal value. This map is used to transform
// the current schema to a new schema that includes enums with the new
// internal value.
enumValueMap[type.name] = enumValueMap[type.name] || {};
enumValueMap[type.name][fieldName] = resolverValue[fieldName];
return;
}
// object type
var fields = getFieldsForType(type);
if (!fields) {
if (allowResolversNotInSchema) {
return;
}
throw new _1.SchemaError(typeName + " was defined in resolvers, but it's not an object");
}
if (!fields[fieldName]) {
if (allowResolversNotInSchema) {
return;
}
throw new _1.SchemaError(typeName + "." + fieldName + " defined in resolvers, but not in schema");
}
var field = fields[fieldName];
var fieldResolve = resolverValue[fieldName];
if (typeof fieldResolve === 'function') {
// for convenience. Allows shorter syntax in resolver definition file
setFieldProperties(field, { resolve: fieldResolve });
}
else {
if (typeof fieldResolve !== 'object') {
throw new _1.SchemaError("Resolver " + typeName + "." + fieldName + " must be object or function");
}
setFieldProperties(field, fieldResolve);
}
});
});
_2.checkForResolveTypeResolver(schema, requireResolversForResolveType);
// If there are any enum resolver functions (that are used to return
// internal enum values), create a new schema that includes enums with the
// new internal facing values.
var updatedSchema = transforms_1.applySchemaTransforms(schema, [
new ConvertEnumValues_1.default(enumValueMap),
]);
return updatedSchema;
}
function getFieldsForType(type) {
if (type instanceof graphql_1.GraphQLObjectType ||
type instanceof graphql_1.GraphQLInterfaceType) {
return type.getFields();
}
else {
return undefined;
}
}
function setFieldProperties(field, propertiesObj) {
Object.keys(propertiesObj).forEach(function (propertyName) {
field[propertyName] = propertiesObj[propertyName];
});
}
exports.default = addResolveFunctionsToSchema;
//# sourceMappingURL=addResolveFunctionsToSchema.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"addResolveFunctionsToSchema.js","sourceRoot":"","sources":["../../src/generate/addResolveFunctionsToSchema.ts"],"names":[],"mappings":";AAAA,sBAAgC;AAEhC,mCASiB;AAOjB,uDAAiE;AACjE,sBAA+E;AAC/E,qEAAgE;AAEhE,SAAS,2BAA2B,CAClC,OAA4D,EAC5D,oBAAiC,EACjC,4BAAyD;IAEzD,IAAI,OAAO,YAAY,uBAAa,EAAE;QACpC,OAAO,CAAC,IAAI,CACV,2GAA2G,CAC5G,CAAC;QACF,OAAO,GAAG;YACR,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,oBAAoB;YAC/B,yBAAyB,EAAE,4BAA4B;SACxD,CAAC;KACH;IAGC,IAAA,uBAAM,EACN,kCAAyB,EACzB,sCAA8B,EAA9B,mDAA8B,EAC9B,2CAAsC,EAAtC,2DAAsC,CAC5B;IAGV,IAAA,wDAAiC,EAAjC,sDAAiC,EACjC,yFAA8B,CACF;IAE9B,IAAM,SAAS,GAAG,8BAA8B;QAC9C,CAAC,CAAC,gCAA6B,CAAC,MAAM,EAAE,cAAc,CAAC;QACvD,CAAC,CAAC,cAAc,CAAC;IAEnB,wEAAwE;IACxE,iDAAiD;IACjD,IAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAA,QAAQ;QACrC,IAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAM,YAAY,GAAG,OAAO,aAAa,CAAC;QAE1C,IAAI,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,UAAU,EAAE;YAC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AY,8BAAoB,EACpC;QACA,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;KACzB;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,SAAS,kBAAkB,CACzB,KAA6B,EAC7B,aAAqB;IAErB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,UAAA,YAAY;QAC7C,KAAK,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,2BAA2B,CAAC"}

View File

@@ -0,0 +1,3 @@
import { GraphQLSchema, GraphQLFieldResolver } from 'graphql';
declare function addSchemaLevelResolveFunction(schema: GraphQLSchema, fn: GraphQLFieldResolver<any, any>): void;
export default addSchemaLevelResolveFunction;

View File

@@ -0,0 +1,61 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
// wraps all resolve functions of query, mutation or subscription fields
// with the provided function to simulate a root schema level resolve funciton
function addSchemaLevelResolveFunction(schema, fn) {
// TODO test that schema is a schema, fn is a function
var rootTypes = [
schema.getQueryType(),
schema.getMutationType(),
schema.getSubscriptionType(),
].filter(function (x) { return !!x; });
rootTypes.forEach(function (type) {
// XXX this should run at most once per request to simulate a true root resolver
// for graphql-js this is an approximation that works with queries but not mutations
var rootResolveFn = runAtMostOncePerRequest(fn);
var fields = type.getFields();
Object.keys(fields).forEach(function (fieldName) {
// XXX if the type is a subscription, a same query AST will be ran multiple times so we
// deactivate here the runOnce if it's a subscription. This may not be optimal though...
if (type === schema.getSubscriptionType()) {
fields[fieldName].resolve = wrapResolver(fields[fieldName].resolve, fn);
}
else {
fields[fieldName].resolve = wrapResolver(fields[fieldName].resolve, rootResolveFn);
}
});
});
}
// XXX badly named function. this doesn't really wrap, it just chains resolvers...
function wrapResolver(innerResolver, outerResolver) {
return function (obj, args, ctx, info) {
return Promise.resolve(outerResolver(obj, args, ctx, info)).then(function (root) {
if (innerResolver) {
return innerResolver(root, args, ctx, info);
}
return graphql_1.defaultFieldResolver(root, args, ctx, info);
});
};
}
// XXX this function only works for resolvers
// XXX very hacky way to remember if the function
// already ran for this request. This will only work
// if people don't actually cache the operation.
// if they do cache the operation, they will have to
// manually remove the __runAtMostOnce before every request.
function runAtMostOncePerRequest(fn) {
var value;
var randomNumber = Math.random();
return function (root, args, ctx, info) {
if (!info.operation['__runAtMostOnce']) {
info.operation['__runAtMostOnce'] = {};
}
if (!info.operation['__runAtMostOnce'][randomNumber]) {
info.operation['__runAtMostOnce'][randomNumber] = true;
value = fn(root, args, ctx, info);
}
return value;
};
}
exports.default = addSchemaLevelResolveFunction;
//# sourceMappingURL=addSchemaLevelResolveFunction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"addSchemaLevelResolveFunction.js","sourceRoot":"","sources":["../../src/generate/addSchemaLevelResolveFunction.ts"],"names":[],"mappings":";AAAA,mCAIiB;AAEjB,wEAAwE;AACxE,8EAA8E;AAC9E,SAAS,6BAA6B,CACpC,MAAqB,EACrB,EAAkC;IAElC,sDAAsD;IACtD,IAAM,SAAS,GAAG;QAChB,MAAM,CAAC,YAAY,EAAE;QACrB,MAAM,CAAC,eAAe,EAAE;QACxB,MAAM,CAAC,mBAAmB,EAAE;KAC7B,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC,CAAC;IACnB,SAAS,CAAC,OAAO,CAAC,UAAA,IAAI;QACpB,gFAAgF;QAChF,oFAAoF;QACpF,IAAM,aAAa,GAAG,uBAAuB,CAAC,EAAE,CAAC,CAAC;QAClD,IAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAA,SAAS;YACnC,uFAAuF;YACvF,wFAAwF;YACxF,IAAI,IAAI,KAAK,MAAM,CAAC,mBAAmB,EAAE,EAAE;gBACzC,MAAM,C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AAiB,CAAC,CAAC,YAAY,CAAC,EAAE;YACpD,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;YACvD,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;SACnC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,6BAA6B,CAAC"}

View File

@@ -0,0 +1,4 @@
import { GraphQLSchema } from 'graphql';
import { IResolverValidationOptions } from '../Interfaces';
declare function assertResolveFunctionsPresent(schema: GraphQLSchema, resolverValidationOptions?: IResolverValidationOptions): void;
export default assertResolveFunctionsPresent;

View File

@@ -0,0 +1,41 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var _1 = require(".");
function assertResolveFunctionsPresent(schema, resolverValidationOptions) {
if (resolverValidationOptions === void 0) { resolverValidationOptions = {}; }
var _a = resolverValidationOptions.requireResolversForArgs, requireResolversForArgs = _a === void 0 ? false : _a, _b = resolverValidationOptions.requireResolversForNonScalar, requireResolversForNonScalar = _b === void 0 ? false : _b, _c = resolverValidationOptions.requireResolversForAllFields, requireResolversForAllFields = _c === void 0 ? false : _c;
if (requireResolversForAllFields &&
(requireResolversForArgs || requireResolversForNonScalar)) {
throw new TypeError('requireResolversForAllFields takes precedence over the more specific assertions. ' +
'Please configure either requireResolversForAllFields or requireResolversForArgs / ' +
'requireResolversForNonScalar, but not a combination of them.');
}
_1.forEachField(schema, function (field, typeName, fieldName) {
// requires a resolve function for *every* field.
if (requireResolversForAllFields) {
expectResolveFunction(field, typeName, fieldName);
}
// requires a resolve function on every field that has arguments
if (requireResolversForArgs && field.args.length > 0) {
expectResolveFunction(field, typeName, fieldName);
}
// requires a resolve function on every field that returns a non-scalar type
if (requireResolversForNonScalar &&
!(graphql_1.getNamedType(field.type) instanceof graphql_1.GraphQLScalarType)) {
expectResolveFunction(field, typeName, fieldName);
}
});
}
function expectResolveFunction(field, typeName, fieldName) {
if (!field.resolve) {
console.warn(
// tslint:disable-next-line: max-line-length
"Resolve function missing for \"" + typeName + "." + fieldName + "\". To disable this warning check https://github.com/apollostack/graphql-tools/issues/131");
return;
}
if (typeof field.resolve !== 'function') {
throw new _1.SchemaError("Resolver \"" + typeName + "." + fieldName + "\" must be a function");
}
}
exports.default = assertResolveFunctionsPresent;
//# sourceMappingURL=assertResolveFunctionsPresent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"assertResolveFunctionsPresent.js","sourceRoot":"","sources":["../../src/generate/assertResolveFunctionsPresent.ts"],"names":[],"mappings":";AAAA,mCAKiB;AAGjB,sBAA8C;AAE9C,SAAS,6BAA6B,CACpC,MAAqB,EACrB,yBAA0D;IAA1D,0CAAA,EAAA,8BAA0D;IAGxD,IAAA,sDAA+B,EAA/B,oDAA+B,EAC/B,2DAAoC,EAApC,yDAAoC,EACpC,2DAAoC,EAApC,yDAAoC,CACR;IAE9B,IACE,4BAA4B;QAC5B,CAAC,uBAAuB,IAAI,4BAA4B,CAAC,EACzD;QACA,MAAM,IAAI,SAAS,CACjB,mFAAmF;YACjF,oFAAoF;YACpF,8DAA8D,CACjE,CAAC;KACH;IAED,eAAY,CAAC,MAAM,EAAE,UAAC,KAAK,EAAE,QAAQ,EAAE,SAAS;QAC9C,iDAAiD;QACjD,IAAI,4BAA4B,EAAE;YAChC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;SACnD;QAED,gEAAgE;QAChE,IAAI,uBAAuB,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACpD,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;SACnD;QAED,4EAA4E;QAC5E,IACE,4BAA4B;YAC5B,CAAC,CAAC,sBAAY,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,2BAAiB,CAAC,EACxD;YACA,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;SACnD;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAC5B,KAA6B,EAC7B,QAAgB,EAChB,SAAiB;IAEjB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;QAClB,OAAO,CAAC,IAAI;QACV,4CAA4C;QAC5C,oCAAiC,QAAQ,SAAI,SAAS,8FAA0F,CACjJ,CAAC;QACF,OAAO;KACR;IACD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE;QACvC,MAAM,IAAI,cAAW,CACnB,gBAAa,QAAQ,SAAI,SAAS,0BAAsB,CACzD,CAAC;KACH;AACH,CAAC;AAED,kBAAe,6BAA6B,CAAC"}

View File

@@ -0,0 +1,2 @@
declare const attachConnectorsToContext: Function;
export default attachConnectorsToContext;

View File

@@ -0,0 +1,55 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var deprecated_decorator_1 = require("deprecated-decorator");
var _1 = require(".");
// takes a GraphQL-JS schema and an object of connectors, then attaches
// the connectors to the context by wrapping each query or mutation resolve
// function with a function that attaches connectors if they don't exist.
// attaches connectors only once to make sure they are singletons
var attachConnectorsToContext = deprecated_decorator_1.deprecated({
version: '0.7.0',
url: 'https://github.com/apollostack/graphql-tools/issues/140',
}, function (schema, connectors) {
if (!schema || !(schema instanceof graphql_1.GraphQLSchema)) {
throw new Error('schema must be an instance of GraphQLSchema. ' +
'This error could be caused by installing more than one version of GraphQL-JS');
}
if (typeof connectors !== 'object') {
var connectorType = typeof connectors;
throw new Error("Expected connectors to be of type object, got " + connectorType);
}
if (Object.keys(connectors).length === 0) {
throw new Error('Expected connectors to not be an empty object');
}
if (Array.isArray(connectors)) {
throw new Error('Expected connectors to be of type object, got Array');
}
if (schema['_apolloConnectorsAttached']) {
throw new Error('Connectors already attached to context, cannot attach more than once');
}
schema['_apolloConnectorsAttached'] = true;
var attachconnectorFn = function (root, args, ctx) {
if (typeof ctx !== 'object') {
// if in any way possible, we should throw an error when the attachconnectors
// function is called, not when a query is executed.
var contextType = typeof ctx;
throw new Error("Cannot attach connector because context is not an object: " + contextType);
}
if (typeof ctx.connectors === 'undefined') {
ctx.connectors = {};
}
Object.keys(connectors).forEach(function (connectorName) {
var connector = connectors[connectorName];
if (!!connector.prototype) {
ctx.connectors[connectorName] = new connector(ctx);
}
else {
throw new Error("Connector must be a function or an class");
}
});
return root;
};
_1.addSchemaLevelResolveFunction(schema, attachconnectorFn);
});
exports.default = attachConnectorsToContext;
//# sourceMappingURL=attachConnectorsToContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"attachConnectorsToContext.js","sourceRoot":"","sources":["../../src/generate/attachConnectorsToContext.ts"],"names":[],"mappings":";AAAA,mCAA8D;AAE9D,6DAAkD;AAIlD,sBAAkD;AAElD,uEAAuE;AACvE,2EAA2E;AAC3E,yEAAyE;AACzE,iEAAiE;AACjE,IAAM,yBAAyB,GAAG,iCAAU,CAC1C;IACE,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE,yDAAyD;CAC/D,EACD,UAAS,MAAqB,EAAE,UAAuB;IACrD,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,YAAY,uBAAa,CAAC,EAAE;QACjD,MAAM,IAAI,KAAK,CACb,+CAA+C;YAC7C,8EAA8E,CACjF,CAAC;KACH;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,IAAM,aAAa,GAAG,OAAO,UAAU,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,mDAAiD,aAAe,CACjE,CAAC;KACH;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KACxE;IACD,IAAI,MAAM,CAAC,2BAA2B,CAAC,EAAE;QACvC,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;KACH;IACD,MAAM,CAAC,2BAA2B,CAAC,GAAG,IAAI,CAAC;IAC3C,IAAM,iBAAiB,GAAmC,UACxD,IAAS,EACT,IAA4B,EAC5B,GAAQ;QAER,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,6EAA6E;YAC7E,oDAAoD;YACpD,IAAM,WAAW,GAAG,OAAO,GAAG,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,+DAA6D,WAAa,CAC3E,CAAC;SACH;QACD,IAAI,OAAO,GAAG,CAAC,UAAU,KAAK,WAAW,EAAE;YACzC,GAAG,CAAC,UAAU,GAAG,EAAE,CAAC;SACrB;QACD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,aAAa;YAC3C,IAAI,SAAS,GAAe,UAAU,CAAC,aAAa,CAAC,CAAC;YACtD,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE;gBACzB,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,IAAoB,SAAU,CAAC,GAAG,CAAC,CAAC;aACrE;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;aAC7D;QACH,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,gCAA6B,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC3D,CAAC,CACF,CAAC;AAEF,kBAAe,yBAAyB,CAAC"}

View File

@@ -0,0 +1,4 @@
import { GraphQLSchema } from 'graphql';
import { IDirectiveResolvers } from '../Interfaces';
declare function attachDirectiveResolvers(schema: GraphQLSchema, directiveResolvers: IDirectiveResolvers<any, any>): void;
export default attachDirectiveResolvers;

View File

@@ -0,0 +1,89 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var schemaVisitor_1 = require("../schemaVisitor");
function attachDirectiveResolvers(schema, directiveResolvers) {
if (typeof directiveResolvers !== 'object') {
throw new Error("Expected directiveResolvers to be of type object, got " + typeof directiveResolvers);
}
if (Array.isArray(directiveResolvers)) {
throw new Error('Expected directiveResolvers to be of type object, got Array');
}
var schemaDirectives = Object.create(null);
Object.keys(directiveResolvers).forEach(function (directiveName) {
schemaDirectives[directiveName] = /** @class */ (function (_super) {
__extends(class_1, _super);
function class_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_1.prototype.visitFieldDefinition = function (field) {
var _this = this;
var resolver = directiveResolvers[directiveName];
var originalResolver = field.resolve || graphql_1.defaultFieldResolver;
var directiveArgs = this.args;
field.resolve = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var source = args[0] /* original args */, context = args[2], info = args[3];
return resolver(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/, originalResolver.apply(field, args)];
}); }); }, source, directiveArgs, context, info);
};
};
return class_1;
}(schemaVisitor_1.SchemaDirectiveVisitor));
});
schemaVisitor_1.SchemaDirectiveVisitor.visitSchemaDirectives(schema, schemaDirectives);
}
exports.default = attachDirectiveResolvers;
//# sourceMappingURL=attachDirectiveResolvers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"attachDirectiveResolvers.js","sourceRoot":"","sources":["../../src/generate/attachDirectiveResolvers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA4E;AAE5E,kDAA0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ACzE,CAAC;AAED,kBAAe,wBAAwB,CAAC"}

View File

@@ -0,0 +1,4 @@
import { GraphQLSchema } from 'graphql';
import { ITypeDefinitions, GraphQLParseOptions } from '../Interfaces';
declare function buildSchemaFromTypeDefinitions(typeDefinitions: ITypeDefinitions, parseOptions?: GraphQLParseOptions): GraphQLSchema;
export default buildSchemaFromTypeDefinitions;

View File

@@ -0,0 +1,37 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var _1 = require(".");
var filterExtensionDefinitions_1 = require("./filterExtensionDefinitions");
function buildSchemaFromTypeDefinitions(typeDefinitions, parseOptions) {
// TODO: accept only array here, otherwise interfaces get confusing.
var myDefinitions = typeDefinitions;
var astDocument;
if (isDocumentNode(typeDefinitions)) {
astDocument = typeDefinitions;
}
else if (typeof myDefinitions !== 'string') {
if (!Array.isArray(myDefinitions)) {
var type = typeof myDefinitions;
throw new _1.SchemaError("typeDefs must be a string, array or schema AST, got " + type);
}
myDefinitions = _1.concatenateTypeDefs(myDefinitions);
}
if (typeof myDefinitions === 'string') {
astDocument = graphql_1.parse(myDefinitions, parseOptions);
}
var backcompatOptions = { commentDescriptions: true };
var typesAst = filterExtensionDefinitions_1.default(astDocument);
// TODO fix types https://github.com/apollographql/graphql-tools/issues/542
var schema = graphql_1.buildASTSchema(typesAst, backcompatOptions);
var extensionsAst = _1.extractExtensionDefinitions(astDocument);
if (extensionsAst.definitions.length > 0) {
// TODO fix types https://github.com/apollographql/graphql-tools/issues/542
schema = graphql_1.extendSchema(schema, extensionsAst, backcompatOptions);
}
return schema;
}
function isDocumentNode(typeDefinitions) {
return typeDefinitions.kind !== undefined;
}
exports.default = buildSchemaFromTypeDefinitions;
//# sourceMappingURL=buildSchemaFromTypeDefinitions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"buildSchemaFromTypeDefinitions.js","sourceRoot":"","sources":["../../src/generate/buildSchemaFromTypeDefinitions.ts"],"names":[],"mappings":";AAAA,mCAMiB;AAGjB,s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ldResolver } from 'graphql';
export declare function chainResolvers(resolvers: GraphQLFieldResolver<any, any>[]): (root: any, args: {
[argName: string]: any;
}, ctx: any, info: GraphQLResolveInfo) => any;

View File

@@ -0,0 +1,14 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
function chainResolvers(resolvers) {
return function (root, args, ctx, info) {
return resolvers.reduce(function (prev, curResolver) {
if (curResolver) {
return curResolver(prev, args, ctx, info);
}
return graphql_1.defaultFieldResolver(prev, args, ctx, info);
}, root);
};
}
exports.chainResolvers = chainResolvers;
//# sourceMappingURL=chainResolvers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chainResolvers.js","sourceRoot":"","sources":["../../src/generate/chainResolvers.ts"],"names":[],"mappings":";AAAA,mCAAyF;AAEzF,SAAgB,cAAc,CAAC,SAA2C;IACxE,OAAO,UAAC,IAAS,EAAE,IAAgC,EAAE,GAAQ,EAAE,IAAwB;QACrF,OAAO,SAAS,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,WAAW;YACxC,IAAI,WAAW,EAAE;gBACf,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;aAC3C;YAED,OAAO,8BAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC,CAAC;AACJ,CAAC;AAVD,wCAUC"}

View File

@@ -0,0 +1,3 @@
import { GraphQLSchema } from 'graphql';
declare function checkForResolveTypeResolver(schema: GraphQLSchema, requireResolversForResolveType?: boolean): void;
export default checkForResolveTypeResolver;

View File

@@ -0,0 +1,27 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var _1 = require(".");
// If we have any union or interface types throw if no there is no resolveType or isTypeOf resolvers
function checkForResolveTypeResolver(schema, requireResolversForResolveType) {
Object.keys(schema.getTypeMap())
.map(function (typeName) { return schema.getType(typeName); })
.forEach(function (type) {
if (!(type instanceof graphql_1.GraphQLUnionType ||
type instanceof graphql_1.GraphQLInterfaceType)) {
return;
}
if (!type.resolveType) {
if (requireResolversForResolveType === false) {
return;
}
if (requireResolversForResolveType === true) {
throw new _1.SchemaError("Type \"" + type.name + "\" is missing a \"resolveType\" resolver");
}
// tslint:disable-next-line:max-line-length
console.warn("Type \"" + type.name + "\" is missing a \"__resolveType\" resolver. Pass false into " +
"\"resolverValidationOptions.requireResolversForResolveType\" to disable this warning.");
}
});
}
exports.default = checkForResolveTypeResolver;
//# sourceMappingURL=checkForResolveTypeResolver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"checkForResolveTypeResolver.js","sourceRoot":"","sources":["../../src/generate/checkForResolveTypeResolver.ts"],"names":[],"mappings":";AAAA,mCAAgF;AAEhF,sBAAgC;AAEhC,oGAAoG;AACpG,SAAS,2BAA2B,CAClC,MAAqB,EACrB,8BAAwC;IAExC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SAC7B,GAAG,CAAC,UAAA,QAAQ,IAAI,OAAA,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAxB,CAAwB,CAAC;SACzC,OAAO,CAAC,UAAC,IAA6C;QACrD,IACE,CAAC,CACC,IAAI,YAAY,0BAAgB;YAChC,IAAI,YAAY,8BAAoB,CACrC,EACD;YACA,OAAO;SACR;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,8BAA8B,KAAK,KAAK,EAAE;gBAC5C,OAAO;aACR;YACD,IAAI,8BAA8B,KAAK,IAAI,EAAE;gBAC3C,MAAM,IAAI,cAAW,CACnB,YAAS,IAAI,CAAC,IAAI,6CAAuC,CAC1D,CAAC;aACH;YACD,2CAA2C;YAC3C,OAAO,CAAC,IAAI,CACV,YACE,IAAI,CAAC,IAAI,iEACgD;gBAC3D,uFAAqF,CACtF,CAAC;SACH;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AACD,kBAAe,2BAA2B,CAAC"}

View File

@@ -0,0 +1,3 @@
import { ITypedef } from '../Interfaces';
declare function concatenateTypeDefs(typeDefinitionsAry: ITypedef[], calledFunctionRefs?: any): string;
export default concatenateTypeDefs;

View File

@@ -0,0 +1,41 @@
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var _1 = require(".");
function concatenateTypeDefs(typeDefinitionsAry, calledFunctionRefs) {
if (calledFunctionRefs === void 0) { calledFunctionRefs = []; }
var resolvedTypeDefinitions = [];
typeDefinitionsAry.forEach(function (typeDef) {
if (typeDef.kind !== undefined) {
typeDef = graphql_1.print(typeDef);
}
if (typeof typeDef === 'function') {
if (calledFunctionRefs.indexOf(typeDef) === -1) {
calledFunctionRefs.push(typeDef);
resolvedTypeDefinitions = resolvedTypeDefinitions.concat(concatenateTypeDefs(typeDef(), calledFunctionRefs));
}
}
else if (typeof typeDef === 'string') {
resolvedTypeDefinitions.push(typeDef.trim());
}
else {
var type = typeof typeDef;
throw new _1.SchemaError("typeDef array must contain only strings and functions, got " + type);
}
});
return uniq(resolvedTypeDefinitions.map(function (x) { return x.trim(); })).join('\n');
}
function uniq(array) {
return array.reduce(function (accumulator, currentValue) {
return accumulator.indexOf(currentValue) === -1
? __spreadArrays(accumulator, [currentValue]) : accumulator;
}, []);
}
exports.default = concatenateTypeDefs;
//# sourceMappingURL=concatenateTypeDefs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"concatenateTypeDefs.js","sourceRoot":"","sources":["../../src/generate/concatenateTypeDefs.ts"],"names":[],"mappings":";;;;;;;;AAAA,mCAAuD;AAGvD,sBAAgC;AAEhC,SAAS,mBAAmB,CAC1B,kBAA8B,EAC9B,kB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BAAmB,CAAC"}

View File

@@ -0,0 +1,4 @@
import { GraphQLFieldResolver } from 'graphql';
import { ILogger } from '../Interfaces';
declare function decorateWithLogger(fn: GraphQLFieldResolver<any, any> | undefined, logger: ILogger, hint: string): GraphQLFieldResolver<any, any>;
export default decorateWithLogger;

View File

@@ -0,0 +1,48 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
/*
* fn: The function to decorate with the logger
* logger: an object instance of type Logger
* hint: an optional hint to add to the error's message
*/
function decorateWithLogger(fn, logger, hint) {
if (typeof fn === 'undefined') {
fn = graphql_1.defaultFieldResolver;
}
var logError = function (e) {
// TODO: clone the error properly
var newE = new Error();
newE.stack = e.stack;
/* istanbul ignore else: always get the hint from addErrorLoggingToSchema */
if (hint) {
newE['originalMessage'] = e.message;
newE['message'] = "Error in resolver " + hint + "\n" + e.message;
}
logger.log(newE);
};
return function (root, args, ctx, info) {
try {
var result = fn(root, args, ctx, info);
// If the resolve function returns a Promise log any Promise rejects.
if (result &&
typeof result.then === 'function' &&
typeof result.catch === 'function') {
result.catch(function (reason) {
// make sure that it's an error we're logging.
var error = reason instanceof Error ? reason : new Error(reason);
logError(error);
// We don't want to leave an unhandled exception so pass on error.
return reason;
});
}
return result;
}
catch (e) {
logError(e);
// we want to pass on the error, just in case.
throw e;
}
};
}
exports.default = decorateWithLogger;
//# sourceMappingURL=decorateWithLogger.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"decorateWithLogger.js","sourceRoot":"","sources":["../../src/generate/decorateWithLogger.ts"],"names":[],"mappings":";AAAA,mCAAqE;AAGrE;;;;GAIG;AACH,SAAS,kBAAkB,CACzB,EAA8C,EAC9C,MAAe,EACf,IAAY;IAEZ,IAAI,OAAO,EAAE,KAAK,WAAW,EAAE;QAC7B,EAAE,GAAG,8BAAoB,CAAC;KAC3B;IAED,IAAM,QAAQ,GAAG,UAAC,CAAQ;QACxB,iCAAiC;QACjC,IAAM,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QACrB,4EAA4E;QAC5E,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YACpC,IAAI,CAAC,SAAS,CAAC,GAAG,uBAAqB,IAAI,UAAK,CAAC,CAAC,OAAS,CAAC;SAC7D;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,UAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI;QAC3B,IAAI;YACF,IAAM,MAAM,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YACzC,qEAAqE;YACrE,IACE,MAAM;gBACN,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU;gBACjC,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,EAClC;gBACA,MAAM,CAAC,KAAK,CAAC,UAAC,MAAsB;oBAClC,8CAA8C;oBAC9C,IAAM,KAAK,GAAG,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;oBACnE,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAEhB,kEAAkE;oBAClE,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC,CAAC;aACJ;YACD,OAAO,MAAM,CAAC;SACf;QAAC,OAAO,CAAC,EAAE;YACV,QAAQ,CAAC,CAAC,CAAC,CAAC;YACZ,8CAA8C;YAC9C,MAAM,CAAC,CAAC;SACT;IACH,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,4 @@
import { GraphQLSchema } from 'graphql';
import { IResolvers } from '../Interfaces';
declare function extendResolversFromInterfaces(schema: GraphQLSchema, resolvers: IResolvers): IResolvers<any, any>;
export default extendResolversFromInterfaces;

View File

@@ -0,0 +1,42 @@
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
function extendResolversFromInterfaces(schema, resolvers) {
var typeNames = Object.keys(__assign(__assign({}, schema.getTypeMap()), resolvers));
var extendedResolvers = {};
typeNames.forEach(function (typeName) {
var typeResolvers = resolvers[typeName];
var type = schema.getType(typeName);
if (type instanceof graphql_1.GraphQLObjectType) {
var interfaceResolvers = type
.getInterfaces()
.map(function (iFace) { return resolvers[iFace.name]; });
extendedResolvers[typeName] = Object.assign.apply(Object, __spreadArrays([{}], interfaceResolvers, [typeResolvers]));
}
else {
if (typeResolvers) {
extendedResolvers[typeName] = typeResolvers;
}
}
});
return extendedResolvers;
}
exports.default = extendResolversFromInterfaces;
//# sourceMappingURL=extendResolversFromInterfaces.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"extendResolversFromInterfaces.js","sourceRoot":"","sources":["../../src/generate/extendResolversFromInterfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,mCAA2D;AAI3D,SAAS,6BAA6B,CACpC,MAAqB,EACrB,SAAqB;IAErB,IAAM,SAAS,GAAG,MAAM,CAAC,IAAI,uBACxB,MAAM,CAAC,UAAU,EAAE,GACnB,SAAS,EACZ,CAAC;IAEH,IAAM,iBAAiB,GAAe,EAAE,CAAC;IACzC,SAAS,CAAC,OAAO,CAAC,UAAA,QAAQ;QACxB,IAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,IAAI,YAAY,2BAAiB,EAAE;YACrC,IAAM,kBAAkB,GAAG,IAAI;iBAC5B,aAAa,EAAE;iBACf,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC,CAAC;YACvC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,OAAb,MAAM,kBAClC,EAAE,GACC,kBAAkB,GACrB,aAAa,GACd,CAAC;SACH;aAAM;YACL,IAAI,aAAa,EAAE;gBACjB,iBAAiB,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC;aAC7C;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,kBAAe,6BAA6B,CAAC"}

View File

@@ -0,0 +1,4 @@
import { DocumentNode, DefinitionNode } from 'graphql';
export default function extractExtensionDefinitions(ast: DocumentNode): DocumentNode & {
definitions: DefinitionNode[];
};

View File

@@ -0,0 +1,20 @@
Object.defineProperty(exports, "__esModule", { value: true });
var newExtensionDefinitionKind = 'ObjectTypeExtension';
var interfaceExtensionDefinitionKind = 'InterfaceTypeExtension';
var inputObjectExtensionDefinitionKind = 'InputObjectTypeExtension';
var unionExtensionDefinitionKind = 'UnionTypeExtension';
var enumExtensionDefinitionKind = 'EnumTypeExtension';
function extractExtensionDefinitions(ast) {
var extensionDefs = ast.definitions.filter(function (def) {
return def.kind === newExtensionDefinitionKind ||
def.kind === interfaceExtensionDefinitionKind ||
def.kind === inputObjectExtensionDefinitionKind ||
def.kind === unionExtensionDefinitionKind ||
def.kind === enumExtensionDefinitionKind;
});
return Object.assign({}, ast, {
definitions: extensionDefs,
});
}
exports.default = extractExtensionDefinitions;
//# sourceMappingURL=extractExtensionDefinitions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"extractExtensionDefinitions.js","sourceRoot":"","sources":["../../src/generate/extractExtensionDefinitions.ts"],"names":[],"mappings":";AAEA,IAAM,0BAA0B,GAAG,qBAAqB,CAAC;AACzD,IAAM,gCAAgC,GAAG,wBAAwB,CAAC;AAClE,IAAM,kCAAkC,GAAG,0BAA0B,CAAC;AACtE,IAAM,4BAA4B,GAAG,oBAAoB,CAAC;AAC1D,IAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAExD,SAAwB,2BAA2B,CAAC,GAAiB;IACnE,IAAM,aAAa,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,CAC1C,UAAC,GAAmB;QAClB,OAAC,GAAG,CAAC,IAAY,KAAK,0BAA0B;YAC/C,GAAG,CAAC,IAAY,KAAK,gCAAgC;YACrD,GAAG,CAAC,IAAY,KAAK,kCAAkC;YACvD,GAAG,CAAC,IAAY,KAAK,4BAA4B;YACjD,GAAG,CAAC,IAAY,KAAK,2BAA2B;IAJjD,CAIiD,CACpD,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE;QAC5B,WAAW,EAAE,aAAa;KAC3B,CAAC,CAAC;AACL,CAAC;AAbD,8CAaC"}

View File

@@ -0,0 +1,6 @@
import { DocumentNode, DefinitionNode } from 'graphql';
export default function filterExtensionDefinitions(ast: DocumentNode): {
definitions: DefinitionNode[];
kind: "Document";
loc?: import("graphql").Location;
};

View File

@@ -0,0 +1,27 @@
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
function filterExtensionDefinitions(ast) {
var extensionDefs = ast.definitions.filter(function (def) {
return def.kind !== graphql_1.Kind.OBJECT_TYPE_EXTENSION &&
def.kind !== graphql_1.Kind.INTERFACE_TYPE_EXTENSION &&
def.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION &&
def.kind !== graphql_1.Kind.UNION_TYPE_EXTENSION &&
def.kind !== graphql_1.Kind.ENUM_TYPE_EXTENSION &&
def.kind !== graphql_1.Kind.SCALAR_TYPE_EXTENSION &&
def.kind !== graphql_1.Kind.SCHEMA_EXTENSION;
});
return __assign(__assign({}, ast), { definitions: extensionDefs });
}
exports.default = filterExtensionDefinitions;
//# sourceMappingURL=filterExtensionDefinitions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"filterExtensionDefinitions.js","sourceRoot":"","sources":["../../src/generate/filterExtensionDefinitions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA6D;AAE7D,SAAwB,0BAA0B,CAAC,GAAiB;IAClE,IAAM,aAAa,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,CAC1C,UAAC,GAAmB;QAClB,OAAA,GAAG,CAAC,IAAI,KAAK,cAAI,CAAC,qBAAqB;YACvC,GAAG,CAAC,IAAI,KAAK,cAAI,CAAC,wBAAwB;YAC1C,GAAG,CAAC,IAAI,KAAK,cAAI,CAAC,2BAA2B;YAC7C,GAAG,CAAC,IAAI,KAAK,cAAI,CAAC,oBAAoB;YACtC,GAAG,CAAC,IAAI,KAAK,cAAI,CAAC,mBAAmB;YACrC,GAAG,CAAC,IAAI,KAAK,cAAI,CAAC,qBAAqB;YACvC,GAAG,CAAC,IAAI,KAAK,cAAI,CAAC,gBAAgB;IANlC,CAMkC,CACrC,CAAC;IAEF,6BACK,GAAG,KACN,WAAW,EAAE,aAAa,IAC1B;AACJ,CAAC;AAhBD,6CAgBC"}

View File

@@ -0,0 +1,4 @@
import { GraphQLSchema } from 'graphql';
import { IFieldIteratorFn } from '../Interfaces';
declare function forEachField(schema: GraphQLSchema, fn: IFieldIteratorFn): void;
export default forEachField;

View File

@@ -0,0 +1,19 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
function forEachField(schema, fn) {
var typeMap = schema.getTypeMap();
Object.keys(typeMap).forEach(function (typeName) {
var type = typeMap[typeName];
// TODO: maybe have an option to include these?
if (!graphql_1.getNamedType(type).name.startsWith('__') &&
type instanceof graphql_1.GraphQLObjectType) {
var fields_1 = type.getFields();
Object.keys(fields_1).forEach(function (fieldName) {
var field = fields_1[fieldName];
fn(field, typeName, fieldName);
});
}
});
}
exports.default = forEachField;
//# sourceMappingURL=forEachField.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"forEachField.js","sourceRoot":"","sources":["../../src/generate/forEachField.ts"],"names":[],"mappings":";AAAA,mCAAyE;AAGzE,SAAS,YAAY,CAAC,MAAqB,EAAE,EAAoB;IAC/D,IAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAA,QAAQ;QACnC,IAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE/B,+CAA+C;QAC/C,IACE,CAAC,sBAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACzC,IAAI,YAAY,2BAAiB,EACjC;YACA,IAAM,QAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,QAAM,CAAC,CAAC,OAAO,CAAC,UAAA,SAAS;gBACnC,IAAM,KAAK,GAAG,QAAM,CAAC,SAAS,CAAC,CAAC;gBAChC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,YAAY,CAAC"}

14
node_modules/graphql-tools/dist/generate/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
export { default as addResolveFunctionsToSchema } from './addResolveFunctionsToSchema';
export { default as addSchemaLevelResolveFunction } from './addSchemaLevelResolveFunction';
export { default as assertResolveFunctionsPresent } from './assertResolveFunctionsPresent';
export { default as attachDirectiveResolvers } from './attachDirectiveResolvers';
export { default as attachConnectorsToContext } from './attachConnectorsToContext';
export { default as buildSchemaFromTypeDefinitions } from './buildSchemaFromTypeDefinitions';
export { chainResolvers } from './chainResolvers';
export { default as checkForResolveTypeResolver } from './checkForResolveTypeResolver';
export { default as concatenateTypeDefs } from './concatenateTypeDefs';
export { default as decorateWithLogger } from './decorateWithLogger';
export { default as extendResolversFromInterfaces } from './extendResolversFromInterfaces';
export { default as extractExtensionDefinitions } from './extractExtensionDefinitions';
export { default as forEachField } from './forEachField';
export { default as SchemaError } from './SchemaError';

30
node_modules/graphql-tools/dist/generate/index.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
Object.defineProperty(exports, "__esModule", { value: true });
var addResolveFunctionsToSchema_1 = require("./addResolveFunctionsToSchema");
exports.addResolveFunctionsToSchema = addResolveFunctionsToSchema_1.default;
var addSchemaLevelResolveFunction_1 = require("./addSchemaLevelResolveFunction");
exports.addSchemaLevelResolveFunction = addSchemaLevelResolveFunction_1.default;
var assertResolveFunctionsPresent_1 = require("./assertResolveFunctionsPresent");
exports.assertResolveFunctionsPresent = assertResolveFunctionsPresent_1.default;
var attachDirectiveResolvers_1 = require("./attachDirectiveResolvers");
exports.attachDirectiveResolvers = attachDirectiveResolvers_1.default;
var attachConnectorsToContext_1 = require("./attachConnectorsToContext");
exports.attachConnectorsToContext = attachConnectorsToContext_1.default;
var buildSchemaFromTypeDefinitions_1 = require("./buildSchemaFromTypeDefinitions");
exports.buildSchemaFromTypeDefinitions = buildSchemaFromTypeDefinitions_1.default;
var chainResolvers_1 = require("./chainResolvers");
exports.chainResolvers = chainResolvers_1.chainResolvers;
var checkForResolveTypeResolver_1 = require("./checkForResolveTypeResolver");
exports.checkForResolveTypeResolver = checkForResolveTypeResolver_1.default;
var concatenateTypeDefs_1 = require("./concatenateTypeDefs");
exports.concatenateTypeDefs = concatenateTypeDefs_1.default;
var decorateWithLogger_1 = require("./decorateWithLogger");
exports.decorateWithLogger = decorateWithLogger_1.default;
var extendResolversFromInterfaces_1 = require("./extendResolversFromInterfaces");
exports.extendResolversFromInterfaces = extendResolversFromInterfaces_1.default;
var extractExtensionDefinitions_1 = require("./extractExtensionDefinitions");
exports.extractExtensionDefinitions = extractExtensionDefinitions_1.default;
var forEachField_1 = require("./forEachField");
exports.forEachField = forEachField_1.default;
var SchemaError_1 = require("./SchemaError");
exports.SchemaError = SchemaError_1.default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generate/index.ts"],"names":[],"mappings":";AAAA,6EAAuF;AAA9E,oEAAA,OAAO,CAA+B;AAC/C,iFAA2F;AAAlF,wEAAA,OAAO,CAAiC;AACjD,iFAA2F;AAAlF,wEAAA,OAAO,CAAiC;AACjD,uEAAiF;AAAxE,8DAAA,OAAO,CAA4B;AAC5C,yEAAmF;AAA1E,gEAAA,OAAO,CAA6B;AAC7C,mFAA6F;AAApF,0EAAA,OAAO,CAAkC;AAClD,mDAAkD;AAAzC,0CAAA,cAAc,CAAA;AACvB,6EAAuF;AAA9E,oEAAA,OAAO,CAA+B;AAC/C,6DAAuE;AAA9D,oDAAA,OAAO,CAAuB;AACvC,2DAAqE;AAA5D,kDAAA,OAAO,CAAsB;AACtC,iFAA2F;AAAlF,wEAAA,OAAO,CAAiC;AACjD,6EAAuF;AAA9E,oEAAA,OAAO,CAA+B;AAC/C,+CAAyD;AAAhD,sCAAA,OAAO,CAAgB;AAChC,6CAAuD;AAA9C,oCAAA,OAAO,CAAe"}

View File

@@ -0,0 +1,2 @@
import { GraphQLType, GraphQLSchema } from 'graphql';
export default function implementsAbstractType(schema: GraphQLSchema, typeA: GraphQLType, typeB: GraphQLType): boolean;

View File

@@ -0,0 +1,15 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
function implementsAbstractType(schema, typeA, typeB) {
if (typeA === typeB) {
return true;
}
else if (graphql_1.isCompositeType(typeA) && graphql_1.isCompositeType(typeB)) {
return graphql_1.doTypesOverlap(schema, typeA, typeB);
}
else {
return false;
}
}
exports.default = implementsAbstractType;
//# sourceMappingURL=implementsAbstractType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"implementsAbstractType.js","sourceRoot":"","sources":["../src/implementsAbstractType.ts"],"names":[],"mappings":";AAAA,mCAKiB;AAEjB,SAAwB,sBAAsB,CAC5C,MAAqB,EACrB,KAAkB,EAClB,KAAkB;IAElB,IAAI,KAAK,KAAK,KAAK,EAAE;QACnB,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,yBAAe,CAAC,KAAK,CAAC,IAAI,yBAAe,CAAC,KAAK,CAAC,EAAE;QAC3D,OAAO,wBAAc,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KAC7C;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAZD,yCAYC"}

6
node_modules/graphql-tools/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export * from './Interfaces';
export * from './makeExecutableSchema';
export * from './mock';
export * from './stitching';
export * from './transforms';
export { SchemaDirectiveVisitor } from './schemaVisitor';

11
node_modules/graphql-tools/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./makeExecutableSchema"));
__export(require("./mock"));
__export(require("./stitching"));
__export(require("./transforms"));
var schemaVisitor_1 = require("./schemaVisitor");
exports.SchemaDirectiveVisitor = schemaVisitor_1.SchemaDirectiveVisitor;
//# sourceMappingURL=index.js.map

1
node_modules/graphql-tools/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,4CAAuC;AACvC,4BAAuB;AACvB,iCAA4B;AAC5B,kCAA6B;AAC7B,iDAAyD;AAAhD,iDAAA,sBAAsB,CAAA"}

1
node_modules/graphql-tools/dist/isEmptyObject.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export default function isEmptyObject(obj: Object): boolean;

14
node_modules/graphql-tools/dist/isEmptyObject.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
Object.defineProperty(exports, "__esModule", { value: true });
function isEmptyObject(obj) {
if (!obj) {
return true;
}
for (var key in obj) {
if (Object.hasOwnProperty.call(obj, key)) {
return false;
}
}
return true;
}
exports.default = isEmptyObject;
//# sourceMappingURL=isEmptyObject.js.map

1
node_modules/graphql-tools/dist/isEmptyObject.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"isEmptyObject.js","sourceRoot":"","sources":["../src/isEmptyObject.ts"],"names":[],"mappings":";AAAA,SAAwB,aAAa,CAAC,GAAW;IAC/C,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAI,CAAC;KACb;IAED,KAAK,IAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;YACxC,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,gCAWC"}

View File

@@ -0,0 +1,3 @@
import { GraphQLScalarType } from 'graphql';
export declare const specifiedScalarTypes: Array<GraphQLScalarType>;
export default function isSpecifiedScalarType(type: any): boolean;

View File

@@ -0,0 +1,22 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
// FIXME: Replace with https://github.com/graphql/graphql-js/blob/master/src/type/scalars.js#L139
exports.specifiedScalarTypes = [
graphql_1.GraphQLString,
graphql_1.GraphQLInt,
graphql_1.GraphQLFloat,
graphql_1.GraphQLBoolean,
graphql_1.GraphQLID,
];
function isSpecifiedScalarType(type) {
return (graphql_1.isNamedType(type) &&
// Would prefer to use specifiedScalarTypes.some(), however %checks needs
// a simple expression.
(type.name === graphql_1.GraphQLString.name ||
type.name === graphql_1.GraphQLInt.name ||
type.name === graphql_1.GraphQLFloat.name ||
type.name === graphql_1.GraphQLBoolean.name ||
type.name === graphql_1.GraphQLID.name));
}
exports.default = isSpecifiedScalarType;
//# sourceMappingURL=isSpecifiedScalarType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isSpecifiedScalarType.js","sourceRoot":"","sources":["../src/isSpecifiedScalarType.ts"],"names":[],"mappings":";AAAA,mCAQiB;AAEjB,iGAAiG;AAEpF,QAAA,oBAAoB,GAA6B;IAC5D,uBAAa;IACb,oBAAU;IACV,sBAAY;IACZ,wBAAc;IACd,mBAAS;CACV,CAAC;AAEF,SAAwB,qBAAqB,CAAC,IAAS;IACrD,OAAO,CACL,qBAAW,CAAC,IAAI,CAAC;QACjB,yEAAyE;QACzE,uBAAuB;QACvB,CAAC,IAAI,CAAC,IAAI,KAAK,uBAAa,CAAC,IAAI;YAC/B,IAAI,CAAC,IAAI,KAAK,oBAAU,CAAC,IAAI;YAC7B,IAAI,CAAC,IAAI,KAAK,sBAAY,CAAC,IAAI;YAC/B,IAAI,CAAC,IAAI,KAAK,wBAAc,CAAC,IAAI;YACjC,IAAI,CAAC,IAAI,KAAK,mBAAS,CAAC,IAAI,CAAC,CAChC,CAAC;AACJ,CAAC;AAXD,wCAWC"}

View File

@@ -0,0 +1,6 @@
import { GraphQLSchema } from 'graphql';
import { IExecutableSchemaDefinition, ILogger } from './Interfaces';
export declare function makeExecutableSchema<TContext = any>({ typeDefs, resolvers, connectors, logger, allowUndefinedInResolve, resolverValidationOptions, directiveResolvers, schemaDirectives, parseOptions, inheritResolversFromInterfaces }: IExecutableSchemaDefinition<TContext>): GraphQLSchema;
export declare function addCatchUndefinedToSchema(schema: GraphQLSchema): void;
export declare function addErrorLoggingToSchema(schema: GraphQLSchema, logger: ILogger): void;
export * from './generate';

View File

@@ -0,0 +1,92 @@
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var schemaVisitor_1 = require("./schemaVisitor");
var mergeDeep_1 = require("./mergeDeep");
var generate_1 = require("./generate");
function makeExecutableSchema(_a) {
var typeDefs = _a.typeDefs, _b = _a.resolvers, resolvers = _b === void 0 ? {} : _b, connectors = _a.connectors, logger = _a.logger, _c = _a.allowUndefinedInResolve, allowUndefinedInResolve = _c === void 0 ? true : _c, _d = _a.resolverValidationOptions, resolverValidationOptions = _d === void 0 ? {} : _d, _e = _a.directiveResolvers, directiveResolvers = _e === void 0 ? null : _e, _f = _a.schemaDirectives, schemaDirectives = _f === void 0 ? null : _f, _g = _a.parseOptions, parseOptions = _g === void 0 ? {} : _g, _h = _a.inheritResolversFromInterfaces, inheritResolversFromInterfaces = _h === void 0 ? false : _h;
// Validate and clean up arguments
if (typeof resolverValidationOptions !== 'object') {
throw new generate_1.SchemaError('Expected `resolverValidationOptions` to be an object');
}
if (!typeDefs) {
throw new generate_1.SchemaError('Must provide typeDefs');
}
if (!resolvers) {
throw new generate_1.SchemaError('Must provide resolvers');
}
// We allow passing in an array of resolver maps, in which case we merge them
var resolverMap = Array.isArray(resolvers)
? resolvers.filter(function (resolverObj) { return typeof resolverObj === 'object'; }).reduce(mergeDeep_1.default, {})
: resolvers;
// Arguments are now validated and cleaned up
var schema = generate_1.buildSchemaFromTypeDefinitions(typeDefs, parseOptions);
schema = generate_1.addResolveFunctionsToSchema({
schema: schema,
resolvers: resolverMap,
resolverValidationOptions: resolverValidationOptions,
inheritResolversFromInterfaces: inheritResolversFromInterfaces
});
generate_1.assertResolveFunctionsPresent(schema, resolverValidationOptions);
if (!allowUndefinedInResolve) {
addCatchUndefinedToSchema(schema);
}
if (logger) {
addErrorLoggingToSchema(schema, logger);
}
if (typeof resolvers['__schema'] === 'function') {
// TODO a bit of a hack now, better rewrite generateSchema to attach it there.
// not doing that now, because I'd have to rewrite a lot of tests.
generate_1.addSchemaLevelResolveFunction(schema, resolvers['__schema']);
}
if (connectors) {
// connectors are optional, at least for now. That means you can just import them in the resolve
// function if you want.
generate_1.attachConnectorsToContext(schema, connectors);
}
if (directiveResolvers) {
generate_1.attachDirectiveResolvers(schema, directiveResolvers);
}
if (schemaDirectives) {
schemaVisitor_1.SchemaDirectiveVisitor.visitSchemaDirectives(schema, schemaDirectives);
}
return schema;
}
exports.makeExecutableSchema = makeExecutableSchema;
function decorateToCatchUndefined(fn, hint) {
if (typeof fn === 'undefined') {
fn = graphql_1.defaultFieldResolver;
}
return function (root, args, ctx, info) {
var result = fn(root, args, ctx, info);
if (typeof result === 'undefined') {
throw new Error("Resolve function for \"" + hint + "\" returned undefined");
}
return result;
};
}
function addCatchUndefinedToSchema(schema) {
generate_1.forEachField(schema, function (field, typeName, fieldName) {
var errorHint = typeName + "." + fieldName;
field.resolve = decorateToCatchUndefined(field.resolve, errorHint);
});
}
exports.addCatchUndefinedToSchema = addCatchUndefinedToSchema;
function addErrorLoggingToSchema(schema, logger) {
if (!logger) {
throw new Error('Must provide a logger');
}
if (typeof logger.log !== 'function') {
throw new Error('Logger.log must be a function');
}
generate_1.forEachField(schema, function (field, typeName, fieldName) {
var errorHint = typeName + "." + fieldName;
field.resolve = generate_1.decorateWithLogger(field.resolve, logger, errorHint);
});
}
exports.addErrorLoggingToSchema = addErrorLoggingToSchema;
__export(require("./generate"));
//# sourceMappingURL=makeExecutableSchema.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"makeExecutableSchema.js","sourceRoot":"","sources":["../src/makeExecutableSchema.ts"],"names":[],"mappings":";;;;AAAA,mCAAoF;AAIpF,iDAAyD;AACzD,yCAAoC;AAEpC,uCAUoB;AAEpB,SAAgB,oBAAoB,CAAiB,EAWb;QAVtC,sBAAQ,EACR,iBAAc,EAAd,mCAAc,EACd,0BAAU,EACV,kBAAM,EACN,+BAA8B,EAA9B,mDAA8B,EAC9B,iCAA8B,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,CAAC,uBAAuB,CAAC,CAAC;KAC1C;IACD,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,EAAE;QACpC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,uBAAY,CAAC,MAAM,EAAE,UAAC,KAAK,EAAE,QAAQ,EAAE,SAAS;QAC9C,IAAM,SAAS,GAAM,QAAQ,SAAI,SAAW,CAAC;QAC7C,KAAK,CAAC,OAAO,GAAG,6BAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,0DAWC;AAED,gCAA2B"}

1
node_modules/graphql-tools/dist/mergeDeep.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export default function mergeDeep(target: any, source: any): any;

26
node_modules/graphql-tools/dist/mergeDeep.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Object.defineProperty(exports, "__esModule", { value: true });
function mergeDeep(target, source) {
var output = Object.assign({}, target);
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach(function (key) {
var _a, _b;
if (isObject(source[key])) {
if (!(key in target)) {
Object.assign(output, (_a = {}, _a[key] = source[key], _a));
}
else {
output[key] = mergeDeep(target[key], source[key]);
}
}
else {
Object.assign(output, (_b = {}, _b[key] = source[key], _b));
}
});
}
return output;
}
exports.default = mergeDeep;
function isObject(item) {
return item && typeof item === 'object' && !Array.isArray(item);
}
//# sourceMappingURL=mergeDeep.js.map

1
node_modules/graphql-tools/dist/mergeDeep.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"mergeDeep.js","sourceRoot":"","sources":["../src/mergeDeep.ts"],"names":[],"mappings":";AAAA,SAAwB,SAAS,CAAC,MAAW,EAAE,MAAW;IACxD,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACvC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;;YAC7B,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE;oBACpB,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG,CAAC;iBAC/C;qBAAM;oBACL,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;iBACnD;aACF;iBAAM;gBACL,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG,CAAC;aAC/C;QACH,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAhBD,4BAgBC;AAED,SAAS,QAAQ,CAAC,IAAS;IACzB,OAAO,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC"}

14
node_modules/graphql-tools/dist/mock.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import { GraphQLSchema, GraphQLList, GraphQLResolveInfo, GraphQLFieldResolver } from 'graphql';
import { IMocks, IMockServer, IMockOptions, IMockTypeFn, ITypeDefinitions } from './Interfaces';
declare function mockServer(schema: GraphQLSchema | ITypeDefinitions, mocks: IMocks, preserveResolvers?: boolean): IMockServer;
declare function addMockFunctionsToSchema({ schema, mocks, preserveResolvers, }: IMockOptions): void;
declare class MockList {
private len;
private wrappedFunction;
constructor(len: number | number[], wrappedFunction?: GraphQLFieldResolver<any, any>);
mock(root: any, args: {
[key: string]: any;
}, context: any, info: GraphQLResolveInfo, fieldType: GraphQLList<any>, mockTypeFunc: IMockTypeFn): any[];
private randint;
}
export { addMockFunctionsToSchema, MockList, mockServer };

306
node_modules/graphql-tools/dist/mock.js generated vendored Normal file
View File

@@ -0,0 +1,306 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var uuid = require("uuid");
var makeExecutableSchema_1 = require("./makeExecutableSchema");
// This function wraps addMockFunctionsToSchema for more convenience
function mockServer(schema, mocks, preserveResolvers) {
if (preserveResolvers === void 0) { preserveResolvers = false; }
var mySchema;
if (!(schema instanceof graphql_1.GraphQLSchema)) {
// TODO: provide useful error messages here if this fails
mySchema = makeExecutableSchema_1.buildSchemaFromTypeDefinitions(schema);
}
else {
mySchema = schema;
}
addMockFunctionsToSchema({ schema: mySchema, mocks: mocks, preserveResolvers: preserveResolvers });
return { query: function (query, vars) { return graphql_1.graphql(mySchema, query, {}, {}, vars); } };
}
exports.mockServer = mockServer;
var defaultMockMap = new Map();
defaultMockMap.set('Int', function () { return Math.round(Math.random() * 200) - 100; });
defaultMockMap.set('Float', function () { return Math.random() * 200 - 100; });
defaultMockMap.set('String', function () { return 'Hello World'; });
defaultMockMap.set('Boolean', function () { return Math.random() > 0.5; });
defaultMockMap.set('ID', function () { return uuid.v4(); });
// TODO allow providing a seed such that lengths of list could be deterministic
// this could be done by using casual to get a random list length if the casual
// object is global.
function addMockFunctionsToSchema(_a) {
var schema = _a.schema, _b = _a.mocks, mocks = _b === void 0 ? {} : _b, _c = _a.preserveResolvers, preserveResolvers = _c === void 0 ? false : _c;
if (!schema) {
throw new Error('Must provide schema to mock');
}
if (!(schema instanceof graphql_1.GraphQLSchema)) {
throw new Error('Value at "schema" must be of type GraphQLSchema');
}
if (!isObject(mocks)) {
throw new Error('mocks must be of type Object');
}
// use Map internally, because that API is nicer.
var mockFunctionMap = new Map();
Object.keys(mocks).forEach(function (typeName) {
mockFunctionMap.set(typeName, mocks[typeName]);
});
mockFunctionMap.forEach(function (mockFunction, mockTypeName) {
if (typeof mockFunction !== 'function') {
throw new Error("mockFunctionMap[" + mockTypeName + "] must be a function");
}
});
var mockType = function (type, typeName, fieldName) {
// order of precendence for mocking:
// 1. if the object passed in already has fieldName, just use that
// --> if it's a function, that becomes your resolver
// --> if it's a value, the mock resolver will return that
// 2. if the nullableType is a list, recurse
// 2. if there's a mock defined for this typeName, that will be used
// 3. if there's no mock defined, use the default mocks for this type
return function (root, args, context, info) {
// nullability doesn't matter for the purpose of mocking.
var fieldType = graphql_1.getNullableType(type);
var namedFieldType = graphql_1.getNamedType(fieldType);
if (root && typeof root[fieldName] !== 'undefined') {
var result = void 0;
// if we're here, the field is already defined
if (typeof root[fieldName] === 'function') {
result = root[fieldName](root, args, context, info);
if (result instanceof MockList) {
result = result.mock(root, args, context, info, fieldType, mockType);
}
}
else {
result = root[fieldName];
}
// Now we merge the result with the default mock for this type.
// This allows overriding defaults while writing very little code.
if (mockFunctionMap.has(namedFieldType.name)) {
result = mergeMocks(mockFunctionMap
.get(namedFieldType.name)
.bind(null, root, args, context, info), result);
}
return result;
}
if (fieldType instanceof graphql_1.GraphQLList ||
fieldType instanceof graphql_1.GraphQLNonNull) {
return [
mockType(fieldType.ofType)(root, args, context, info),
mockType(fieldType.ofType)(root, args, context, info),
];
}
if (mockFunctionMap.has(fieldType.name) &&
!(fieldType instanceof graphql_1.GraphQLUnionType ||
fieldType instanceof graphql_1.GraphQLInterfaceType)) {
// the object passed doesn't have this field, so we apply the default mock
return mockFunctionMap.get(fieldType.name)(root, args, context, info);
}
if (fieldType instanceof graphql_1.GraphQLObjectType) {
// objects don't return actual data, we only need to mock scalars!
return {};
}
// if a mock function is provided for unionType or interfaceType, execute it to resolve the concrete type
// otherwise randomly pick a type from all implementation types
if (fieldType instanceof graphql_1.GraphQLUnionType ||
fieldType instanceof graphql_1.GraphQLInterfaceType) {
var implementationType = void 0;
if (mockFunctionMap.has(fieldType.name)) {
var interfaceMockObj = mockFunctionMap.get(fieldType.name)(root, args, context, info);
if (!interfaceMockObj || !interfaceMockObj.__typename) {
return Error("Please return a __typename in \"" + fieldType.name + "\"");
}
implementationType = schema.getType(interfaceMockObj.__typename);
}
else {
var possibleTypes = schema.getPossibleTypes(fieldType);
implementationType = getRandomElement(possibleTypes);
}
return Object.assign({ __typename: implementationType }, mockType(implementationType)(root, args, context, info));
}
if (fieldType instanceof graphql_1.GraphQLEnumType) {
return getRandomElement(fieldType.getValues()).value;
}
if (defaultMockMap.has(fieldType.name)) {
return defaultMockMap.get(fieldType.name)(root, args, context, info);
}
// if we get to here, we don't have a value, and we don't have a mock for this type,
// we could return undefined, but that would be hard to debug, so we throw instead.
// however, we returning it instead of throwing it, so preserveResolvers can handle the failures.
return Error("No mock defined for type \"" + fieldType.name + "\"");
};
};
makeExecutableSchema_1.forEachField(schema, function (field, typeName, fieldName) {
assignResolveType(field.type, preserveResolvers);
var mockResolver;
// we have to handle the root mutation and root query types differently,
// because no resolver is called at the root.
/* istanbul ignore next: Must provide schema DefinitionNode with query type or a type named Query. */
var isOnQueryType = schema.getQueryType() && schema.getQueryType().name === typeName;
var isOnMutationType = schema.getMutationType() && schema.getMutationType().name === typeName;
if (isOnQueryType || isOnMutationType) {
if (mockFunctionMap.has(typeName)) {
var rootMock_1 = mockFunctionMap.get(typeName);
// XXX: BUG in here, need to provide proper signature for rootMock.
if (typeof rootMock_1(undefined, {}, {}, {})[fieldName] === 'function') {
mockResolver = function (root, args, context, info) {
var updatedRoot = root || {}; // TODO: should we clone instead?
updatedRoot[fieldName] = rootMock_1(root, args, context, info)[fieldName];
// XXX this is a bit of a hack to still use mockType, which
// lets you mock lists etc. as well
// otherwise we could just set field.resolve to rootMock()[fieldName]
// it's like pretending there was a resolve function that ran before
// the root resolve function.
return mockType(field.type, typeName, fieldName)(updatedRoot, args, context, info);
};
}
}
}
if (!mockResolver) {
mockResolver = mockType(field.type, typeName, fieldName);
}
if (!preserveResolvers || !field.resolve) {
field.resolve = mockResolver;
}
else {
var oldResolver_1 = field.resolve;
field.resolve = function (rootObject, args, context, info) {
return Promise.all([
mockResolver(rootObject, args, context, info),
oldResolver_1(rootObject, args, context, info),
]).then(function (values) {
var mockedValue = values[0], resolvedValue = values[1];
// In case we couldn't mock
if (mockedValue instanceof Error) {
// only if value was not resolved, populate the error.
if (undefined === resolvedValue) {
throw mockedValue;
}
return resolvedValue;
}
if (resolvedValue instanceof Date && mockedValue instanceof Date) {
return undefined !== resolvedValue ? resolvedValue : mockedValue;
}
if (isObject(mockedValue) && isObject(resolvedValue)) {
// Object.assign() won't do here, as we need to all properties, including
// the non-enumerable ones and defined using Object.defineProperty
var emptyObject = Object.create(Object.getPrototypeOf(resolvedValue));
return copyOwnProps(emptyObject, resolvedValue, mockedValue);
}
return undefined !== resolvedValue ? resolvedValue : mockedValue;
});
};
}
});
}
exports.addMockFunctionsToSchema = addMockFunctionsToSchema;
function isObject(thing) {
return thing === Object(thing) && !Array.isArray(thing);
}
// returns a random element from that ary
function getRandomElement(ary) {
var sample = Math.floor(Math.random() * ary.length);
return ary[sample];
}
function mergeObjects(a, b) {
return Object.assign(a, b);
}
function copyOwnPropsIfNotPresent(target, source) {
Object.getOwnPropertyNames(source).forEach(function (prop) {
if (!Object.getOwnPropertyDescriptor(target, prop)) {
Object.defineProperty(target, prop, Object.getOwnPropertyDescriptor(source, prop));
}
});
}
function copyOwnProps(target) {
var sources = [];
for (var _i = 1; _i < arguments.length; _i++) {
sources[_i - 1] = arguments[_i];
}
sources.forEach(function (source) {
var chain = source;
while (chain) {
copyOwnPropsIfNotPresent(target, chain);
chain = Object.getPrototypeOf(chain);
}
});
return target;
}
// takes either an object or a (possibly nested) array
// and completes the customMock object with any fields
// defined on genericMock
// only merges objects or arrays. Scalars are returned as is
function mergeMocks(genericMockFunction, customMock) {
if (Array.isArray(customMock)) {
return customMock.map(function (el) { return mergeMocks(genericMockFunction, el); });
}
if (isObject(customMock)) {
return mergeObjects(genericMockFunction(), customMock);
}
return customMock;
}
function getResolveType(namedFieldType) {
if (namedFieldType instanceof graphql_1.GraphQLInterfaceType ||
namedFieldType instanceof graphql_1.GraphQLUnionType) {
return namedFieldType.resolveType;
}
else {
return undefined;
}
}
function assignResolveType(type, preserveResolvers) {
var fieldType = graphql_1.getNullableType(type);
var namedFieldType = graphql_1.getNamedType(fieldType);
var oldResolveType = getResolveType(namedFieldType);
if (preserveResolvers && oldResolveType && oldResolveType.length) {
return;
}
if (namedFieldType instanceof graphql_1.GraphQLUnionType ||
namedFieldType instanceof graphql_1.GraphQLInterfaceType) {
// the default `resolveType` always returns null. We add a fallback
// resolution that works with how unions and interface are mocked
namedFieldType.resolveType = function (data, context, info) {
return info.schema.getType(data.__typename);
};
}
}
var MockList = /** @class */ (function () {
// wrappedFunction can return another MockList or a value
function MockList(len, wrappedFunction) {
this.len = len;
if (typeof wrappedFunction !== 'undefined') {
if (typeof wrappedFunction !== 'function') {
throw new Error('Second argument to MockList must be a function or undefined');
}
this.wrappedFunction = wrappedFunction;
}
}
MockList.prototype.mock = function (root, args, context, info, fieldType, mockTypeFunc) {
var arr;
if (Array.isArray(this.len)) {
arr = new Array(this.randint(this.len[0], this.len[1]));
}
else {
arr = new Array(this.len);
}
for (var i = 0; i < arr.length; i++) {
if (typeof this.wrappedFunction === 'function') {
var res = this.wrappedFunction(root, args, context, info);
if (res instanceof MockList) {
var nullableType = graphql_1.getNullableType(fieldType.ofType);
arr[i] = res.mock(root, args, context, info, nullableType, mockTypeFunc);
}
else {
arr[i] = res;
}
}
else {
arr[i] = mockTypeFunc(fieldType.ofType)(root, args, context, info);
}
}
return arr;
};
MockList.prototype.randint = function (low, high) {
return Math.floor(Math.random() * (high - low + 1) + low);
};
return MockList;
}());
exports.MockList = MockList;
//# sourceMappingURL=mock.js.map

1
node_modules/graphql-tools/dist/mock.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

62
node_modules/graphql-tools/dist/schemaVisitor.d.ts generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import { GraphQLArgument, GraphQLDirective, GraphQLEnumType, GraphQLEnumValue, GraphQLField, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType } from 'graphql';
export declare type VisitableSchemaType = GraphQLSchema | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | GraphQLNamedType | GraphQLScalarType | GraphQLField<any, any> | GraphQLArgument | GraphQLUnionType | GraphQLEnumType | GraphQLEnumValue | GraphQLInputField;
export declare abstract class SchemaVisitor {
schema: GraphQLSchema;
static implementsVisitorMethod(methodName: string): boolean;
visitSchema(schema: GraphQLSchema): void;
visitScalar(scalar: GraphQLScalarType): GraphQLScalarType | void | null;
visitObject(object: GraphQLObjectType): GraphQLObjectType | void | null;
visitFieldDefinition(field: GraphQLField<any, any>, details: {
objectType: GraphQLObjectType | GraphQLInterfaceType;
}): GraphQLField<any, any> | void | null;
visitArgumentDefinition(argument: GraphQLArgument, details: {
field: GraphQLField<any, any>;
objectType: GraphQLObjectType | GraphQLInterfaceType;
}): GraphQLArgument | void | null;
visitInterface(iface: GraphQLInterfaceType): GraphQLInterfaceType | void | null;
visitUnion(union: GraphQLUnionType): GraphQLUnionType | void | null;
visitEnum(type: GraphQLEnumType): GraphQLEnumType | void | null;
visitEnumValue(value: GraphQLEnumValue, details: {
enumType: GraphQLEnumType;
}): GraphQLEnumValue | void | null;
visitInputObject(object: GraphQLInputObjectType): GraphQLInputObjectType | void | null;
visitInputFieldDefinition(field: GraphQLInputField, details: {
objectType: GraphQLInputObjectType;
}): GraphQLInputField | void | null;
}
export declare function visitSchema(schema: GraphQLSchema, visitorSelector: (type: VisitableSchemaType, methodName: string) => SchemaVisitor[]): GraphQLSchema;
export declare function healSchema(schema: GraphQLSchema): GraphQLSchema;
export declare class SchemaDirectiveVisitor extends SchemaVisitor {
name: string;
args: {
[name: string]: any;
};
visitedType: VisitableSchemaType;
context: {
[key: string]: any;
};
static getDirectiveDeclaration(directiveName: string, schema: GraphQLSchema): GraphQLDirective;
static visitSchemaDirectives(schema: GraphQLSchema, directiveVisitors: {
[directiveName: string]: typeof SchemaDirectiveVisitor;
}, context?: {
[key: string]: any;
}): {
[directiveName: string]: SchemaDirectiveVisitor[];
};
protected static getDeclaredDirectives(schema: GraphQLSchema, directiveVisitors: {
[directiveName: string]: typeof SchemaDirectiveVisitor;
}): {
[directiveName: string]: GraphQLDirective;
};
protected constructor(config: {
name: string;
args: {
[name: string]: any;
};
visitedType: VisitableSchemaType;
schema: GraphQLSchema;
context: {
[key: string]: any;
};
});
}

587
node_modules/graphql-tools/dist/schemaVisitor.js generated vendored Normal file
View File

@@ -0,0 +1,587 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var values_1 = require("graphql/execution/values");
var hasOwn = Object.prototype.hasOwnProperty;
// Abstract base class of any visitor implementation, defining the available
// visitor methods along with their parameter types, and providing a static
// helper function for determining whether a subclass implements a given
// visitor method, as opposed to inheriting one of the stubs defined here.
var SchemaVisitor = /** @class */ (function () {
function SchemaVisitor() {
}
// Determine if this SchemaVisitor (sub)class implements a particular
// visitor method.
SchemaVisitor.implementsVisitorMethod = function (methodName) {
if (!methodName.startsWith('visit')) {
return false;
}
var method = this.prototype[methodName];
if (typeof method !== 'function') {
return false;
}
if (this === SchemaVisitor) {
// The SchemaVisitor class implements every visitor method.
return true;
}
var stub = SchemaVisitor.prototype[methodName];
if (method === stub) {
// If this.prototype[methodName] was just inherited from SchemaVisitor,
// then this class does not really implement the method.
return false;
}
return true;
};
// Concrete subclasses of SchemaVisitor should override one or more of these
// visitor methods, in order to express their interest in handling certain
// schema types/locations. Each method may return null to remove the given
// type from the schema, a non-null value of the same type to update the
// type in the schema, or nothing to leave the type as it was.
/* tslint:disable:no-empty */
SchemaVisitor.prototype.visitSchema = function (schema) { };
SchemaVisitor.prototype.visitScalar = function (scalar) { };
SchemaVisitor.prototype.visitObject = function (object) { };
SchemaVisitor.prototype.visitFieldDefinition = function (field, details) { };
SchemaVisitor.prototype.visitArgumentDefinition = function (argument, details) { };
SchemaVisitor.prototype.visitInterface = function (iface) { };
SchemaVisitor.prototype.visitUnion = function (union) { };
SchemaVisitor.prototype.visitEnum = function (type) { };
SchemaVisitor.prototype.visitEnumValue = function (value, details) { };
SchemaVisitor.prototype.visitInputObject = function (object) { };
SchemaVisitor.prototype.visitInputFieldDefinition = function (field, details) { };
return SchemaVisitor;
}());
exports.SchemaVisitor = SchemaVisitor;
// Generic function for visiting GraphQLSchema objects.
function visitSchema(schema,
// To accommodate as many different visitor patterns as possible, the
// visitSchema function does not simply accept a single instance of the
// SchemaVisitor class, but instead accepts a function that takes the
// current VisitableSchemaType object and the name of a visitor method and
// returns an array of SchemaVisitor instances that implement the visitor
// method and have an interest in handling the given VisitableSchemaType
// object. In the simplest case, this function can always return an array
// containing a single visitor object, without even looking at the type or
// methodName parameters. In other cases, this function might sometimes
// return an empty array to indicate there are no visitors that should be
// applied to the given VisitableSchemaType object. For an example of a
// visitor pattern that benefits from this abstraction, see the
// SchemaDirectiveVisitor class below.
visitorSelector) {
// Helper function that calls visitorSelector and applies the resulting
// visitors to the given type, with arguments [type, ...args].
function callMethod(methodName, type) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
visitorSelector(type, methodName).every(function (visitor) {
var newType = visitor[methodName].apply(visitor, __spreadArrays([type], args));
if (typeof newType === 'undefined') {
// Keep going without modifying type.
return true;
}
if (methodName === 'visitSchema' ||
type instanceof graphql_1.GraphQLSchema) {
throw new Error("Method " + methodName + " cannot replace schema with " + newType);
}
if (newType === null) {
// Stop the loop and return null form callMethod, which will cause
// the type to be removed from the schema.
type = null;
return false;
}
// Update type to the new type returned by the visitor method, so that
// later directives will see the new type, and callMethod will return
// the final type.
type = newType;
return true;
});
// If there were no directives for this type object, or if all visitor
// methods returned nothing, type will be returned unmodified.
return type;
}
// Recursive helper function that calls any appropriate visitor methods for
// each object in the schema, then traverses the object's children (if any).
function visit(type) {
if (type instanceof graphql_1.GraphQLSchema) {
// Unlike the other types, the root GraphQLSchema object cannot be
// replaced by visitor methods, because that would make life very hard
// for SchemaVisitor subclasses that rely on the original schema object.
callMethod('visitSchema', type);
updateEachKey(type.getTypeMap(), function (namedType, typeName) {
if (!typeName.startsWith('__')) {
// Call visit recursively to let it determine which concrete
// subclass of GraphQLNamedType we found in the type map. Because
// we're using updateEachKey, the result of visit(namedType) may
// cause the type to be removed or replaced.
return visit(namedType);
}
});
return type;
}
if (type instanceof graphql_1.GraphQLObjectType) {
// Note that callMethod('visitObject', type) may not actually call any
// methods, if there are no @directive annotations associated with this
// type, or if this SchemaDirectiveVisitor subclass does not override
// the visitObject method.
var newObject = callMethod('visitObject', type);
if (newObject) {
visitFields(newObject);
}
return newObject;
}
if (type instanceof graphql_1.GraphQLInterfaceType) {
var newInterface = callMethod('visitInterface', type);
if (newInterface) {
visitFields(newInterface);
}
return newInterface;
}
if (type instanceof graphql_1.GraphQLInputObjectType) {
var newInputObject_1 = callMethod('visitInputObject', type);
if (newInputObject_1) {
updateEachKey(newInputObject_1.getFields(), function (field) {
// Since we call a different method for input object fields, we
// can't reuse the visitFields function here.
return callMethod('visitInputFieldDefinition', field, {
objectType: newInputObject_1,
});
});
}
return newInputObject_1;
}
if (type instanceof graphql_1.GraphQLScalarType) {
return callMethod('visitScalar', type);
}
if (type instanceof graphql_1.GraphQLUnionType) {
return callMethod('visitUnion', type);
}
if (type instanceof graphql_1.GraphQLEnumType) {
var newEnum_1 = callMethod('visitEnum', type);
if (newEnum_1) {
updateEachKey(newEnum_1.getValues(), function (value) {
return callMethod('visitEnumValue', value, {
enumType: newEnum_1,
});
});
}
return newEnum_1;
}
throw new Error("Unexpected schema type: " + type);
}
function visitFields(type) {
updateEachKey(type.getFields(), function (field) {
// It would be nice if we could call visit(field) recursively here, but
// GraphQLField is merely a type, not a value that can be detected using
// an instanceof check, so we have to visit the fields in this lexical
// context, so that TypeScript can validate the call to
// visitFieldDefinition.
var newField = callMethod('visitFieldDefinition', field, {
// While any field visitor needs a reference to the field object, some
// field visitors may also need to know the enclosing (parent) type,
// perhaps to determine if the parent is a GraphQLObjectType or a
// GraphQLInterfaceType. To obtain a reference to the parent, a
// visitor method can have a second parameter, which will be an object
// with an .objectType property referring to the parent.
objectType: type,
});
if (newField && newField.args) {
updateEachKey(newField.args, function (arg) {
return callMethod('visitArgumentDefinition', arg, {
// Like visitFieldDefinition, visitArgumentDefinition takes a
// second parameter that provides additional context, namely the
// parent .field and grandparent .objectType. Remember that the
// current GraphQLSchema is always available via this.schema.
field: newField,
objectType: type,
});
});
}
return newField;
});
}
visit(schema);
// Return the original schema for convenience, even though it cannot have
// been replaced or removed by the code above.
return schema;
}
exports.visitSchema = visitSchema;
// Update any references to named schema types that disagree with the named
// types found in schema.getTypeMap().
function healSchema(schema) {
heal(schema);
return schema;
function heal(type) {
if (type instanceof graphql_1.GraphQLSchema) {
var originalTypeMap_1 = type.getTypeMap();
var actualNamedTypeMap_1 = Object.create(null);
// If any of the .name properties of the GraphQLNamedType objects in
// schema.getTypeMap() have changed, the keys of the type map need to
// be updated accordingly.
each(originalTypeMap_1, function (namedType, typeName) {
if (typeName.startsWith('__')) {
return;
}
var actualName = namedType.name;
if (actualName.startsWith('__')) {
return;
}
if (hasOwn.call(actualNamedTypeMap_1, actualName)) {
throw new Error("Duplicate schema type name " + actualName);
}
actualNamedTypeMap_1[actualName] = namedType;
// Note: we are deliberately leaving namedType in the schema by its
// original name (which might be different from actualName), so that
// references by that name can be healed.
});
// Now add back every named type by its actual name.
each(actualNamedTypeMap_1, function (namedType, typeName) {
originalTypeMap_1[typeName] = namedType;
});
// Directive declaration argument types can refer to named types.
each(type.getDirectives(), function (decl) {
if (decl.args) {
each(decl.args, function (arg) {
arg.type = healType(arg.type);
});
}
});
each(originalTypeMap_1, function (namedType, typeName) {
if (!typeName.startsWith('__')) {
heal(namedType);
}
});
updateEachKey(originalTypeMap_1, function (namedType, typeName) {
// Dangling references to renamed types should remain in the schema
// during healing, but must be removed now, so that the following
// invariant holds for all names: schema.getType(name).name === name
if (!typeName.startsWith('__') &&
!hasOwn.call(actualNamedTypeMap_1, typeName)) {
return null;
}
});
}
else if (type instanceof graphql_1.GraphQLObjectType) {
healFields(type);
each(type.getInterfaces(), function (iface) { return heal(iface); });
}
else if (type instanceof graphql_1.GraphQLInterfaceType) {
healFields(type);
}
else if (type instanceof graphql_1.GraphQLInputObjectType) {
each(type.getFields(), function (field) {
field.type = healType(field.type);
});
}
else if (type instanceof graphql_1.GraphQLScalarType) {
// Nothing to do.
}
else if (type instanceof graphql_1.GraphQLUnionType) {
updateEachKey(type.getTypes(), function (t) { return healType(t); });
}
else if (type instanceof graphql_1.GraphQLEnumType) {
// Nothing to do.
}
else {
throw new Error("Unexpected schema type: " + type);
}
}
function healFields(type) {
each(type.getFields(), function (field) {
field.type = healType(field.type);
if (field.args) {
each(field.args, function (arg) {
arg.type = healType(arg.type);
});
}
});
}
function healType(type) {
// Unwrap the two known wrapper types
if (type instanceof graphql_1.GraphQLList) {
type = new graphql_1.GraphQLList(healType(type.ofType));
}
else if (type instanceof graphql_1.GraphQLNonNull) {
type = new graphql_1.GraphQLNonNull(healType(type.ofType));
}
else if (graphql_1.isNamedType(type)) {
// If a type annotation on a field or an argument or a union member is
// any `GraphQLNamedType` with a `name`, then it must end up identical
// to `schema.getType(name)`, since `schema.getTypeMap()` is the source
// of truth for all named schema types.
var namedType = type;
var officialType = schema.getType(namedType.name);
if (officialType && namedType !== officialType) {
return officialType;
}
}
return type;
}
}
exports.healSchema = healSchema;
// This class represents a reusable implementation of a @directive that may
// appear in a GraphQL schema written in Schema Definition Language.
//
// By overriding one or more visit{Object,Union,...} methods, a subclass
// registers interest in certain schema types, such as GraphQLObjectType,
// GraphQLUnionType, etc. When SchemaDirectiveVisitor.visitSchemaDirectives is
// called with a GraphQLSchema object and a map of visitor subclasses, the
// overidden methods of those subclasses allow the visitors to obtain
// references to any type objects that have @directives attached to them,
// enabling visitors to inspect or modify the schema as appropriate.
//
// For example, if a directive called @rest(url: "...") appears after a field
// definition, a SchemaDirectiveVisitor subclass could provide meaning to that
// directive by overriding the visitFieldDefinition method (which receives a
// GraphQLField parameter), and then the body of that visitor method could
// manipulate the field's resolver function to fetch data from a REST endpoint
// described by the url argument passed to the @rest directive:
//
// const typeDefs = `
// type Query {
// people: [Person] @rest(url: "/api/v1/people")
// }`;
//
// const schema = makeExecutableSchema({ typeDefs });
//
// SchemaDirectiveVisitor.visitSchemaDirectives(schema, {
// rest: class extends SchemaDirectiveVisitor {
// public visitFieldDefinition(field: GraphQLField<any, any>) {
// const { url } = this.args;
// field.resolve = () => fetch(url);
// }
// }
// });
//
// The subclass in this example is defined as an anonymous class expression,
// for brevity. A truly reusable SchemaDirectiveVisitor would most likely be
// defined in a library using a named class declaration, and then exported for
// consumption by other modules and packages.
//
// See below for a complete list of overridable visitor methods, their
// parameter types, and more details about the properties exposed by instances
// of the SchemaDirectiveVisitor class.
var SchemaDirectiveVisitor = /** @class */ (function (_super) {
__extends(SchemaDirectiveVisitor, _super);
// Mark the constructor protected to enforce passing SchemaDirectiveVisitor
// subclasses (not instances) to visitSchemaDirectives.
function SchemaDirectiveVisitor(config) {
var _this = _super.call(this) || this;
_this.name = config.name;
_this.args = config.args;
_this.visitedType = config.visitedType;
_this.schema = config.schema;
_this.context = config.context;
return _this;
}
// Override this method to return a custom GraphQLDirective (or modify one
// already present in the schema) to enforce argument types, provide default
// argument values, or specify schema locations where this @directive may
// appear. By default, any declaration found in the schema will be returned.
SchemaDirectiveVisitor.getDirectiveDeclaration = function (directiveName, schema) {
return schema.getDirective(directiveName);
};
// Call SchemaDirectiveVisitor.visitSchemaDirectives to visit every
// @directive in the schema and create an appropriate SchemaDirectiveVisitor
// instance to visit the object decorated by the @directive.
SchemaDirectiveVisitor.visitSchemaDirectives = function (schema, directiveVisitors,
// Optional context object that will be available to all visitor instances
// via this.context. Defaults to an empty null-prototype object.
context) {
if (context === void 0) { context = Object.create(null); }
// If the schema declares any directives for public consumption, record
// them here so that we can properly coerce arguments when/if we encounter
// an occurrence of the directive while walking the schema below.
var declaredDirectives = this.getDeclaredDirectives(schema, directiveVisitors);
// Map from directive names to lists of SchemaDirectiveVisitor instances
// created while visiting the schema.
var createdVisitors = Object.create(null);
Object.keys(directiveVisitors).forEach(function (directiveName) {
createdVisitors[directiveName] = [];
});
function visitorSelector(type, methodName) {
var visitors = [];
var directiveNodes = type.astNode && type.astNode.directives;
if (!directiveNodes) {
return visitors;
}
directiveNodes.forEach(function (directiveNode) {
var directiveName = directiveNode.name.value;
if (!hasOwn.call(directiveVisitors, directiveName)) {
return;
}
var visitorClass = directiveVisitors[directiveName];
// Avoid creating visitor objects if visitorClass does not override
// the visitor method named by methodName.
if (!visitorClass.implementsVisitorMethod(methodName)) {
return;
}
var decl = declaredDirectives[directiveName];
var args;
if (decl) {
// If this directive was explicitly declared, use the declared
// argument types (and any default values) to check, coerce, and/or
// supply default values for the given arguments.
args = values_1.getArgumentValues(decl, directiveNode);
}
else {
// If this directive was not explicitly declared, just convert the
// argument nodes to their corresponding JavaScript values.
args = Object.create(null);
directiveNode.arguments.forEach(function (arg) {
args[arg.name.value] = valueFromASTUntyped(arg.value);
});
}
// As foretold in comments near the top of the visitSchemaDirectives
// method, this is where instances of the SchemaDirectiveVisitor class
// get created and assigned names. While subclasses could override the
// constructor method, the constructor is marked as protected, so
// these are the only arguments that will ever be passed.
visitors.push(new visitorClass({
name: directiveName,
args: args,
visitedType: type,
schema: schema,
context: context,
}));
});
if (visitors.length > 0) {
visitors.forEach(function (visitor) {
createdVisitors[visitor.name].push(visitor);
});
}
return visitors;
}
visitSchema(schema, visitorSelector);
// Automatically update any references to named schema types replaced
// during the traversal, so implementors don't have to worry about that.
healSchema(schema);
return createdVisitors;
};
SchemaDirectiveVisitor.getDeclaredDirectives = function (schema, directiveVisitors) {
var declaredDirectives = Object.create(null);
each(schema.getDirectives(), function (decl) {
declaredDirectives[decl.name] = decl;
});
// If the visitor subclass overrides getDirectiveDeclaration, and it
// returns a non-null GraphQLDirective, use that instead of any directive
// declared in the schema itself. Reasoning: if a SchemaDirectiveVisitor
// goes to the trouble of implementing getDirectiveDeclaration, it should
// be able to rely on that implementation.
each(directiveVisitors, function (visitorClass, directiveName) {
var decl = visitorClass.getDirectiveDeclaration(directiveName, schema);
if (decl) {
declaredDirectives[directiveName] = decl;
}
});
each(declaredDirectives, function (decl, name) {
if (!hasOwn.call(directiveVisitors, name)) {
// SchemaDirectiveVisitors.visitSchemaDirectives might be called
// multiple times with partial directiveVisitors maps, so it's not
// necessarily an error for directiveVisitors to be missing an
// implementation of a directive that was declared in the schema.
return;
}
var visitorClass = directiveVisitors[name];
each(decl.locations, function (loc) {
var visitorMethodName = directiveLocationToVisitorMethodName(loc);
if (SchemaVisitor.implementsVisitorMethod(visitorMethodName) &&
!visitorClass.implementsVisitorMethod(visitorMethodName)) {
// While visitor subclasses may implement extra visitor methods,
// it's definitely a mistake if the GraphQLDirective declares itself
// applicable to certain schema locations, and the visitor subclass
// does not implement all the corresponding methods.
throw new Error("SchemaDirectiveVisitor for @" + name + " must implement " + visitorMethodName + " method");
}
});
});
return declaredDirectives;
};
return SchemaDirectiveVisitor;
}(SchemaVisitor));
exports.SchemaDirectiveVisitor = SchemaDirectiveVisitor;
// Convert a string like "FIELD_DEFINITION" to "visitFieldDefinition".
function directiveLocationToVisitorMethodName(loc) {
return 'visit' + loc.replace(/([^_]*)_?/g, function (wholeMatch, part) {
return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
});
}
function each(arrayOrObject, callback) {
Object.keys(arrayOrObject).forEach(function (key) {
callback(arrayOrObject[key], key);
});
}
// A more powerful version of each that has the ability to replace or remove
// array or object keys.
function updateEachKey(arrayOrObject,
// The callback can return nothing to leave the key untouched, null to remove
// the key from the array or object, or a non-null V to replace the value.
callback) {
var deletedCount = 0;
Object.keys(arrayOrObject).forEach(function (key) {
var result = callback(arrayOrObject[key], key);
if (typeof result === 'undefined') {
return;
}
if (result === null) {
delete arrayOrObject[key];
deletedCount++;
return;
}
arrayOrObject[key] = result;
});
if (deletedCount > 0 && Array.isArray(arrayOrObject)) {
// Remove any holes from the array due to deleted elements.
arrayOrObject.splice(0).forEach(function (elem) {
arrayOrObject.push(elem);
});
}
}
// Similar to the graphql-js function of the same name, slightly simplified:
// https://github.com/graphql/graphql-js/blob/master/src/utilities/valueFromASTUntyped.js
function valueFromASTUntyped(valueNode) {
switch (valueNode.kind) {
case graphql_1.Kind.NULL:
return null;
case graphql_1.Kind.INT:
return parseInt(valueNode.value, 10);
case graphql_1.Kind.FLOAT:
return parseFloat(valueNode.value);
case graphql_1.Kind.STRING:
case graphql_1.Kind.ENUM:
case graphql_1.Kind.BOOLEAN:
return valueNode.value;
case graphql_1.Kind.LIST:
return valueNode.values.map(valueFromASTUntyped);
case graphql_1.Kind.OBJECT:
var obj_1 = Object.create(null);
valueNode.fields.forEach(function (field) {
obj_1[field.name.value] = valueFromASTUntyped(field.value);
});
return obj_1;
/* istanbul ignore next */
default:
throw new Error('Unexpected value kind: ' + valueNode.kind);
}
}
//# sourceMappingURL=schemaVisitor.js.map

1
node_modules/graphql-tools/dist/schemaVisitor.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
import { GraphQLFieldResolver } from 'graphql';
declare const defaultMergedResolver: GraphQLFieldResolver<any, any>;
export default defaultMergedResolver;

View File

@@ -0,0 +1,32 @@
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var error_1 = require("graphql/error");
var errors_1 = require("./errors");
var getResponseKeyFromInfo_1 = require("./getResponseKeyFromInfo");
// Resolver that knows how to:
// a) handle aliases for proxied schemas
// b) handle errors from proxied schemas
var defaultMergedResolver = function (parent, args, context, info) {
if (!parent) {
return null;
}
var responseKey = getResponseKeyFromInfo_1.getResponseKeyFromInfo(info);
var errorResult = errors_1.getErrorsFromParent(parent, responseKey);
if (errorResult.kind === 'OWN') {
throw error_1.locatedError(new Error(errorResult.error.message), info.fieldNodes, graphql_1.responsePathAsArray(info.path));
}
var result = parent[responseKey];
if (result == null) {
result = parent[info.fieldName];
}
// subscription result mapping
if (!result && parent.data && parent.data[responseKey]) {
result = parent.data[responseKey];
}
if (errorResult.errors) {
result = errors_1.annotateWithChildrenErrors(result, errorResult.errors);
}
return result;
};
exports.default = defaultMergedResolver;
//# sourceMappingURL=defaultMergedResolver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultMergedResolver.js","sourceRoot":"","sources":["../../src/stitching/defaultMergedResolver.ts"],"names":[],"mappings":";AAAA,mCAAoE;AACpE,uCAA6C;AAC7C,mCAA2E;AAC3E,mEAAkE;AAElE,8BAA8B;AAC9B,wCAAwC;AACxC,wCAAwC;AACxC,IAAM,qBAAqB,GAAmC,UAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI;IACxF,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IAED,IAAM,WAAW,GAAG,+CAAsB,CAAC,IAAI,CAAC,CAAC;IACjD,IAAM,WAAW,GAAG,4BAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAE7D,IAAI,WAAW,CAAC,IAAI,KAAK,KAAK,EAAE;QAC9B,MAAM,oBAAY,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,6BAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;KAC3G;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAEjC,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACjC;IAED,8BAA8B;IAC9B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QACtD,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KACnC;IAED,IAAI,WAAW,CAAC,MAAM,EAAE;QACtB,MAAM,GAAG,mCAA0B,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;KACjE;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,qBAAqB,CAAC"}

View File

@@ -0,0 +1,3 @@
import { GraphQLSchema } from 'graphql';
import { IDelegateToSchemaOptions } from '../Interfaces';
export default function delegateToSchema(options: IDelegateToSchemaOptions | GraphQLSchema, ...args: any[]): Promise<any>;

View File

@@ -0,0 +1,171 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var transforms_1 = require("../transforms/transforms");
var AddArgumentsAsVariables_1 = require("../transforms/AddArgumentsAsVariables");
var FilterToSchema_1 = require("../transforms/FilterToSchema");
var AddTypenameToAbstract_1 = require("../transforms/AddTypenameToAbstract");
var CheckResultAndHandleErrors_1 = require("../transforms/CheckResultAndHandleErrors");
var mapAsyncIterator_1 = require("./mapAsyncIterator");
var ExpandAbstractTypes_1 = require("../transforms/ExpandAbstractTypes");
var ReplaceFieldWithFragment_1 = require("../transforms/ReplaceFieldWithFragment");
var ConvertEnumResponse_1 = require("../transforms/ConvertEnumResponse");
function delegateToSchema(options) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (options instanceof graphql_1.GraphQLSchema) {
throw new Error('Passing positional arguments to delegateToSchema is a deprecated. ' +
'Please pass named parameters instead.');
}
return delegateToSchemaImplementation(options);
}
exports.default = delegateToSchema;
function delegateToSchemaImplementation(options) {
return __awaiter(this, void 0, void 0, function () {
var info, _a, args, operation, rawDocument, rawRequest, transforms, processedRequest, errors, _b, executionResult;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
info = options.info, _a = options.args, args = _a === void 0 ? {} : _a;
operation = options.operation || info.operation.operation;
rawDocument = createDocument(options.fieldName, operation, info.fieldNodes, Object.keys(info.fragments).map(function (fragmentName) { return info.fragments[fragmentName]; }), info.operation.variableDefinitions, info.operation.name);
rawRequest = {
document: rawDocument,
variables: info.variableValues,
};
transforms = __spreadArrays((options.transforms || []), [
new ExpandAbstractTypes_1.default(info.schema, options.schema),
]);
if (info.mergeInfo && info.mergeInfo.fragments) {
transforms.push(new ReplaceFieldWithFragment_1.default(options.schema, info.mergeInfo.fragments));
}
transforms = transforms.concat([
new AddArgumentsAsVariables_1.default(options.schema, args),
new FilterToSchema_1.default(options.schema),
new AddTypenameToAbstract_1.default(options.schema),
new CheckResultAndHandleErrors_1.default(info, options.fieldName),
]);
if (graphql_1.isEnumType(options.info.returnType)) {
transforms = transforms.concat(new ConvertEnumResponse_1.default(options.info.returnType));
}
processedRequest = transforms_1.applyRequestTransforms(rawRequest, transforms);
if (!options.skipValidation) {
errors = graphql_1.validate(options.schema, processedRequest.document);
if (errors.length > 0) {
throw errors;
}
}
if (!(operation === 'query' || operation === 'mutation')) return [3 /*break*/, 2];
_b = transforms_1.applyResultTransforms;
return [4 /*yield*/, graphql_1.execute(options.schema, processedRequest.document, info.rootValue, options.context, processedRequest.variables)];
case 1: return [2 /*return*/, _b.apply(void 0, [_c.sent(),
transforms])];
case 2:
if (!(operation === 'subscription')) return [3 /*break*/, 4];
return [4 /*yield*/, graphql_1.subscribe(options.schema, processedRequest.document, info.rootValue, options.context, processedRequest.variables)];
case 3:
executionResult = (_c.sent());
// "subscribe" to the subscription result and map the result through the transforms
return [2 /*return*/, mapAsyncIterator_1.default(executionResult, function (result) {
var _a;
var transformedResult = transforms_1.applyResultTransforms(result, transforms);
var subscriptionKey = Object.keys(result.data)[0];
// for some reason the returned transformedResult needs to be nested inside the root subscription field
// does not work otherwise...
return _a = {},
_a[subscriptionKey] = transformedResult,
_a;
})];
case 4: return [2 /*return*/];
}
});
});
}
function createDocument(targetField, targetOperation, originalSelections, fragments, variables, operationName) {
var selections = [];
var args = [];
originalSelections.forEach(function (field) {
var fieldSelections = field.selectionSet
? field.selectionSet.selections
: [];
selections = selections.concat(fieldSelections);
args = args.concat(field.arguments || []);
});
var selectionSet = null;
if (selections.length > 0) {
selectionSet = {
kind: graphql_1.Kind.SELECTION_SET,
selections: selections,
};
}
var rootField = {
kind: graphql_1.Kind.FIELD,
alias: null,
arguments: args,
selectionSet: selectionSet,
name: {
kind: graphql_1.Kind.NAME,
value: targetField,
},
};
var rootSelectionSet = {
kind: graphql_1.Kind.SELECTION_SET,
selections: [rootField],
};
var operationDefinition = {
kind: graphql_1.Kind.OPERATION_DEFINITION,
operation: targetOperation,
variableDefinitions: variables,
selectionSet: rootSelectionSet,
name: operationName,
};
return {
kind: graphql_1.Kind.DOCUMENT,
definitions: __spreadArrays([operationDefinition], fragments),
};
}
//# sourceMappingURL=delegateToSchema.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"delegateToSchema.js","sourceRoot":"","sources":["../../src/stitching/delegateToSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAiBiB;AAI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B,YAAY,GAAG;YACb,IAAI,EAAE,cAAI,CAAC,aAAa;YACxB,UAAU,EAAE,UAAU;SACvB,CAAC;KACH;IAED,IAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,cAAI,CAAC,KAAK;QAChB,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,IAAI;QACf,YAAY,cAAA;QACZ,IAAI,EAAE;YACJ,IAAI,EAAE,cAAI,CAAC,IAAI;YACf,KAAK,EAAE,WAAW;SACnB;KACF,CAAC;IACF,IAAM,gBAAgB,GAAqB;QACzC,IAAI,EAAE,cAAI,CAAC,aAAa;QACxB,UAAU,EAAE,CAAC,SAAS,CAAC;KACxB,CAAC;IAEF,IAAM,mBAAmB,GAA4B;QACnD,IAAI,EAAE,cAAI,CAAC,oBAAoB;QAC/B,SAAS,EAAE,eAAe;QAC1B,mBAAmB,EAAE,SAAS;QAC9B,YAAY,EAAE,gBAAgB;QAC9B,IAAI,EAAE,aAAa;KACpB,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,cAAI,CAAC,QAAQ;QACnB,WAAW,kBAAG,mBAAmB,GAAK,SAAS,CAAC;KACjD,CAAC;AACJ,CAAC"}

11
node_modules/graphql-tools/dist/stitching/errors.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import { GraphQLResolveInfo, ExecutionResult, GraphQLFormattedError } from 'graphql';
export declare let ERROR_SYMBOL: any;
export declare function annotateWithChildrenErrors(object: any, childrenErrors: ReadonlyArray<GraphQLFormattedError>): any;
export declare function getErrorsFromParent(object: any, fieldName: string): {
kind: 'OWN';
error: any;
} | {
kind: 'CHILDREN';
errors?: Array<GraphQLFormattedError>;
};
export declare function checkResultAndHandleErrors(result: ExecutionResult, info: GraphQLResolveInfo, responseKey?: string): any;

114
node_modules/graphql-tools/dist/stitching/errors.js generated vendored Normal file
View File

@@ -0,0 +1,114 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var error_1 = require("graphql/error");
var getResponseKeyFromInfo_1 = require("./getResponseKeyFromInfo");
if ((typeof global !== 'undefined' && 'Symbol' in global) ||
(typeof window !== 'undefined' && 'Symbol' in window)) {
exports.ERROR_SYMBOL = Symbol('subSchemaErrors');
}
else {
exports.ERROR_SYMBOL = '@@__subSchemaErrors';
}
function annotateWithChildrenErrors(object, childrenErrors) {
var _a;
if (!childrenErrors || childrenErrors.length === 0) {
// Nothing to see here, move along
return object;
}
if (Array.isArray(object)) {
var byIndex_1 = {};
childrenErrors.forEach(function (error) {
if (!error.path) {
return;
}
var index = error.path[1];
var current = byIndex_1[index] || [];
current.push(__assign(__assign({}, error), { path: error.path.slice(1) }));
byIndex_1[index] = current;
});
return object.map(function (item, index) { return annotateWithChildrenErrors(item, byIndex_1[index]); });
}
return __assign(__assign({}, object), (_a = {}, _a[exports.ERROR_SYMBOL] = childrenErrors.map(function (error) { return (__assign(__assign({}, error), (error.path ? { path: error.path.slice(1) } : {}))); }), _a));
}
exports.annotateWithChildrenErrors = annotateWithChildrenErrors;
function getErrorsFromParent(object, fieldName) {
var errors = (object && object[exports.ERROR_SYMBOL]) || [];
var childrenErrors = [];
for (var _i = 0, errors_1 = errors; _i < errors_1.length; _i++) {
var error = errors_1[_i];
if (!error.path || (error.path.length === 1 && error.path[0] === fieldName)) {
return {
kind: 'OWN',
error: error
};
}
else if (error.path[0] === fieldName) {
childrenErrors.push(error);
}
}
return {
kind: 'CHILDREN',
errors: childrenErrors
};
}
exports.getErrorsFromParent = getErrorsFromParent;
var CombinedError = /** @class */ (function (_super) {
__extends(CombinedError, _super);
function CombinedError(message, errors) {
var _this = _super.call(this, message) || this;
_this.errors = errors;
return _this;
}
return CombinedError;
}(Error));
function checkResultAndHandleErrors(result, info, responseKey) {
if (!responseKey) {
responseKey = getResponseKeyFromInfo_1.getResponseKeyFromInfo(info);
}
if (result.errors && (!result.data || result.data[responseKey] == null)) {
// apollo-link-http & http-link-dataloader need the
// result property to be passed through for better error handling.
// If there is only one error, which contains a result property, pass the error through
var newError = result.errors.length === 1 && hasResult(result.errors[0])
? result.errors[0]
: new CombinedError(concatErrors(result.errors), result.errors);
throw error_1.locatedError(newError, info.fieldNodes, graphql_1.responsePathAsArray(info.path));
}
var resultObject = result.data[responseKey];
if (result.errors) {
resultObject = annotateWithChildrenErrors(resultObject, result.errors);
}
return resultObject;
}
exports.checkResultAndHandleErrors = checkResultAndHandleErrors;
function concatErrors(errors) {
return errors.map(function (error) { return error.message; }).join('\n');
}
function hasResult(error) {
return error.result || error.extensions || (error.originalError && error.originalError.result);
}
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/stitching/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAMiB;AACjB,uCAA6C;AAC7C,mEAAkE;AAGlE,IACE,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,QAAQ,IAAI,MAAM,CAAC;IACrD,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,QAAQ,IAAI,MAAM,CAAC,EACrD;IACA,oBAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;CAC1C;KAAM;IACL,oBAAY,GAAG,qBAAqB,CAAC;CACtC;AAED,SAAgB,0BAA0B,CAAC,MAAW,EAAE,c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,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,IAAI,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACpE,MAAM,oBAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,6BAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;KAC/E;IAED,IAAI,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,YAAY,GAAG,0BAA0B,CAAC,YAAY,EAAE,MAAM,CAAC,MAA8C,CAAC,CAAC;KAChH;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAzBD,gEAyBC;AAED,SAAS,YAAY,CAAC,MAAmC;IACvD,OAAO,MAAM,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,OAAO,EAAb,CAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,SAAS,CAAC,KAAU;IAC3B,OAAO,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AACjG,CAAC"}

View File

@@ -0,0 +1,7 @@
import { GraphQLResolveInfo } from 'graphql';
/**
* Get the key under which the result of this resolver will be placed in the response JSON. Basically, just
* resolves aliases.
* @param info The info argument to the resolver.
*/
export declare function getResponseKeyFromInfo(info: GraphQLResolveInfo): string;

View File

@@ -0,0 +1,11 @@
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Get the key under which the result of this resolver will be placed in the response JSON. Basically, just
* resolves aliases.
* @param info The info argument to the resolver.
*/
function getResponseKeyFromInfo(info) {
return info.fieldNodes[0].alias ? info.fieldNodes[0].alias.value : info.fieldName;
}
exports.getResponseKeyFromInfo = getResponseKeyFromInfo;
//# sourceMappingURL=getResponseKeyFromInfo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getResponseKeyFromInfo.js","sourceRoot":"","sources":["../../src/stitching/getResponseKeyFromInfo.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,IAAwB;IAC7D,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;AACpF,CAAC;AAFD,wDAEC"}

6
node_modules/graphql-tools/dist/stitching/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import makeRemoteExecutableSchema, { createResolver as defaultCreateRemoteResolver } from './makeRemoteExecutableSchema';
import introspectSchema from './introspectSchema';
import mergeSchemas from './mergeSchemas';
import delegateToSchema from './delegateToSchema';
import defaultMergedResolver from './defaultMergedResolver';
export { makeRemoteExecutableSchema, introspectSchema, mergeSchemas, delegateToSchema, defaultMergedResolver, defaultCreateRemoteResolver };

13
node_modules/graphql-tools/dist/stitching/index.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
Object.defineProperty(exports, "__esModule", { value: true });
var makeRemoteExecutableSchema_1 = require("./makeRemoteExecutableSchema");
exports.makeRemoteExecutableSchema = makeRemoteExecutableSchema_1.default;
exports.defaultCreateRemoteResolver = makeRemoteExecutableSchema_1.createResolver;
var introspectSchema_1 = require("./introspectSchema");
exports.introspectSchema = introspectSchema_1.default;
var mergeSchemas_1 = require("./mergeSchemas");
exports.mergeSchemas = mergeSchemas_1.default;
var delegateToSchema_1 = require("./delegateToSchema");
exports.delegateToSchema = delegateToSchema_1.default;
var defaultMergedResolver_1 = require("./defaultMergedResolver");
exports.defaultMergedResolver = defaultMergedResolver_1.default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stitching/index.ts"],"names":[],"mappings":";AAAA,2EAAyH;AAOvH,qCAPK,oCAA0B,CAOL;AAO1B,sCAdqD,2CAA2B,CAcrD;AAb7B,uDAAkD;AAOhD,2BAPK,0BAAgB,CAOL;AANlB,+CAA0C;AAOxC,uBAPK,sBAAY,CAOL;AANd,uDAAkD;AAShD,2BATK,0BAAgB,CASL;AARlB,iEAA4D;AAS1D,gCATK,+BAAqB,CASL"}

View File

@@ -0,0 +1,6 @@
import { GraphQLSchema } from 'graphql';
import { ApolloLink } from 'apollo-link';
import { Fetcher } from './makeRemoteExecutableSchema';
export default function introspectSchema(fetcher: ApolloLink | Fetcher, linkContext?: {
[key: string]: any;
}): Promise<GraphQLSchema>;

View File

@@ -0,0 +1,72 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var utilities_1 = require("graphql/utilities");
var linkToFetcher_1 = require("./linkToFetcher");
var parsedIntrospectionQuery = graphql_1.parse(utilities_1.getIntrospectionQuery());
function introspectSchema(fetcher, linkContext) {
return __awaiter(this, void 0, void 0, function () {
var introspectionResult, schema;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// Convert link to fetcher
if (fetcher.request) {
fetcher = linkToFetcher_1.default(fetcher);
}
return [4 /*yield*/, fetcher({
query: parsedIntrospectionQuery,
context: linkContext,
})];
case 1:
introspectionResult = _a.sent();
if ((introspectionResult.errors && introspectionResult.errors.length) ||
!introspectionResult.data.__schema) {
throw introspectionResult.errors;
}
else {
schema = graphql_1.buildClientSchema(introspectionResult.data);
return [2 /*return*/, schema];
}
return [2 /*return*/];
}
});
});
}
exports.default = introspectSchema;
//# sourceMappingURL=introspectSchema.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"introspectSchema.js","sourceRoot":"","sources":["../../src/stitching/introspectSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAAmD;AACnD,+CAA0D;AAG1D,iDAA4C;AAE5C,IAAM,wBAAwB,GAAiB,eAAK,CAAC,iCAAqB,EAAE,CAAC,CAAC;AAE9E,SAA8B,gBAAgB,CAC5C,OAA6B,EAC7B,WAAoC;;;;;;oBAEpC,0BAA0B;oBAC1B,IAAK,OAAsB,CAAC,OAAO,EAAE;wBACnC,OAAO,GAAG,uBAAa,CAAC,OAAqB,CAAC,CAAC;qBAChD;oBAE2B,qBAAO,OAAmB,CAAC;4BACrD,KAAK,EAAE,wBAAwB;4BAC/B,OAAO,EAAE,WAAW;yBACrB,CAAC,EAAA;;oBAHI,mBAAmB,GAAG,SAG1B;oBAEF,IACE,CAAC,mBAAmB,CAAC,MAAM,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC;wBACjE,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,EAClC;wBACA,MAAM,mBAAmB,CAAC,MAAM,CAAC;qBAClC;yBAAM;wBACC,MAAM,GAAG,2BAAiB,CAAC,mBAAmB,CAAC,IAEpD,CAAC,CAAC;wBACH,sBAAO,MAAM,EAAC;qBACf;;;;;CACF;AAzBD,mCAyBC"}

View File

@@ -0,0 +1,4 @@
import { Fetcher } from './makeRemoteExecutableSchema';
import { ApolloLink } from 'apollo-link';
export { execute } from 'apollo-link';
export default function linkToFetcher(link: ApolloLink): Fetcher;

View File

@@ -0,0 +1,11 @@
Object.defineProperty(exports, "__esModule", { value: true });
var apollo_link_1 = require("apollo-link");
var apollo_link_2 = require("apollo-link");
exports.execute = apollo_link_2.execute;
function linkToFetcher(link) {
return function (fetcherOperation) {
return apollo_link_1.makePromise(apollo_link_1.execute(link, fetcherOperation));
};
}
exports.default = linkToFetcher;
//# sourceMappingURL=linkToFetcher.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"linkToFetcher.js","sourceRoot":"","sources":["../../src/stitching/linkToFetcher.ts"],"names":[],"mappings":";AAEA,2CAKqB;AAErB,2CAAsC;AAA7B,gCAAA,OAAO,CAAA;AAEhB,SAAwB,aAAa,CAAC,IAAgB;IACpD,OAAO,UAAC,gBAAkC;QACxC,OAAO,yBAAW,CAAC,qBAAO,CAAC,IAAI,EAAE,gBAAkC,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC;AACJ,CAAC;AAJD,gCAIC"}

View File

@@ -0,0 +1,44 @@
import { ApolloLink } from 'apollo-link';
import { GraphQLFieldResolver, GraphQLSchema, ExecutionResult, GraphQLResolveInfo, DocumentNode, BuildSchemaOptions } from 'graphql';
export declare type ResolverFn = (rootValue?: any, args?: any, context?: any, info?: GraphQLResolveInfo) => AsyncIterator<any>;
export declare type Fetcher = (operation: FetcherOperation) => Promise<ExecutionResult>;
export declare type FetcherOperation = {
query: DocumentNode;
operationName?: string;
variables?: {
[key: string]: any;
};
context?: {
[key: string]: any;
};
};
/**
* This type has been copied inline from its source on `@types/graphql`:
*
* https://git.io/Jv8NX
*
* Previously, it was imported from `graphql/utilities/schemaPrinter`, however
* that module has been removed in `graphql@15`. Furthermore, the sole property
* on this type is due to be deprecated in `graphql@16`.
*/
interface PrintSchemaOptions {
/**
* Descriptions are defined as preceding string literals, however an older
* experimental version of the SDL supported preceding comments as
* descriptions. Set to true to enable this deprecated behavior.
* This option is provided to ease adoption and will be removed in v16.
*
* Default: false
*/
commentDescriptions?: boolean;
}
export default function makeRemoteExecutableSchema({ schema, link, fetcher, createResolver: customCreateResolver, buildSchemaOptions, printSchemaOptions }: {
schema: GraphQLSchema | string;
link?: ApolloLink;
fetcher?: Fetcher;
createResolver?: (fetcher: Fetcher) => GraphQLFieldResolver<any, any>;
buildSchemaOptions?: BuildSchemaOptions;
printSchemaOptions?: PrintSchemaOptions;
}): GraphQLSchema;
export declare function createResolver(fetcher: Fetcher): GraphQLFieldResolver<any, any>;
export {};

Some files were not shown because too many files have changed in this diff Show More