Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-tools/schema-generator

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/schema-generator - npm Package Compare versions

Comparing version 5.0.1-alpha-5b99152.0 to 5.0.1-alpha-ac91d12.0

4

buildSchemaFromTypeDefinitions.d.ts

@@ -1,3 +0,5 @@

import { GraphQLSchema } from 'graphql';
import { GraphQLSchema, DocumentNode } from 'graphql';
import { ITypeDefinitions, GraphQLParseOptions } from '@graphql-tools/utils';
export declare function buildSchemaFromTypeDefinitions(typeDefinitions: ITypeDefinitions, parseOptions?: GraphQLParseOptions): GraphQLSchema;
export declare function isDocumentNode(typeDefinitions: ITypeDefinitions): typeDefinitions is DocumentNode;
export declare function buildDocumentFromTypeDefinitions(typeDefinitions: ITypeDefinitions, parseOptions?: GraphQLParseOptions): DocumentNode;

@@ -187,3 +187,3 @@ 'use strict';

const type = typeof typeDef;
throw new Error(`typeDef array must contain only strings and functions, got ${type}`);
throw new Error(`typeDef array must contain only strings, documents, or functions, got ${type}`);
}

@@ -198,22 +198,7 @@ });

function buildSchemaFromTypeDefinitions(typeDefinitions, parseOptions) {
// TODO: accept only array here, otherwise interfaces get confusing.
let myDefinitions = typeDefinitions;
let astDocument;
if (isDocumentNode(typeDefinitions)) {
astDocument = typeDefinitions;
}
else if (typeof myDefinitions !== 'string') {
if (!Array.isArray(myDefinitions)) {
const type = typeof myDefinitions;
throw new Error(`typeDefs must be a string, array or schema AST, got ${type}`);
}
myDefinitions = concatenateTypeDefs(myDefinitions);
}
if (typeof myDefinitions === 'string') {
astDocument = graphql.parse(myDefinitions, parseOptions);
}
const typesAst = filterExtensionDefinitions(astDocument);
const document = buildDocumentFromTypeDefinitions(typeDefinitions, parseOptions);
const typesAst = filterExtensionDefinitions(document);
const backcompatOptions = { commentDescriptions: true };
let schema = graphql.buildASTSchema(typesAst, backcompatOptions);
const extensionsAst = extractExtensionDefinitions(astDocument);
const extensionsAst = extractExtensionDefinitions(document);
if (extensionsAst.definitions.length > 0) {

@@ -227,2 +212,19 @@ schema = graphql.extendSchema(schema, extensionsAst, backcompatOptions);

}
function buildDocumentFromTypeDefinitions(typeDefinitions, parseOptions) {
let document;
if (typeof typeDefinitions === 'string') {
document = graphql.parse(typeDefinitions, parseOptions);
}
else if (Array.isArray(typeDefinitions)) {
document = graphql.parse(concatenateTypeDefs(typeDefinitions), parseOptions);
}
else if (isDocumentNode(typeDefinitions)) {
document = typeDefinitions;
}
else {
const type = typeof typeDefinitions;
throw new Error(`typeDefs must be a string, array or schema AST, got ${type}`);
}
return document;
}

@@ -519,2 +521,3 @@ function chainResolvers(resolvers) {

exports.addCatchUndefinedToSchema = addCatchUndefinedToSchema;
exports.addErrorLoggingToSchema = addErrorLoggingToSchema;

@@ -525,2 +528,3 @@ exports.addResolversToSchema = addResolversToSchema;

exports.attachDirectiveResolvers = attachDirectiveResolvers;
exports.buildDocumentFromTypeDefinitions = buildDocumentFromTypeDefinitions;
exports.buildSchemaFromTypeDefinitions = buildSchemaFromTypeDefinitions;

@@ -527,0 +531,0 @@ exports.chainResolvers = chainResolvers;

export { addSchemaLevelResolver } from './addSchemaLevelResolver';
export { assertResolversPresent } from './assertResolversPresent';
export { attachDirectiveResolvers } from './attachDirectiveResolvers';
export { buildSchemaFromTypeDefinitions } from './buildSchemaFromTypeDefinitions';
export { buildSchemaFromTypeDefinitions, buildDocumentFromTypeDefinitions } from './buildSchemaFromTypeDefinitions';
export { chainResolvers } from './chainResolvers';

@@ -13,2 +13,3 @@ export { concatenateTypeDefs } from './concatenateTypeDefs';

export { addErrorLoggingToSchema } from './addErrorLoggingToSchema';
export { addCatchUndefinedToSchema } from './addCatchUndefinedToSchema';
export { makeExecutableSchema } from './makeExecutableSchema';

@@ -1,2 +0,2 @@

import { defaultFieldResolver, isScalarType, getNamedType, Kind, print, parse, buildASTSchema, extendSchema, isAbstractType, isSchema, isEnumType, GraphQLEnumType, isUnionType, isObjectType, isInterfaceType } from 'graphql';
import { defaultFieldResolver, isScalarType, getNamedType, Kind, print, buildASTSchema, extendSchema, parse, isAbstractType, isSchema, isEnumType, GraphQLEnumType, isUnionType, isObjectType, isInterfaceType } from 'graphql';
import { forEachField, SchemaDirectiveVisitor, forEachDefaultValue, serializeInputValue, healSchema, parseInputValue, mergeDeep } from '@graphql-tools/utils';

@@ -183,3 +183,3 @@

const type = typeof typeDef;
throw new Error(`typeDef array must contain only strings and functions, got ${type}`);
throw new Error(`typeDef array must contain only strings, documents, or functions, got ${type}`);
}

@@ -194,22 +194,7 @@ });

