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

perf(GraphQL): Part-1: Pagination for root user query is applied at root auth query (GRAPHQL-854) #7100

Merged
merged 2 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 10 additions & 10 deletions graphql/resolve/auth_query_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,11 @@
USER: "user1"
dgquery: |-
query {
queryUserSecret(func: uid(UserSecretRoot), orderasc: UserSecret.aSecret, first: 1) {
queryUserSecret(func: uid(UserSecretRoot), orderasc: UserSecret.aSecret) {
id : uid
ownedBy : UserSecret.ownedBy
}
UserSecretRoot as var(func: uid(UserSecret1)) @filter(uid(UserSecretAuth2))
UserSecretRoot as var(func: uid(UserSecret1), first: 1) @filter(uid(UserSecretAuth2))
UserSecret1 as var(func: type(UserSecret)) @filter(eq(UserSecret.ownedBy, "user2"))
UserSecretAuth2 as var(func: uid(UserSecret1)) @filter(eq(UserSecret.ownedBy, "user1")) @cascade
}
Expand Down Expand Up @@ -843,11 +843,11 @@
USER: "user1"
dgquery: |-
query {
queryMovie(func: uid(MovieRoot), orderasc: Movie.content, first: 10, offset: 10) {
queryMovie(func: uid(MovieRoot), orderasc: Movie.content) {
content : Movie.content
dgraph.uid : uid
}
MovieRoot as var(func: uid(Movie1)) @filter((NOT (uid(MovieAuth2)) AND (uid(MovieAuth3) OR uid(MovieAuth4))))
MovieRoot as var(func: uid(Movie1), first: 10, offset: 10) @filter((NOT (uid(MovieAuth2)) AND (uid(MovieAuth3) OR uid(MovieAuth4))))
Movie1 as var(func: type(Movie)) @filter(eq(Movie.content, "A. N. Author"))
MovieAuth2 as var(func: uid(Movie1)) @filter(eq(Movie.hidden, true)) @cascade
MovieAuth3 as var(func: uid(Movie1)) @cascade {
Expand Down Expand Up @@ -878,7 +878,7 @@
USER: "user1"
dgquery: |-
query {
queryMovie(func: uid(MovieRoot), orderasc: Movie.content, first: 10, offset: 10) @cascade {
queryMovie(func: uid(MovieRoot), orderasc: Movie.content) @cascade {
content : Movie.content
regionsAvailable : Movie.regionsAvailable @filter(uid(Region2)) (orderasc: Region.name, first: 10, offset: 10) {
name : Region.name
Expand All @@ -887,7 +887,7 @@
}
dgraph.uid : uid
}
MovieRoot as var(func: uid(Movie3)) @filter((NOT (uid(MovieAuth4)) AND (uid(MovieAuth5) OR uid(MovieAuth6))))
MovieRoot as var(func: uid(Movie3), first: 10, offset: 10) @filter((NOT (uid(MovieAuth4)) AND (uid(MovieAuth5) OR uid(MovieAuth6))))
Movie3 as var(func: type(Movie)) @filter(eq(Movie.content, "MovieXYZ"))
MovieAuth4 as var(func: uid(Movie3)) @filter(eq(Movie.hidden, true)) @cascade
MovieAuth5 as var(func: uid(Movie3)) @cascade {
Expand Down Expand Up @@ -931,7 +931,7 @@
USER: "user1"
dgquery: |-
query {
queryMovie(func: uid(MovieRoot), orderasc: Movie.content, first: 10, offset: 10) {
queryMovie(func: uid(MovieRoot), orderasc: Movie.content) {
content : Movie.content
regionsAvailable : Movie.regionsAvailable @filter(uid(Region7)) (orderasc: Region.name, first: 10, offset: 10) @cascade {
name : Region.name
Expand All @@ -951,7 +951,7 @@
}
dgraph.uid : uid
}
MovieRoot as var(func: uid(Movie8)) @filter((NOT (uid(MovieAuth9)) AND (uid(MovieAuth10) OR uid(MovieAuth11))))
MovieRoot as var(func: uid(Movie8), first: 10, offset: 10) @filter((NOT (uid(MovieAuth9)) AND (uid(MovieAuth10) OR uid(MovieAuth11))))
Movie8 as var(func: type(Movie)) @filter(eq(Movie.content, "MovieXYZ"))
MovieAuth9 as var(func: uid(Movie8)) @filter(eq(Movie.hidden, true)) @cascade
MovieAuth10 as var(func: uid(Movie8)) @cascade {
Expand Down Expand Up @@ -1526,12 +1526,12 @@
USER: "Random"
dgquery: |-
query {
queryPost(func: uid(PostRoot), orderdesc: Post.text, first: 10, offset: 5) {
queryPost(func: uid(PostRoot), orderdesc: Post.text) {
dgraph.type
text : Post.text
dgraph.uid : uid
}
PostRoot as var(func: uid(Post1)) @filter(((uid(QuestionAuth2) AND uid(QuestionAuth3)) OR uid(FbPostAuth4) OR uid(AnswerAuth5)))
PostRoot as var(func: uid(Post1), first: 10, offset: 5) @filter(((uid(QuestionAuth2) AND uid(QuestionAuth3)) OR uid(FbPostAuth4) OR uid(AnswerAuth5)))
Post1 as var(func: type(Post)) @filter(eq(Post.text, "A Post"))
Question1 as var(func: type(Question))
QuestionAuth2 as var(func: uid(Question1)) @filter(eq(Question.answered, true)) @cascade {
Expand Down
2 changes: 2 additions & 0 deletions graphql/resolve/query_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,11 @@ func (authRw *authRewriter) addAuthQueries(
Args: []gql.Arg{{Value: authRw.varName}},
},
Filter: filter,
Args: dgQuery[0].Args,
}

dgQuery[0].Filter = nil
dgQuery[0].Args = nil

// The user query starts from the var query generated above and is filtered
// by the the filter generated from auth processing, so now we build
Expand Down
7 changes: 6 additions & 1 deletion query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,12 @@ func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error) {
if len(sg.Attr) > 0 {
suffix += "." + sg.Attr
}
span := otrace.FromContext(ctx)
if len(sg.Params.Var) > 0 {
suffix += "." + sg.Params.Alias
}
ctx, span := otrace.StartSpan(ctx, "query.ProcessGraph."+suffix)
defer span.End()

stop := x.SpanTimer(span, "query.ProcessGraph"+suffix)
defer stop()

Expand Down