Skip to content

Commit

Permalink
fix: add validation of null values with correct order of graphql rule…
Browse files Browse the repository at this point in the history
… validation (#8007) (#8008)

* fix: add validation of null values with correct order of graphql rule validation
  • Loading branch information
aman-bansal authored Aug 31, 2021
1 parent be2103b commit 20c9a59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/dgraph-io/badger/v3 v3.0.0-20210825061050-c2b23c471f5e
github.com/dgraph-io/dgo/v210 v210.0.0-20210825123656-d3f867fe9cc3
github.com/dgraph-io/gqlgen v0.13.2
github.com/dgraph-io/gqlparser/v2 v2.2.0
github.com/dgraph-io/gqlparser/v2 v2.2.1
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15
github.com/dgraph-io/ristretto v0.1.1-0.20210824115121-89e99415887a
github.com/dgraph-io/simdjson-go v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ github.com/dgraph-io/dgo/v210 v210.0.0-20210825123656-d3f867fe9cc3/go.mod h1:dCz
github.com/dgraph-io/gqlgen v0.13.2 h1:TNhndk+eHKj5qE7BenKKSYdSIdOGhLqxR1rCiMso9KM=
github.com/dgraph-io/gqlgen v0.13.2/go.mod h1:iCOrOv9lngN7KAo+jMgvUPVDlYHdf7qDwsTkQby2Sis=
github.com/dgraph-io/gqlparser/v2 v2.1.1/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
github.com/dgraph-io/gqlparser/v2 v2.2.0 h1:fKSCW8OxoMogjDwUhO9OrFvrgIA0UZspTDbcm0QGk9M=
github.com/dgraph-io/gqlparser/v2 v2.2.0/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
github.com/dgraph-io/gqlparser/v2 v2.2.1 h1:15msK9XEHOSrRqQO48UU+2ZTf1R1U8+tfL9H5D5/eQQ=
github.com/dgraph-io/gqlparser/v2 v2.2.1/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15 h1:X2NRsgAtVUAp2nmTPCq+x+wTcRRrj74CEpy7E0Unsl4=
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15/go.mod h1:7z3c/5w0sMYYZF5bHsrh8IH4fKwG5O5Y70cPH1ZLLRQ=
github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug=
Expand Down
6 changes: 5 additions & 1 deletion graphql/schema/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ func init() {
validator.AddRule("Check variable type is correct", variableTypeCheck)
validator.AddRule("Check arguments of cascade directive", directiveArgumentsCheck)
validator.AddRule("Check range for Int type", intRangeCheck)
validator.AddRule("Input Coercion to List", listInputCoercion)
// Graphql accept both single object and array of objects as value when the schema is defined
// as an array. listInputCoercion changes the value to array if the single object is provided.
// Changing the value can mess up with the other data validation rules hence we are setting
// up the order to a high value so that it will be executed last.
validator.AddRuleWithOrder("Input Coercion to List", 100, listInputCoercion)
validator.AddRule("Check filter functions", filterCheck)

}
Expand Down

0 comments on commit 20c9a59

Please sign in to comment.