Skip to content

Commit

Permalink
Update tests for dql_query param
Browse files Browse the repository at this point in the history
# Conflicts:
#	graphql/e2e/normal/docker-compose.yml
  • Loading branch information
matthewmcneely committed Jan 17, 2025
1 parent 16af8e2 commit d82fe2e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions graphql/e2e/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ func RunAll(t *testing.T) {
t.Run("multiple operations", multipleOperations)
t.Run("query post with author", queryPostWithAuthor)
t.Run("queries have extensions", queriesHaveExtensions)
t.Run("queries with debug flag have dql query in extensions", queriesWithDebugFlagHaveDQLQueryInExtensions)
t.Run("queries have touched_uids even if there are GraphQL errors", erroredQueriesHaveTouchedUids)
t.Run("alias works for queries", queryWithAlias)
t.Run("multiple aliases for same field in query", queryWithMultipleAliasOfSameField)
Expand Down
16 changes: 16 additions & 0 deletions graphql/e2e/common/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,22 @@ func queriesHaveExtensions(t *testing.T) {
require.Greater(t, int(gqlResponse.Extensions[touchedUidskey].(float64)), 0)
}

func queriesWithDebugFlagHaveDQLQueryInExtensions(t *testing.T) {
query := &GraphQLParams{
Query: `query {
queryPost {
title
}
}`,
}

gqlResponse := query.ExecuteAsPost(t, GraphqlURL+"?debug=true")
RequireNoGQLErrors(t, gqlResponse)
require.Contains(t, gqlResponse.Extensions, "dql_query")
require.NotEmpty(t, gqlResponse.Extensions["dql_query"])
require.Equal(t, "query {\n queryPost(func: type(Post)) {\n Post.title : Post.title\n dgraph.uid : uid\n }\n}", gqlResponse.Extensions["dql_query"])
}

func erroredQueriesHaveTouchedUids(t *testing.T) {
country1 := addCountry(t, postExecutor)
country2 := addCountry(t, postExecutor)
Expand Down
2 changes: 1 addition & 1 deletion graphql/e2e/normal/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
/gobin/dgraph ${COVERAGE_OUTPUT} alpha --telemetry "reports=false; sentry=false;"
--zero=zero1:5080 --expose_trace --profile_mode block --block_rate 10 --logtostderr -v=2
--my=alpha1:7080 --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;" --graphql
"lambda-url=http://lambda:8686/graphql-worker;" --trace "ratio=1.0;"
"lambda-url=http://lambda:8686/graphql-worker; debug=true;" --trace "ratio=1.0;"

lambda:
image: dgraph/dgraph-lambda:latest
Expand Down

0 comments on commit d82fe2e

Please sign in to comment.