@@ -19,6 +19,7 @@ import {
1919 assertListType ,
2020 assertNamedType ,
2121 assertNonNullType ,
22+ assertSemanticNonNullType ,
2223 assertNullableType ,
2324 assertObjectType ,
2425 assertOutputType ,
@@ -33,6 +34,7 @@ import {
3334 GraphQLInterfaceType ,
3435 GraphQLList ,
3536 GraphQLNonNull ,
37+ GraphQLSemanticNonNull ,
3638 GraphQLObjectType ,
3739 GraphQLScalarType ,
3840 GraphQLUnionType ,
@@ -46,6 +48,7 @@ import {
4648 isListType ,
4749 isNamedType ,
4850 isNonNullType ,
51+ isSemanticNonNullType ,
4952 isNullableType ,
5053 isObjectType ,
5154 isOutputType ,
@@ -298,6 +301,45 @@ describe('Type predicates', () => {
298301 expect ( ( ) =>
299302 assertNonNullType ( new GraphQLList ( new GraphQLNonNull ( ObjectType ) ) ) ,
300303 ) . to . throw ( ) ;
304+ expect ( isNonNullType ( new GraphQLSemanticNonNull ( ObjectType ) ) ) . to . equal (
305+ false ,
306+ ) ;
307+ expect ( ( ) =>
308+ assertNonNullType ( new GraphQLSemanticNonNull ( ObjectType ) ) ,
309+ ) . to . throw ( ) ;
310+ } ) ;
311+ } ) ;
312+
313+ describe ( 'isSemanticNonNullType' , ( ) => {
314+ it ( 'returns true for a semantic-non-null wrapped type' , ( ) => {
315+ expect (
316+ isSemanticNonNullType ( new GraphQLSemanticNonNull ( ObjectType ) ) ,
317+ ) . to . equal ( true ) ;
318+ expect ( ( ) =>
319+ assertSemanticNonNullType ( new GraphQLSemanticNonNull ( ObjectType ) ) ,
320+ ) . to . not . throw ( ) ;
321+ } ) ;
322+
323+ it ( 'returns false for an unwrapped type' , ( ) => {
324+ expect ( isSemanticNonNullType ( ObjectType ) ) . to . equal ( false ) ;
325+ expect ( ( ) => assertSemanticNonNullType ( ObjectType ) ) . to . throw ( ) ;
326+ } ) ;
327+
328+ it ( 'returns false for a not non-null wrapped type' , ( ) => {
329+ expect (
330+ isSemanticNonNullType (
331+ new GraphQLList ( new GraphQLSemanticNonNull ( ObjectType ) ) ,
332+ ) ,
333+ ) . to . equal ( false ) ;
334+ expect ( ( ) =>
335+ assertSemanticNonNullType (
336+ new GraphQLList ( new GraphQLSemanticNonNull ( ObjectType ) ) ,
337+ ) ,
338+ ) . to . throw ( ) ;
339+ expect ( isNonNullType ( new GraphQLNonNull ( ObjectType ) ) ) . to . equal ( false ) ;
340+ expect ( ( ) =>
341+ assertNonNullType ( new GraphQLNonNull ( ObjectType ) ) ,
342+ ) . to . throw ( ) ;
301343 } ) ;
302344 } ) ;
303345
0 commit comments