@@ -11,6 +11,7 @@ import { describe, it } from 'mocha';
11
11
import { expect } from 'chai' ;
12
12
import dedent from '../../jsutils/dedent' ;
13
13
import invariant from '../../jsutils/invariant' ;
14
+ import { buildSchema } from '../buildASTSchema' ;
14
15
import { extendSchema } from '../extendSchema' ;
15
16
import { parse , print , DirectiveLocation } from '../../language' ;
16
17
import { printSchema } from '../schemaPrinter' ;
@@ -30,7 +31,10 @@ import {
30
31
GraphQLInterfaceType ,
31
32
GraphQLUnionType ,
32
33
GraphQLID ,
34
+ GraphQLInt ,
35
+ GraphQLFloat ,
33
36
GraphQLString ,
37
+ GraphQLBoolean ,
34
38
GraphQLEnumType ,
35
39
GraphQLInputObjectType ,
36
40
GraphQLNonNull ,
@@ -266,6 +270,48 @@ describe('extendSchema', () => {
266
270
expect ( queryType . getFields ( ) . foo ) . to . include ( { type : fooType } ) ;
267
271
} ) ;
268
272
273
+ it ( 'extends objects with standard type fields' , ( ) => {
274
+ const schema = buildSchema ( `
275
+ type Query {
276
+ str: String
277
+ }
278
+ ` ) ;
279
+
280
+ expect ( schema . getType ( 'Int' ) ) . to . equal ( undefined ) ;
281
+ expect ( schema . getType ( 'Float' ) ) . to . equal ( undefined ) ;
282
+ expect ( schema . getType ( 'String' ) ) . to . equal ( GraphQLString ) ;
283
+ expect ( schema . getType ( 'Boolean' ) ) . to . equal ( GraphQLBoolean ) ;
284
+ expect ( schema . getType ( 'ID' ) ) . to . equal ( undefined ) ;
285
+
286
+ const extendAST = parse ( `
287
+ extend type Query {
288
+ bool: Boolean
289
+ }
290
+ ` ) ;
291
+ const extendedSchema = extendSchema ( schema , extendAST ) ;
292
+
293
+ expect ( extendedSchema . getType ( 'Int' ) ) . to . equal ( undefined ) ;
294
+ expect ( extendedSchema . getType ( 'Float' ) ) . to . equal ( undefined ) ;
295
+ expect ( extendedSchema . getType ( 'String' ) ) . to . equal ( GraphQLString ) ;
296
+ expect ( extendedSchema . getType ( 'Boolean' ) ) . to . equal ( GraphQLBoolean ) ;
297
+ expect ( extendedSchema . getType ( 'ID' ) ) . to . equal ( undefined ) ;
298
+
299
+ const extendTwiceAST = parse ( `
300
+ extend type Query {
301
+ int: Int
302
+ float: Float
303
+ id: ID
304
+ }
305
+ ` ) ;
306
+ const extendedTwiceSchema = extendSchema ( schema , extendTwiceAST ) ;
307
+
308
+ expect ( extendedTwiceSchema . getType ( 'Int' ) ) . to . equal ( GraphQLInt ) ;
309
+ expect ( extendedTwiceSchema . getType ( 'Float' ) ) . to . equal ( GraphQLFloat ) ;
310
+ expect ( extendedTwiceSchema . getType ( 'String' ) ) . to . equal ( GraphQLString ) ;
311
+ expect ( extendedTwiceSchema . getType ( 'Boolean' ) ) . to . equal ( GraphQLBoolean ) ;
312
+ expect ( extendedTwiceSchema . getType ( 'ID' ) ) . to . equal ( GraphQLID ) ;
313
+ } ) ;
314
+
269
315
it ( 'extends enums by adding new values' , ( ) => {
270
316
const extendedSchema = extendTestSchema ( `
271
317
extend enum SomeEnum {
0 commit comments