Skip to content

Commit

Permalink
refactor: remove duplicate core schema type checks (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser authored Sep 2, 2021
1 parent d4c6260 commit e65b5a7
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,6 @@ export function makeSchemaInternal(config: SchemaConfig) {
builder.addTypes(config.schemaRoots)
}
const { finalConfig, typeMap, missingTypes, schemaExtension, onAfterBuildFns } = builder.getFinalTypeMap()
const { Query, Mutation, Subscription } = typeMap

function getRootType(rootType: 'query' | 'mutation' | 'subscription', defaultType: string) {
const rootTypeVal = config.schemaRoots?.[rootType] ?? defaultType
Expand All @@ -1736,19 +1735,6 @@ export function makeSchemaInternal(config: SchemaConfig) {
return returnVal
}

/* istanbul ignore next */
if (!isObjectType(Query)) {
throw new Error(`Expected Query to be a objectType, saw ${Query.constructor.name}`)
}
/* istanbul ignore next */
if (Mutation && !isObjectType(Mutation)) {
throw new Error(`Expected Mutation to be a objectType, saw ${Mutation.constructor.name}`)
}
/* istanbul ignore next */
if (Subscription && !isObjectType(Subscription)) {
throw new Error(`Expected Subscription to be a objectType, saw ${Subscription.constructor.name}`)
}

const schema = new GraphQLSchema({
query: getRootType('query', 'Query'),
mutation: getRootType('mutation', 'Mutation'),
Expand Down

0 comments on commit e65b5a7

Please sign in to comment.