Skip to content

Implement Query#sanitized_query_string#1106

Description

@rmosolgo

We want to improve logging, but don't leak private info into the logs. So, let's take a page out of Shopify's book (again 馃槉 ) and add a custom printer API.

Let's add a couple of steps:

  • Implement class GraphQL::Language::Printer which has print_* methods corresponding to each node type; this is the base class for custom printers.
  • Extend GraphQL::Language::Nodes::AbstractNode#to_query_string(printer: GraphQL::Language::Printer)
  • Add Schema#sanitizing_printer_class; accept options via sanitize(whitelist:, blacklist:, ... ?)
  • Add Query#sanitized_query_string which prints the document with the sanitization settings.

(I'm not sure I've got the right split of which methods go where; I'm open to reshuffling that, for sure. But I think it'd be nice to support an injected printer and a base implementation for printers.)

TODO: What does it look like to integrate this with Rails' parameter filtering?

If the approach works, maybe we can do something similar for #791

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions