Skip to content

Commit

Permalink
[Bugfix]: Not validating queries with non-null params.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhif22 committed Sep 1, 2019
1 parent 0e4463d commit 3e31d0e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ type Response struct {
}

// Validate validates the given query with the schema.
func (s *Schema) Validate(queryString string) []*errors.QueryError {
func (s *Schema) Validate(queryString string, variables map[string]interface{}) []*errors.QueryError {
doc, qErr := query.Parse(queryString)
if qErr != nil {
return []*errors.QueryError{qErr}
}

return validation.Validate(s.schema, doc, nil, s.maxDepth)
return validation.Validate(s.schema, doc, variables, s.maxDepth)
}

// Exec executes the given query with the schema's resolver. It panics if the schema was created
Expand Down Expand Up @@ -181,7 +180,7 @@ func (s *Schema) exec(ctx context.Context, queryString string, operationName str

// Subscriptions are not valid in Exec. Use schema.Subscribe() instead.
if op.Type == query.Subscription {
return &Response{Errors: []*errors.QueryError{&errors.QueryError{ Message: "graphql-ws protocol header is missing" }}}
return &Response{Errors: []*errors.QueryError{&errors.QueryError{Message: "graphql-ws protocol header is missing"}}}
}

// Fill in variables with the defaults from the operation
Expand Down

0 comments on commit 3e31d0e

Please sign in to comment.