Class AstSignature


  • @PublicApi
    public class AstSignature
    extends java.lang.Object
    This will produce signature and privacy safe query documents that can be used for query categorisation and logging.
    • Constructor Detail

      • AstSignature

        public AstSignature()
    • Method Detail

      • signatureQuery

        public Document signatureQuery​(Document document,
                                       java.lang.String operationName)
        This can produce a "signature" canonical AST that conforms to the algorithm as outlined here which removes excess operations, removes any field aliases, hides literal values and sorts the result into a canonical query. A signature says two queries with the same signature can be thought of as the same query. For example a tracing system will want a canonical signature for queries to group them.
        Parameters:
        document - the document to make a signature query from
        operationName - the name of the operation to do it for (since only one query can be run at a time)
        Returns:
        the signature query in document form
      • privacySafeQuery

        public Document privacySafeQuery​(Document document,
                                         java.lang.String operationName)
        This can produce a "privacy safe" AST that some what conforms to the algorithm as outlined here which removes excess operations, removes any field aliases, hides some literal values and sorts the result. This is not a signature. For example object literal structures are retained like `{ a : "", b : 0}` which means you can infer what was asked for but not what the values are. This differs from signatureQuery(Document, String) which collapses literals to create more canonical signatures. A privacy safe Query is useful for logging say to show what shapes was asked for without revealing what data was provided
        Parameters:
        document - the document to make a privacy safe query from
        operationName - the name of the operation to do it for (since only one query can be run at a time)
        Returns:
        the privacy safe query in document form
      • hideLiterals

        private Document hideLiterals​(boolean signatureMode,
                                      Document document)
      • remapVariable

        private java.lang.String remapVariable​(java.lang.String varName,
                                               java.util.Map<java.lang.String,​java.lang.String> variableRemapping,
                                               java.util.concurrent.atomic.AtomicInteger variableCount)
      • dropUnusedQueryDefinitions

        private Document dropUnusedQueryDefinitions​(Document document,
                                                    java.lang.String operationName)
      • isThisOperation

        private boolean isThisOperation​(OperationDefinition operationDefinition,
                                        java.lang.String operationName)