Skip to content

Commit

Permalink
remove dead code from buildASTSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Aug 16, 2017
1 parent 6953f97 commit d9178f4
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src/utilities/buildASTSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,26 +316,16 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
}

function typeDefNamed(typeName: string): GraphQLNamedType {
if (innerTypeMap[typeName]) {
return innerTypeMap[typeName];
}

if (!nodeMap[typeName]) {
throw new Error(`Type "${typeName}" not found in document.`);
}

const innerTypeDef = makeSchemaDef(nodeMap[typeName]);
if (!innerTypeDef) {
throw new Error(`Nothing constructed for "${typeName}".`);
if (!innerTypeMap[typeName]) {
if (!nodeMap[typeName]) {
throw new Error(`Type "${typeName}" not found in document.`);
}
innerTypeMap[typeName] = makeSchemaDef(nodeMap[typeName]);
}
innerTypeMap[typeName] = innerTypeDef;
return innerTypeDef;
return innerTypeMap[typeName];
}

function makeSchemaDef(def) {
if (!def) {
throw new Error('def must be defined');
}
switch (def.kind) {
case Kind.OBJECT_TYPE_DEFINITION:
return makeTypeDef(def);
Expand Down Expand Up @@ -403,9 +393,8 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
}

function makeInterfaceDef(def: InterfaceTypeDefinitionNode) {
const typeName = def.name.value;
return new GraphQLInterfaceType({
name: typeName,
name: def.name.value,
description: getDescription(def),
fields: () => makeFieldDefMap(def),
astNode: def,
Expand All @@ -414,7 +403,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
}

function makeEnumDef(def: EnumTypeDefinitionNode) {
const enumType = new GraphQLEnumType({
return new GraphQLEnumType({
name: def.name.value,
description: getDescription(def),
values: keyValMap(
Expand All @@ -428,8 +417,6 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
),
astNode: def,
});

return enumType;
}

function makeUnionDef(def: UnionTypeDefinitionNode) {
Expand Down

0 comments on commit d9178f4

Please sign in to comment.