Skip to content

Commit 135c6ff

Browse files
Adding variables parameter for query validations.
1 parent c5bdf3b commit 135c6ff

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
@@ -146,12 +146,17 @@ type Response struct {
146146

147147
// Validate validates the given query with the schema.
148148
func (s *Schema) Validate(queryString string) []*errors.QueryError {
149+
return s.ValidateWithVariables(queryString, nil)
150+
}
151+
152+
// ValidateWithVariables validates the given query with the schema and the input variables.
153+
func (s *Schema) ValidateWithVariables(queryString string, variables map[string]interface{}) []*errors.QueryError {
149154
doc, qErr := query.Parse(queryString)
150155
if qErr != nil {
151156
return []*errors.QueryError{qErr}
152157
}
153158

154-
return validation.Validate(s.schema, doc, nil, s.maxDepth)
159+
return validation.Validate(s.schema, doc, variables, s.maxDepth)
155160
}
156161

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

0 commit comments

Comments
 (0)