File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -320,7 +320,6 @@ type Hello { testUnion: TestUnion }
320
320
. to . throw ( 'Type Bar not found in document' ) ;
321
321
} ) ;
322
322
323
-
324
323
it ( 'Unknown query type' , ( ) => {
325
324
var body = `
326
325
type Hello {
@@ -331,4 +330,15 @@ type Hello {
331
330
expect ( ( ) => buildASTSchema ( doc , 'Wat' ) )
332
331
. to . throw ( 'Specified query type Wat not found in document' ) ;
333
332
} ) ;
333
+
334
+ it ( 'Unknown mutation type' , ( ) => {
335
+ var body = `
336
+ type Hello {
337
+ str: String
338
+ }
339
+ ` ;
340
+ var doc = parseSchemaIntoAST ( body ) ;
341
+ expect ( ( ) => buildASTSchema ( doc , 'Hello' , 'Wat' ) )
342
+ . to . throw ( 'Specified mutation type Wat not found in document' ) ;
343
+ } ) ;
334
344
} ) ;
Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ export function buildASTSchema(
105
105
' not found in document.' ) ;
106
106
}
107
107
108
+ if ( ! isNullish ( mutationTypeName ) && isNullish ( astMap [ mutationTypeName ] ) ) {
109
+ throw new Error ( 'Specified mutation type ' + mutationTypeName +
110
+ ' not found in document.' ) ;
111
+ }
112
+
108
113
/**
109
114
* This generates a function that allows you to produce
110
115
* type definitions on demand. We produce the function
@@ -142,10 +147,6 @@ export function buildASTSchema(
142
147
143
148
var produceTypeDef = getTypeDefProducer ( ast ) ;
144
149
145
- if ( isNullish ( astMap [ queryTypeName ] ) ) {
146
- throw new Error ( `Type ${ queryTypeName } not found in document` ) ;
147
- }
148
-
149
150
ast . definitions . forEach ( produceTypeDef ) ;
150
151
151
152
var queryType = produceTypeDef ( astMap [ queryTypeName ] ) ;
You can’t perform that action at this time.
0 commit comments