Skip to content

Commit 68f118d

Browse files
author
abhif22
committed
Adding support for handling query parse error by returning boolean value signifying any such error
1 parent 7c3964f commit 68f118d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

graphql.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ type Response struct {
142142
}
143143

144144
// Validate validates the given query with the schema.
145-
func (s *Schema) Validate(queryString string, variables map[string]interface{}) []*errors.QueryError {
145+
func (s *Schema) Validate(queryString string, variables map[string]interface{}) (bool, []*errors.QueryError) {
146146
doc, qErr := query.Parse(queryString)
147147
if qErr != nil {
148-
return []*errors.QueryError{qErr}
148+
return true, []*errors.QueryError{qErr}
149149
}
150-
return validation.Validate(s.schema, doc, variables, s.maxDepth)
150+
return false, validation.Validate(s.schema, doc, variables, s.maxDepth)
151151
}
152152

153153
// Exec executes the given query with the schema's resolver. It panics if the schema was created
@@ -174,7 +174,7 @@ func (s *Schema) exec(ctx context.Context, queryString string, operationName str
174174
if len(errs) != 0 {
175175

176176
for _, err := range errs {
177-
if err.Rule != "VariablesOfCorrectType" && err.Rule != ""{
177+
if err.Rule != "VariablesOfCorrectType" && err.Rule != "" {
178178
anyOtherValidationError = true
179179
}
180180
}

0 commit comments

Comments
 (0)