class GraphQL::Language::SanitizedPrinter

A custom printer used to print sanitized queries. It inlines provided variables within the query for facilitate logging and analysis of queries.

The printer returns nil if the query is invalid.

Since the GraphQL Ruby AST for a GraphQL query doesnt contain any reference on the type of fields or arguments, we have to track the current object, field and input type while printing the query.

See Query#sanitized_query_string

Examples

Example: Printing a scrubbed string

printer = QueryPrinter.new(query)
puts printer.sanitized_query_string