@@ -190,7 +190,7 @@ type directiveValidator func(
190190 typ * ast.Definition ,
191191 field * ast.FieldDefinition ,
192192 dir * ast.Directive ,
193- secrets map [string ]x.SensitiveByteSlice ) * gqlerror.Error
193+ secrets map [string ]x.SensitiveByteSlice ) gqlerror.List
194194
195195type searchTypeIndex struct {
196196 gqlType string
@@ -289,38 +289,32 @@ var scalarToDgraph = map[string]string{
289289 "Password" : "password" ,
290290}
291291
292+ func ValidatorNoOp (
293+ sch * ast.Schema ,
294+ typ * ast.Definition ,
295+ field * ast.FieldDefinition ,
296+ dir * ast.Directive ,
297+ secrets map [string ]x.SensitiveByteSlice ) gqlerror.List {
298+ return nil
299+ }
300+
292301var directiveValidators = map [string ]directiveValidator {
293- inverseDirective : hasInverseValidation ,
294- searchDirective : searchValidation ,
295- dgraphDirective : dgraphDirectiveValidation ,
296- idDirective : idValidation ,
297- secretDirective : passwordValidation ,
298- customDirective : customDirectiveValidation ,
299- remoteDirective : remoteDirectiveValidation ,
300- deprecatedDirective : func (
301- sch * ast.Schema ,
302- typ * ast.Definition ,
303- field * ast.FieldDefinition ,
304- dir * ast.Directive ,
305- secrets map [string ]x.SensitiveByteSlice ) * gqlerror.Error {
306- return nil
307- },
302+ inverseDirective : hasInverseValidation ,
303+ searchDirective : searchValidation ,
304+ dgraphDirective : dgraphDirectiveValidation ,
305+ idDirective : idValidation ,
306+ secretDirective : passwordValidation ,
307+ customDirective : customDirectiveValidation ,
308+ remoteDirective : ValidatorNoOp ,
309+ deprecatedDirective : ValidatorNoOp ,
308310 // Just go get it printed into generated schema
309- authDirective : func (
310- sch * ast.Schema ,
311- typ * ast.Definition ,
312- field * ast.FieldDefinition ,
313- dir * ast.Directive ,
314- secrets map [string ]x.SensitiveByteSlice ) * gqlerror.Error {
315- return nil
316- },
311+ authDirective : ValidatorNoOp ,
317312}
318313
319314var schemaDocValidations []func (schema * ast.SchemaDocument ) gqlerror.List
320315var schemaValidations []func (schema * ast.Schema , definitions []string ) gqlerror.List
321- var defnValidations , typeValidations []func (schema * ast.Schema ,
322- defn * ast.Definition ) * gqlerror.Error
323- var fieldValidations []func (typ * ast.Definition , field * ast.FieldDefinition ) * gqlerror.Error
316+ var defnValidations , typeValidations []func (schema * ast.Schema , defn * ast.Definition ) gqlerror.List
317+ var fieldValidations []func (typ * ast.Definition , field * ast.FieldDefinition ) gqlerror.List
324318
325319func copyAstFieldDef (src * ast.FieldDefinition ) * ast.FieldDefinition {
326320 var dirs ast.DirectiveList
@@ -425,8 +419,7 @@ func postGQLValidation(schema *ast.Schema, definitions []string,
425419 if directiveValidators [dir .Name ] == nil {
426420 continue
427421 }
428- errs = appendIfNotNull (errs ,
429- directiveValidators [dir.Name ](schema , typ , field , dir , secrets ))
422+ errs = append (errs , directiveValidators [dir.Name ](schema , typ , field , dir , secrets )... )
430423 }
431424 }
432425 }
@@ -463,21 +456,19 @@ func applySchemaValidations(schema *ast.Schema, definitions []string) gqlerror.L
463456}
464457
465458func applyDefnValidations (defn * ast.Definition , schema * ast.Schema ,
466- rules []func (schema * ast.Schema , defn * ast.Definition ) * gqlerror.Error ) gqlerror.List {
459+ rules []func (schema * ast.Schema , defn * ast.Definition ) gqlerror.List ) gqlerror.List {
467460 var errs []* gqlerror.Error
468-
469461 for _ , rule := range rules {
470- errs = appendIfNotNull (errs , rule (schema , defn ))
462+ errs = append (errs , rule (schema , defn )... )
471463 }
472-
473464 return errs
474465}
475466
476467func applyFieldValidations (typ * ast.Definition , field * ast.FieldDefinition ) gqlerror.List {
477468 var errs []* gqlerror.Error
478469
479470 for _ , rule := range fieldValidations {
480- errs = appendIfNotNull (errs , rule (typ , field ))
471+ errs = append (errs , rule (typ , field )... )
481472 }
482473
483474 return errs
0 commit comments