class GraphQL::Analysis::QueryDepth

A query reducer for measuring the depth of a given query.

See graphql-ruby.org/queries/ast_analysis.html for more examples.

Examples

Example: Logging the depth of a query

class LogQueryDepth < GraphQL::Analysis::QueryDepth
  def result
    log("GraphQL query depth: #{@max_depth}")
  end
end

# In your Schema file:

class MySchema < GraphQL::Schema
  query_analyzer LogQueryDepth
end

# When you run the query, the depth will get logged:

Schema.execute(query_str)
# GraphQL query depth: 8