@@ -936,6 +936,60 @@ Second line of the description.
936
936
return nil
937
937
},
938
938
},
939
+ {
940
+ name : "Decorating scalar with an undeclared directive should return an error" ,
941
+ sdl : `
942
+ scalar S @undeclareddirective
943
+ ` ,
944
+ validateError : func (err error ) error {
945
+ prefix := `graphql: directive "undeclareddirective" not found`
946
+ if err == nil || ! strings .HasPrefix (err .Error (), prefix ) {
947
+ return fmt .Errorf ("expected error starting with %q, but got %q" , prefix , err )
948
+ }
949
+ return nil
950
+ },
951
+ },
952
+ {
953
+ name : "Decorating argument with an undeclared directive should return an error" ,
954
+ sdl : `
955
+ type Query {
956
+ hello(name: String! @undeclareddirective): String!
957
+ }
958
+ ` ,
959
+ validateError : func (err error ) error {
960
+ prefix := `graphql: directive "undeclareddirective" not found`
961
+ if err == nil || ! strings .HasPrefix (err .Error (), prefix ) {
962
+ return fmt .Errorf ("expected error starting with %q, but got %q" , prefix , err )
963
+ }
964
+ return nil
965
+ },
966
+ },
967
+ {
968
+ name : "Decorating input object with an undeclared directive should return an error" ,
969
+ sdl : `
970
+ input InputObject @undeclareddirective{}
971
+ ` ,
972
+ validateError : func (err error ) error {
973
+ prefix := `graphql: directive "undeclareddirective" not found`
974
+ if err == nil || ! strings .HasPrefix (err .Error (), prefix ) {
975
+ return fmt .Errorf ("expected error starting with %q, but got %q" , prefix , err )
976
+ }
977
+ return nil
978
+ },
979
+ },
980
+ {
981
+ name : "Decorating interface with an undeclared directive should return an error" ,
982
+ sdl : `
983
+ interface I @undeclareddirective {}
984
+ ` ,
985
+ validateError : func (err error ) error {
986
+ prefix := `graphql: directive "undeclareddirective" not found`
987
+ if err == nil || ! strings .HasPrefix (err .Error (), prefix ) {
988
+ return fmt .Errorf ("expected error starting with %q, but got %q" , prefix , err )
989
+ }
990
+ return nil
991
+ },
992
+ },
939
993
} {
940
994
t .Run (test .name , func (t * testing.T ) {
941
995
s , err := schema .ParseSchema (test .sdl , test .useStringDescriptions )
0 commit comments