Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vmrajas committed Nov 4, 2020
1 parent ab35b89 commit c636184
Show file tree
Hide file tree
Showing 33 changed files with 194 additions and 219 deletions.
12 changes: 6 additions & 6 deletions graphql/e2e/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1414,18 +1414,18 @@ func TestChildCountQueryWithDeepRBAC(t *testing.T) {
{
user: "user1",
role: "USER",
result: `{"queryUser": [{"username": "user1", "aggregate_issues":{"count": null}}]}`},
result: `{"queryUser": [{"username": "user1", "aggregateissues":{"count": null}}]}`},
{
user: "user1",
role: "ADMIN",
result: `{"queryUser":[{"username":"user1","aggregate_issues":{"count":1}}]}`},
result: `{"queryUser":[{"username":"user1","aggregateissues":{"count":1}}]}`},
}

query := `
query {
queryUser (filter:{username:{eq:"user1"}}) {
username
aggregate_issues {
aggregateissues {
count
}
}
Expand All @@ -1452,18 +1452,18 @@ func TestChildCountQueryWithOtherFields(t *testing.T) {
{
user: "user1",
role: "USER",
result: `{"queryUser": [{"username": "user1","issues":[],"aggregate_issues":{"count": null}}]}`},
result: `{"queryUser": [{"username": "user1","issues":[],"aggregateissues":{"count": null}}]}`},
{
user: "user1",
role: "ADMIN",
result: `{"queryUser":[{"username":"user1","issues":[{"msg":"Issue1"}],"aggregate_issues":{"count":1}}]}`},
result: `{"queryUser":[{"username":"user1","issues":[{"msg":"Issue1"}],"aggregateissues":{"count":1}}]}`},
}

query := `
query {
queryUser (filter:{username:{eq:"user1"}}) {
username
aggregate_issues {
aggregateissues {
count
}
issues {
Expand Down
12 changes: 6 additions & 6 deletions graphql/e2e/common/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2444,13 +2444,13 @@ func queryCountWithAlias(t *testing.T) {

func queryCountAtChildLevel(t *testing.T) {
queryNumberOfStates := &GraphQLParams{
Query: `query
Query: `query
{
queryCountry(filter: { name: { eq: "India" } }) {
name
ag : aggregate_states {
count
}
ag : aggregatestates {
count
}
}
}`,
}
Expand All @@ -2475,7 +2475,7 @@ func queryCountAtChildLevelWithFilter(t *testing.T) {
{
queryCountry(filter: { name: { eq: "India" } }) {
name
ag : aggregate_states(filter: {xcode: {in: ["ka", "mh"]}}) {
ag : aggregatestates(filter: {xcode: {in: ["ka", "mh"]}}) {
count
}
}
Expand All @@ -2502,7 +2502,7 @@ func queryCountAndOtherFieldsAtChildLevel(t *testing.T) {
{
queryCountry(filter: { name: { eq: "India" } }) {
name
ag : aggregate_states {
ag : aggregatestates {
count
},
states {
Expand Down
2 changes: 1 addition & 1 deletion graphql/e2e/common/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const (
"description": ""
},
{
"name": "aggregate_posts",
"name": "aggregateposts",
"description": ""
}
],
Expand Down
112 changes: 36 additions & 76 deletions graphql/resolve/auth_query_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@
gqlquery: |
query {
queryUser {
aggregate_tickets(filter: { title: { anyofterms: "graphql" } }) {
aggregatetickets(filter: { title: { anyofterms: "graphql" } }) {
count
}
}
Expand All @@ -1155,7 +1155,7 @@
dgquery: |-
query {
queryUser(func: uid(UserRoot)) {
count_aggregate_tickets : count(User.tickets) @filter(uid(Ticket3))
count_aggregatetickets : count(User.tickets) @filter(uid(Ticket3))
dgraph.uid : uid
}
UserRoot as var(func: uid(User4))
Expand All @@ -1179,16 +1179,19 @@
}
}
- name: "Multiple Count queries at child level with Auth deep filter"
- name: "Multiple Count queries at child level and other queries with Auth deep filter"
gqlquery: |
query {
queryUser {
aggregate_tickets(filter: { title: { anyofterms: "graphql" } }) {
aggregatetickets(filter: { title: { anyofterms: "graphql" } }) {
count
}
aggregate_issues {
aggregateissues {
count
}
tickets(filter: { title: { anyofterms: "graphql2" } }) {
title
}
}
}
jwtvar:
Expand All @@ -1197,12 +1200,16 @@
dgquery: |-
query {
queryUser(func: uid(UserRoot)) {
count_aggregate_tickets : count(User.tickets) @filter(uid(Ticket3))
count_aggregate_issues : count(User.issues) @filter(uid(Issue6))
count_aggregatetickets : count(User.tickets) @filter(uid(Ticket3))
count_aggregateissues : count(User.issues) @filter(uid(Issue6))
tickets : User.tickets @filter(uid(Ticket9)) {
title : Ticket.title
dgraph.uid : uid
}
dgraph.uid : uid
}
UserRoot as var(func: uid(User7))
User7 as var(func: type(User))
UserRoot as var(func: uid(User10))
User10 as var(func: type(User))
var(func: uid(UserRoot)) {
TicketAggregateResult1 as User.tickets
}
Expand All @@ -1228,13 +1235,30 @@
owner : Issue.owner @filter(eq(User.username, "user1"))
dgraph.uid : uid
}
var(func: uid(UserRoot)) {
Ticket7 as User.tickets
}
Ticket9 as var(func: uid(Ticket7)) @filter((anyofterms(Ticket.title, "graphql2") AND uid(TicketAuth8)))
TicketAuth8 as var(func: uid(Ticket7)) @cascade {
onColumn : Ticket.onColumn {
inProject : Column.inProject {
roles : Project.roles @filter(eq(Role.permission, "VIEW")) {
assignedTo : Role.assignedTo @filter(eq(User.username, "user1"))
dgraph.uid : uid
}
dgraph.uid : uid
}
dgraph.uid : uid
}
dgraph.uid : uid
}
}
- name: "count at child with RBAC rules true"
gqlquery: |
query {
queryUser {
aggregate_issues {
aggregateissues {
count
}
}
Expand All @@ -1245,7 +1269,7 @@
dgquery: |-
query {
queryUser(func: uid(UserRoot)) {
count_aggregate_issues : count(User.issues) @filter(uid(Issue3))
count_aggregateissues : count(User.issues) @filter(uid(Issue3))
dgraph.uid : uid
}
UserRoot as var(func: uid(User4))
Expand All @@ -1265,7 +1289,7 @@
query {
queryUser {
username
aggregate_issues {
aggregateissues {
count
}
}
Expand All @@ -1282,67 +1306,3 @@
UserRoot as var(func: uid(User1))
User1 as var(func: type(User))
}
- name: "Count at child and other child level fields with Auth deep filter and field filter"
gqlquery: |
query {
queryUser {
username
aggregate_tickets(filter: { title: { anyofterms: "graphql" } }) {
count
}
tickets(filter: { title: { anyofterms: "graphql2" } }) {
title
}
}
}
jwtvar:
USER: "user1"
dgquery: |-
query {
queryUser(func: uid(UserRoot)) {
username : User.username
count_aggregate_tickets : count(User.tickets) @filter(uid(Ticket3))
tickets : User.tickets @filter(uid(Ticket6)) {
title : Ticket.title
dgraph.uid : uid
}
dgraph.uid : uid
}
UserRoot as var(func: uid(User7))
User7 as var(func: type(User))
var(func: uid(UserRoot)) {
TicketAggregateResult1 as User.tickets
}
Ticket3 as var(func: uid(TicketAggregateResult1)) @filter((anyofterms(Ticket.title, "graphql") AND uid(TicketAuth2)))
TicketAuth2 as var(func: uid(TicketAggregateResult1)) @cascade {
onColumn : Ticket.onColumn {
inProject : Column.inProject {
roles : Project.roles @filter(eq(Role.permission, "VIEW")) {
assignedTo : Role.assignedTo @filter(eq(User.username, "user1"))
dgraph.uid : uid
}
dgraph.uid : uid
}
dgraph.uid : uid
}
dgraph.uid : uid
}
var(func: uid(UserRoot)) {
Ticket4 as User.tickets
}
Ticket6 as var(func: uid(Ticket4)) @filter((anyofterms(Ticket.title, "graphql2") AND uid(TicketAuth5)))
TicketAuth5 as var(func: uid(Ticket4)) @cascade {
onColumn : Ticket.onColumn {
inProject : Column.inProject {
roles : Project.roles @filter(eq(Role.permission, "VIEW")) {
assignedTo : Role.assignedTo @filter(eq(User.username, "user1"))
dgraph.uid : uid
}
dgraph.uid : uid
}
dgraph.uid : uid
}
dgraph.uid : uid
}
}
Loading

0 comments on commit c636184

Please sign in to comment.