| 'use strict'; |
|
|
| var definition = require('graphql/type/definition'); |
|
|
| function bindFieldToContext() { |
| return function field(field) { |
| if (!field.type) { |
| throw new Error("A type must be passed to graphql.field()"); |
| } |
|
|
| return field; |
| }; |
| } |
|
|
| function bindObjectTypeToContext() { |
| return function object() { |
| return function objectInner(config) { |
| var _config$interfaces; |
|
|
| return { |
| kind: "object", |
| name: config.name, |
| graphQLType: new definition.GraphQLObjectType({ |
| name: config.name, |
| description: config.description, |
| isTypeOf: config.isTypeOf, |
| interfaces: (_config$interfaces = config.interfaces) === null || _config$interfaces === void 0 ? void 0 : _config$interfaces.map(x => x.graphQLType), |
| fields: () => { |
| const fields = typeof config.fields === "function" ? config.fields() : config.fields; |
| return buildFields(fields); |
| }, |
| extensions: config.extensions |
| }), |
| __source: undefined, |
| __context: undefined |
| }; |
| }; |
| }; |
| } |
|
|
| function buildFields(fields) { |
| return Object.fromEntries(Object.entries(fields).map(([key, val]) => [key, { |
| type: val.type.graphQLType, |
| resolve: val.resolve, |
| deprecationReason: val.deprecationReason, |
| description: val.description, |
| args: Object.fromEntries(Object.entries(val.args || {}).map(([key, val]) => [key, { |
| type: val.type.graphQLType, |
| description: val.description, |
| defaultValue: val.defaultValue, |
| deprecationReason: val.deprecationReason |
| }])), |
| extensions: val.extensions |
| }])); |
| } |
|
|
| function bindUnionTypeToContext() { |
| return function union(config) { |
| return { |
| kind: "union", |
| graphQLType: new definition.GraphQLUnionType({ |
| name: config.name, |
| description: config.description, |
| types: config.types.map(x => x.graphQLType), |
| resolveType: config.resolveType |
| }), |
| __source: undefined, |
| __context: undefined |
| }; |
| }; |
| } |
|
|
| function bindFieldsToContext() { |
| return function fields() { |
| return function fieldsInner(fields) { |
| return fields; |
| }; |
| }; |
| } |
|
|
| function bindInterfaceFieldToContext() { |
| return function interfaceField(field) { |
| return field; |
| }; |
| } |
|
|
| function bindInterfaceTypeToContext() { |
| return function interfaceType() { |
| return function interfaceInner(config) { |
| var _config$interfaces2; |
|
|
| return { |
| kind: "interface", |
| graphQLType: new definition.GraphQLInterfaceType({ |
| name: config.name, |
| description: config.description, |
| resolveType: config.resolveType, |
| interfaces: (_config$interfaces2 = config.interfaces) === null || _config$interfaces2 === void 0 ? void 0 : _config$interfaces2.map(x => x.graphQLType), |
| extensions: config.extensions, |
| fields: () => { |
| const fields = typeof config.fields === "function" ? config.fields() : config.fields; |
| return buildFields(fields); |
| } |
| }), |
| __source: undefined, |
| __context: undefined, |
| __fields: undefined |
| }; |
| }; |
| }; |
| } |
|
|
| function bindGraphQLSchemaAPIToContext() { |
| return { |
| object: bindObjectTypeToContext(), |
| union: bindUnionTypeToContext(), |
| field: bindFieldToContext(), |
| fields: bindFieldsToContext(), |
| interfaceField: bindInterfaceFieldToContext(), |
| interface: bindInterfaceTypeToContext() |
| }; |
| } |
|
|
| const __graphql = bindGraphQLSchemaAPIToContext(); |
|
|
| const { |
| field, |
| fields, |
| interfaceField, |
| object, |
| union |
| } = __graphql; |
| const interfaceType = __graphql.interface; |
|
|
| exports.bindGraphQLSchemaAPIToContext = bindGraphQLSchemaAPIToContext; |
| exports.field = field; |
| exports.fields = fields; |
| exports.interfaceField = interfaceField; |
| exports.interfaceType = interfaceType; |
| exports.object = object; |
| exports.union = union; |