11
11
import { expect } from 'chai' ;
12
12
import { describe , it } from 'mocha' ;
13
13
import { execute } from '../execute' ;
14
- import { coerceValue } from '../values' ;
15
14
import { parse } from '../../language' ;
16
15
import {
17
16
GraphQLSchema ,
@@ -301,8 +300,8 @@ describe('Execute: Handles inputs', () => {
301
300
{
302
301
message :
303
302
'Variable "$input" got invalid value ' +
304
- '{"a":"foo","b":"bar","c":null}. ' +
305
- '\nIn field "c": Expected " String!", found null .' ,
303
+ '{"a":"foo","b":"bar","c":null}; ' +
304
+ 'Expected non-nullable type String! at value.c .' ,
306
305
locations : [ { line : 2 , column : 17 } ] ,
307
306
path : undefined ,
308
307
} ,
@@ -318,8 +317,8 @@ describe('Execute: Handles inputs', () => {
318
317
errors : [
319
318
{
320
319
message :
321
- 'Variable "$input" got invalid value "foo bar". ' +
322
- '\nExpected "TestInputObject", found not an object .' ,
320
+ 'Variable "$input" got invalid value "foo bar"; ' +
321
+ 'Expected object type TestInputObject .' ,
323
322
locations : [ { line : 2 , column : 17 } ] ,
324
323
path : undefined ,
325
324
} ,
@@ -335,8 +334,8 @@ describe('Execute: Handles inputs', () => {
335
334
errors : [
336
335
{
337
336
message :
338
- 'Variable "$input" got invalid value {"a":"foo","b":"bar"}. ' +
339
- '\nIn field "c": Expected " String!", found null .' ,
337
+ 'Variable "$input" got invalid value {"a":"foo","b":"bar"}; ' +
338
+ 'Field value.c of required type String! was not provided .' ,
340
339
locations : [ { line : 2 , column : 17 } ] ,
341
340
path : undefined ,
342
341
} ,
@@ -358,10 +357,15 @@ describe('Execute: Handles inputs', () => {
358
357
errors : [
359
358
{
360
359
message :
361
- 'Variable "$input" got invalid value {"na":{"a":"foo"}}.' +
362
- '\nIn field "na": In field "c": Expected "String!", ' +
363
- 'found null.' +
364
- '\nIn field "nb": Expected "String!", found null.' ,
360
+ 'Variable "$input" got invalid value {"na":{"a":"foo"}}; ' +
361
+ 'Field value.na.c of required type String! was not provided.' ,
362
+ locations : [ { line : 2 , column : 19 } ] ,
363
+ path : undefined ,
364
+ } ,
365
+ {
366
+ message :
367
+ 'Variable "$input" got invalid value {"na":{"a":"foo"}}; ' +
368
+ 'Field value.nb of required type String! was not provided.' ,
365
369
locations : [ { line : 2 , column : 19 } ] ,
366
370
path : undefined ,
367
371
} ,
@@ -380,8 +384,8 @@ describe('Execute: Handles inputs', () => {
380
384
{
381
385
message :
382
386
'Variable "$input" got invalid value ' +
383
- '{"a":"foo","b":"bar","c":"baz","extra":"dog"}. ' +
384
- '\nIn field "extra": Unknown field .' ,
387
+ '{"a":"foo","b":"bar","c":"baz","extra":"dog"}; ' +
388
+ 'Field "extra" is not defined by type TestInputObject .' ,
385
389
locations : [ { line : 2 , column : 17 } ] ,
386
390
path : undefined ,
387
391
} ,
@@ -535,8 +539,8 @@ describe('Execute: Handles inputs', () => {
535
539
errors : [
536
540
{
537
541
message :
538
- 'Variable "$value" got invalid value null.\n ' +
539
- 'Expected "String!", found null .' ,
542
+ 'Variable "$value" got invalid value null; ' +
543
+ 'Expected non-nullable type String! .' ,
540
544
locations : [ { line : 2 , column : 31 } ] ,
541
545
path : undefined ,
542
546
} ,
@@ -608,31 +612,21 @@ describe('Execute: Handles inputs', () => {
608
612
const ast = parse ( doc ) ;
609
613
const variables = { value : [ 1 , 2 , 3 ] } ;
610
614
611
- expect ( await execute ( schema , ast , null , null , variables ) ) . to . deep . equal ( {
615
+ const result = await execute ( schema , ast , null , null , variables ) ;
616
+
617
+ expect ( result ) . to . deep . equal ( {
612
618
errors : [
613
619
{
614
620
message :
615
- 'Variable "$value" got invalid value [1,2,3].\nExpected type ' +
616
- '" String", found [1,2,3] ; String cannot represent an array value: [1,2,3]' ,
621
+ 'Variable "$value" got invalid value [1,2,3]; Expected type ' +
622
+ 'String; String cannot represent an array value: [1,2,3]' ,
617
623
locations : [ { line : 2 , column : 31 } ] ,
618
624
path : undefined ,
619
625
} ,
620
626
] ,
621
627
} ) ;
622
- } ) ;
623
-
624
- it ( 'coercing an array to GraphQLString throws TypeError' , async ( ) => {
625
- let caughtError ;
626
- try {
627
- coerceValue ( GraphQLString , [ 1 , 2 , 3 ] ) ;
628
- } catch ( error ) {
629
- caughtError = error ;
630
- }
631
628
632
- expect ( caughtError instanceof TypeError ) . to . equal ( true ) ;
633
- expect ( caughtError && caughtError . message ) . to . equal (
634
- 'String cannot represent an array value: [1,2,3]' ,
635
- ) ;
629
+ expect ( result . errors [ 0 ] . originalError ) . not . to . equal ( undefined ) ;
636
630
} ) ;
637
631
638
632
it ( 'serializing an array via GraphQLString throws TypeError' , async ( ) => {
@@ -744,8 +738,8 @@ describe('Execute: Handles inputs', () => {
744
738
errors : [
745
739
{
746
740
message :
747
- 'Variable "$input" got invalid value null.\n ' +
748
- 'Expected " [String]!", found null .' ,
741
+ 'Variable "$input" got invalid value null; ' +
742
+ 'Expected non-nullable type [String]!.' ,
749
743
locations : [ { line : 2 , column : 17 } ] ,
750
744
path : undefined ,
751
745
} ,
@@ -835,8 +829,8 @@ describe('Execute: Handles inputs', () => {
835
829
errors : [
836
830
{
837
831
message :
838
- 'Variable "$input" got invalid value ["A",null,"B"]. ' +
839
- '\nIn element #1: Expected " String!", found null .' ,
832
+ 'Variable "$input" got invalid value ["A",null,"B"]; ' +
833
+ 'Expected non-nullable type String! at value[1] .' ,
840
834
locations : [ { line : 2 , column : 17 } ] ,
841
835
path : undefined ,
842
836
} ,
@@ -857,8 +851,8 @@ describe('Execute: Handles inputs', () => {
857
851
errors : [
858
852
{
859
853
message :
860
- 'Variable "$input" got invalid value null.\n ' +
861
- 'Expected " [String!]!", found null .' ,
854
+ 'Variable "$input" got invalid value null; ' +
855
+ 'Expected non-nullable type [String!]!.' ,
862
856
locations : [ { line : 2 , column : 17 } ] ,
863
857
path : undefined ,
864
858
} ,
@@ -897,8 +891,8 @@ describe('Execute: Handles inputs', () => {
897
891
errors : [
898
892
{
899
893
message :
900
- 'Variable "$input" got invalid value ["A",null,"B"]. ' +
901
- '\nIn element #1: Expected " String!", found null .' ,
894
+ 'Variable "$input" got invalid value ["A",null,"B"]; ' +
895
+ 'Expected non-nullable type String! at value[1] .' ,
902
896
locations : [ { line : 2 , column : 17 } ] ,
903
897
path : undefined ,
904
898
} ,
0 commit comments