Skip to content

Commit d5f4f41

Browse files
authored
Merge pull request #415 from smotavitaendava/master
Adding variables parameter for query validations.
2 parents 1f70736 + 135c6ff commit d5f4f41

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

graphql.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,17 @@ type Response struct {
157157

158158
// Validate validates the given query with the schema.
159159
func (s *Schema) Validate(queryString string) []*errors.QueryError {
160+
return s.ValidateWithVariables(queryString, nil)
161+
}
162+
163+
// ValidateWithVariables validates the given query with the schema and the input variables.
164+
func (s *Schema) ValidateWithVariables(queryString string, variables map[string]interface{}) []*errors.QueryError {
160165
doc, qErr := query.Parse(queryString)
161166
if qErr != nil {
162167
return []*errors.QueryError{qErr}
163168
}
164169

165-
return validation.Validate(s.schema, doc, nil, s.maxDepth)
170+
return validation.Validate(s.schema, doc, variables, s.maxDepth)
166171
}
167172

168173
// Exec executes the given query with the schema's resolver. It panics if the schema was created

0 commit comments

Comments
 (0)