function buildSchemaFromTypeDefinitions(typeDefinitions, parseOptions) {
// TODO: accept only array here, otherwise interfaces get confusing.
let myDefinitions = typeDefinitions;
let astDocument;
if (isDocumentNode(typeDefinitions)) {
astDocument = typeDefinitions;
}
else if (typeof myDefinitions !== 'string') {
if (!Array.isArray(myDefinitions)) {
const type = typeof myDefinitions;
throw new Error(`typeDefs must be a string, array or schema AST, got ${type}`);
}
myDefinitions = concatenateTypeDefs(myDefinitions);
}
if (typeof myDefinitions === 'string') {
astDocument = parse(myDefinitions, parseOptions);
}
const typesAst = filterExtensionDefinitions(astDocument);
const document = buildDocumentFromTypeDefinitions(typeDefinitions, parseOptions);
const typesAst = filterExtensionDefinitions(document);
const backcompatOptions = { commentDescriptions: true };
let schema = buildASTSchema(typesAst, backcompatOptions);
const extensionsAst = extractExtensionDefinitions(astDocument);
const extensionsAst = extractExtensionDefinitions(document);
if (extensionsAst.definitions.length > 0) {

@@ -223,2 +208,19 @@ schema = extendSchema(schema, extensionsAst, backcompatOptions);

}
function buildDocumentFromTypeDefinitions(typeDefinitions, parseOptions) {
let document;
if (typeof typeDefinitions === 'string') {
document = parse(typeDefinitions, parseOptions);
}
else if (Array.isArray(typeDefinitions)) {
document = parse(concatenateTypeDefs(typeDefinitions), parseOptions);
}
else if (isDocumentNode(typeDefinitions)) {
document = typeDefinitions;
}
else {
const type = typeof typeDefinitions;
throw new Error(`typeDefs must be a string, array or schema AST, got ${type}`);
}
return document;
}

@@ -515,3 +517,3 @@ function chainResolvers(resolvers) {

export { addErrorLoggingToSchema, addResolversToSchema, addSchemaLevelResolver, assertResolversPresent, attachDirectiveResolvers, buildSchemaFromTypeDefinitions, chainResolvers, checkForResolveTypeResolver, concatenateTypeDefs, decorateWithLogger, extendResolversFromInterfaces, extractExtensionDefinitions, filterExtensionDefinitions, makeExecutableSchema };
export { addCatchUndefinedToSchema, addErrorLoggingToSchema, addResolversToSchema, addSchemaLevelResolver, assertResolversPresent, attachDirectiveResolvers, buildDocumentFromTypeDefinitions, buildSchemaFromTypeDefinitions, chainResolvers, checkForResolveTypeResolver, concatenateTypeDefs, decorateWithLogger, extendResolversFromInterfaces, extractExtensionDefinitions, filterExtensionDefinitions, makeExecutableSchema };
//# sourceMappingURL=index.esm.js.map
{
"name": "@graphql-tools/schema-generator",
"version": "5.0.1-alpha-5b99152.0",
"version": "5.0.1-alpha-ac91d12.0",
"description": "A set of utils for faster development of GraphQL tools",

@@ -9,3 +9,3 @@ "peerDependencies": {

"dependencies": {
"@graphql-tools/utils": "5.0.1-alpha-5b99152.0",
"@graphql-tools/utils": "5.0.1-alpha-ac91d12.0",
"tslib": "1.11.1"

@@ -12,0 +12,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc