Skip to content

Commit

Permalink
Add dql_query to extensions when GraphQL debug super flag is true
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmcneely committed Jan 17, 2025
1 parent 053a440 commit 16af8e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions graphql/resolve/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ func (qr *queryResolver) rewriteAndExecute(ctx context.Context, query schema.Que
}

ext.TouchedUids = resp.GetMetrics().GetNumUids()[touchedUidsKey]
if x.Config.GraphQL.GetBool("debug") {
ext.DQLQuery = qry
}
resolved := &Resolved{
Data: resp.GetJson(),
Field: query,
Expand Down
7 changes: 7 additions & 0 deletions graphql/schema/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func (r *Response) Output() interface{} {
type Extensions struct {
TouchedUids uint64 `json:"touched_uids,omitempty"`
Tracing *Trace `json:"tracing,omitempty"`
DQLQuery string `json:"dql_query,omitempty"`
}

// GetTouchedUids returns TouchedUids
Expand All @@ -205,6 +206,12 @@ func (e *Extensions) Merge(ext *Extensions) {
} else {
e.Tracing.Merge(ext.Tracing)
}

if e.DQLQuery == "" {
e.DQLQuery = ext.DQLQuery
} else {
e.DQLQuery = e.DQLQuery + "\n" + ext.DQLQuery
}
}

// Trace : Apollo Tracing is a GraphQL extension for tracing resolver performance.Response
Expand Down

0 comments on commit 16af8e2

Please sign in to comment.