Skip to content

Commit 20c9a59

Browse files
authored
fix: add validation of null values with correct order of graphql rule validation (#8007) (#8008)
* fix: add validation of null values with correct order of graphql rule validation
1 parent be2103b commit 20c9a59

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/dgraph-io/badger/v3 v3.0.0-20210825061050-c2b23c471f5e
2323
github.com/dgraph-io/dgo/v210 v210.0.0-20210825123656-d3f867fe9cc3
2424
github.com/dgraph-io/gqlgen v0.13.2
25-
github.com/dgraph-io/gqlparser/v2 v2.2.0
25+
github.com/dgraph-io/gqlparser/v2 v2.2.1
2626
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15
2727
github.com/dgraph-io/ristretto v0.1.1-0.20210824115121-89e99415887a
2828
github.com/dgraph-io/simdjson-go v0.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ github.com/dgraph-io/dgo/v210 v210.0.0-20210825123656-d3f867fe9cc3/go.mod h1:dCz
173173
github.com/dgraph-io/gqlgen v0.13.2 h1:TNhndk+eHKj5qE7BenKKSYdSIdOGhLqxR1rCiMso9KM=
174174
github.com/dgraph-io/gqlgen v0.13.2/go.mod h1:iCOrOv9lngN7KAo+jMgvUPVDlYHdf7qDwsTkQby2Sis=
175175
github.com/dgraph-io/gqlparser/v2 v2.1.1/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
176-
github.com/dgraph-io/gqlparser/v2 v2.2.0 h1:fKSCW8OxoMogjDwUhO9OrFvrgIA0UZspTDbcm0QGk9M=
177-
github.com/dgraph-io/gqlparser/v2 v2.2.0/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
176+
github.com/dgraph-io/gqlparser/v2 v2.2.1 h1:15msK9XEHOSrRqQO48UU+2ZTf1R1U8+tfL9H5D5/eQQ=
177+
github.com/dgraph-io/gqlparser/v2 v2.2.1/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
178178
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15 h1:X2NRsgAtVUAp2nmTPCq+x+wTcRRrj74CEpy7E0Unsl4=
179179
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15/go.mod h1:7z3c/5w0sMYYZF5bHsrh8IH4fKwG5O5Y70cPH1ZLLRQ=
180180
github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug=

graphql/schema/rules.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ func init() {
4747
validator.AddRule("Check variable type is correct", variableTypeCheck)
4848
validator.AddRule("Check arguments of cascade directive", directiveArgumentsCheck)
4949
validator.AddRule("Check range for Int type", intRangeCheck)
50-
validator.AddRule("Input Coercion to List", listInputCoercion)
50+
// Graphql accept both single object and array of objects as value when the schema is defined
51+
// as an array. listInputCoercion changes the value to array if the single object is provided.
52+
// Changing the value can mess up with the other data validation rules hence we are setting
53+
// up the order to a high value so that it will be executed last.
54+
validator.AddRuleWithOrder("Input Coercion to List", 100, listInputCoercion)
5155
validator.AddRule("Check filter functions", filterCheck)
5256

5357
}

0 commit comments

Comments
 (0)