Skip to content

Commit

Permalink
buildClientSchema: move inner functions to follow return (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Jan 21, 2019
1 parent 183ff32 commit bdfd1c6
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/utilities/buildClientSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,36 @@ export function buildClientSchema(
}
}

// Get the root Query, Mutation, and Subscription types.
const queryType = schemaIntrospection.queryType
? getObjectType(schemaIntrospection.queryType)
: null;

const mutationType = schemaIntrospection.mutationType
? getObjectType(schemaIntrospection.mutationType)
: null;

const subscriptionType = schemaIntrospection.subscriptionType
? getObjectType(schemaIntrospection.subscriptionType)
: null;

// Get the directives supported by Introspection, assuming empty-set if
// directives were not queried for.
const directives = schemaIntrospection.directives
? schemaIntrospection.directives.map(buildDirective)
: [];

// Then produce and return a Schema with these types.
return new GraphQLSchema({
query: queryType,
mutation: mutationType,
subscription: subscriptionType,
types: objectValues(typeMap),
directives,
assumeValid: options && options.assumeValid,
allowedLegacyNames: options && options.allowedLegacyNames,
});

// Given a type reference in introspection, return the GraphQLType instance.
// preferring cached instances before building new instances.
function getType(typeRef: IntrospectionTypeRef): GraphQLType {
Expand Down Expand Up @@ -356,34 +386,4 @@ export function buildClientSchema(
args: buildInputValueDefMap(directiveIntrospection.args),
});
}

// Get the root Query, Mutation, and Subscription types.
const queryType = schemaIntrospection.queryType
? getObjectType(schemaIntrospection.queryType)
: null;

const mutationType = schemaIntrospection.mutationType
? getObjectType(schemaIntrospection.mutationType)
: null;

const subscriptionType = schemaIntrospection.subscriptionType
? getObjectType(schemaIntrospection.subscriptionType)
: null;

// Get the directives supported by Introspection, assuming empty-set if
// directives were not queried for.
const directives = schemaIntrospection.directives
? schemaIntrospection.directives.map(buildDirective)
: [];

// Then produce and return a Schema with these types.
return new GraphQLSchema({
query: queryType,
mutation: mutationType,
subscription: subscriptionType,
types: objectValues(typeMap),
directives,
assumeValid: options && options.assumeValid,
allowedLegacyNames: options && options.allowedLegacyNames,
});
}

0 comments on commit bdfd1c6

Please sign in to comment.