Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GraphQL): This PR fix panic error when we give null value in filter connectives. (#6707) #6729

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions graphql/resolve/query_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,9 @@ func buildFilter(typ schema.Type, filter map[string]interface{}) *gql.FilterTree
// Each key in filter is either "and", "or", "not" or the field name it
// applies to such as "title" in: `title: { anyofterms: "GraphQL" }``
for _, field := range keys {
if filter[field] == nil {
continue
}
switch field {

// In 'and', 'or' and 'not' cases, filter[field] must be a map[string]interface{}
Expand Down
16 changes: 15 additions & 1 deletion graphql/resolve/query_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,21 @@
dgraph.uid : uid
}
}

-
name: "Filter connectives with null values gets skipped "
gqlquery: |
query {
queryAuthor(filter: { name: { eq: "A. N. Author" },not:null }) {
name
}
}
dgquery: |-
query {
queryAuthor(func: type(Author)) @filter(eq(Author.name, "A. N. Author")) {
name : Author.name
dgraph.uid : uid
}
}
-
name: "Filters in same input object implies AND"
gqlquery: |
Expand Down