-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(graphql): Introducing Nested Filtering for Dgraph GraphQL API with Optimized Query Support #9100
feat(graphql): Introducing Nested Filtering for Dgraph GraphQL API with Optimized Query Support #9100
Changes from 14 commits
faecee6
83ed624
9012f15
55f5b6e
9fddbf7
01c84ca
c48b191
c4aa1b9
3544b65
3a5f682
a64fea4
00e4876
a3ab965
c95ecba
acbdbea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2148,3 +2148,112 @@ | |
Person.id : uid | ||
} | ||
} | ||
|
||
- | ||
name: "Query positive auth rules with nested filter" | ||
gqlquery: | | ||
query{ | ||
queryNested_X(filter: {y: {s: {eq: "-"}}}) { | ||
b | ||
y { s } | ||
} | ||
} | ||
jwtvar: | ||
rbac: positive | ||
dgquery: |- | ||
query { | ||
queryNested_X(func: uid(Nested_XRoot)) { | ||
Nested_X.b : Nested_X.b | ||
Nested_X.y : Nested_X.y @filter(uid(Nested_Y_1)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the filter appearing here? I don't think it's required? I am guessing that your intention is that If someone has a filter on root query, we should propagate that here as well? The problem is, what if I want to do a nested query where y.s has some value, but i want to see all the order values for that y as well. Lets just make it a filter at the root level for now, and then we can add a new api for y { s }. Something like y @filter(s: eq()) {s} |
||
Nested_Y.s : Nested_Y.s | ||
dgraph.uid : uid | ||
} | ||
dgraph.uid : uid | ||
} | ||
var(func: type(Nested_Y)) @filter(eq(Nested_Y.s, "-")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am guessing you have made the change from the RFC(requirement for @search), so that you don't have to use @cascade? |
||
queryNested_X_y as Nested_Z.x | ||
} | ||
Nested_XRoot as var(func: uid(Nested_X_3)) @filter(uid(Nested_X_Auth4)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we combine all of these queries? We have a lot of optimizations for multiple filters together. |
||
Nested_X_3 as var(func: type(Nested_X)) @filter((uid(queryNested_X_y))) | ||
Nested_X_Auth4 as var(func: uid(Nested_X_3)) @filter((uid(Nested_X_Auth4_y))) @cascade | ||
var(func: type(Nested_Y)) @filter(eq(Nested_Y.s, "y")) { | ||
Nested_X_Auth4_y as Nested_Z.x | ||
} | ||
var(func: uid(Nested_XRoot)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This query seems unnecessary? We are just repeating the queryNested_X |
||
Nested_Y_2 as Nested_X.y | ||
} | ||
Nested_Y_1 as var(func: uid(Nested_Y_2)) | ||
} | ||
|
||
- | ||
name: "Query negative auth rules with nested filter" | ||
gqlquery: | | ||
query{ | ||
queryNested_X(filter: {y: {s: {eq: "-"}}}) { | ||
b | ||
y { s } | ||
} | ||
} | ||
jwtvar: | ||
rbac: negative | ||
dgquery: |- | ||
query { | ||
queryNested_X(func: uid(Nested_XRoot)) { | ||
Nested_X.b : Nested_X.b | ||
dgraph.uid : uid | ||
} | ||
queryNested_X_y as var() | ||
Nested_XRoot as var(func: uid(Nested_X_3)) @filter(uid(Nested_X_Auth4)) | ||
Nested_X_3 as var(func: type(Nested_X)) @filter((uid(queryNested_X_y))) | ||
Nested_X_Auth4 as var(func: uid(Nested_X_3)) @filter((uid(Nested_X_Auth4_y))) @cascade | ||
var(func: type(Nested_Y)) @filter(eq(Nested_Y.s, "y")) { | ||
Nested_X_Auth4_y as Nested_Z.x | ||
} | ||
} | ||
|
||
- | ||
name: "Query uncertain auth rules with nested filter" | ||
gqlquery: | | ||
query{ | ||
queryNested_X(filter: {y: {s: {eq: "-"}}}) { | ||
b | ||
y { s } | ||
} | ||
} | ||
jwtvar: | ||
rbac: uncertain | ||
dgquery: |- | ||
query { | ||
queryNested_X(func: uid(Nested_XRoot)) { | ||
Nested_X.b : Nested_X.b | ||
Nested_X.y : Nested_X.y @filter(uid(Nested_Y_3)) { | ||
Nested_Y.s : Nested_Y.s | ||
dgraph.uid : uid | ||
} | ||
dgraph.uid : uid | ||
} | ||
var(func: uid(queryNested_X_yRoot)) { | ||
queryNested_X_y as Nested_Z.x | ||
} | ||
queryNested_X_yRoot as var(func: uid(Nested_Y_1)) @filter(uid(Nested_Y_Auth2)) | ||
Nested_Y_1 as var(func: type(Nested_Y)) @filter(eq(Nested_Y.s, "-")) | ||
Nested_Y_Auth2 as var(func: uid(Nested_Y_1)) @filter((uid(Nested_Y_Auth2_x))) @cascade | ||
var(func: type(Nested_X)) @filter(eq(Nested_X.b, true)) { | ||
Nested_Y_Auth2_x as Nested_X.y | ||
} | ||
Nested_XRoot as var(func: uid(Nested_X_6)) @filter(uid(Nested_X_Auth7)) | ||
Nested_X_6 as var(func: type(Nested_X)) @filter((uid(queryNested_X_y))) | ||
Nested_X_Auth7 as var(func: uid(Nested_X_6)) @filter((uid(Nested_X_Auth7_y))) @cascade | ||
var(func: type(Nested_Y)) @filter(eq(Nested_Y.s, "y")) { | ||
Nested_X_Auth7_y as Nested_Z.x | ||
} | ||
var(func: uid(Nested_XRoot)) { | ||
Nested_Y_4 as Nested_X.y | ||
} | ||
Nested_Y_3 as var(func: uid(Nested_Y_4)) @filter(uid(Nested_Y_Auth5)) | ||
Nested_Y_Auth5 as var(func: uid(Nested_Y_4)) @filter((uid(Nested_Y_Auth5_x))) @cascade | ||
var(func: type(Nested_X)) @filter(eq(Nested_X.b, true)) { | ||
Nested_Y_Auth5_x as Nested_X.y | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write one test around auth also? Where we have a auth filter on the query, so that we can make sure no uids are returned that shouldn't be