Skip to content

Commit

Permalink
Minor simplification in extendSchema (#1349)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored and mjmahone committed May 16, 2018
1 parent 0276d68 commit 7199b3d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/utilities/extendSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,20 @@ export function extendSchema(
return type;
}

if (!extendTypeCache[type.name]) {
const name = type.name;
if (!extendTypeCache[name]) {
if (isObjectType(type)) {
extendTypeCache[type.name] = extendObjectType(type);
extendTypeCache[name] = extendObjectType(type);
} else if (isInterfaceType(type)) {
extendTypeCache[type.name] = extendInterfaceType(type);
extendTypeCache[name] = extendInterfaceType(type);
} else if (isUnionType(type)) {
extendTypeCache[type.name] = extendUnionType(type);
extendTypeCache[name] = extendUnionType(type);
} else {
// This type is not yet extendable.
extendTypeCache[type.name] = type;
extendTypeCache[name] = type;
}
}
return (extendTypeCache[type.name]: any);
return (extendTypeCache[name]: any);
}

function extendObjectType(type: GraphQLObjectType): GraphQLObjectType {
Expand Down

0 comments on commit 7199b3d

Please sign in to comment.