Package graphql.language
Class AstSignature
- java.lang.Object
-
- graphql.language.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 Summary
Constructors Constructor Description AstSignature()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Document
dropUnusedQueryDefinitions(Document document, java.lang.String operationName)
private Document
hideLiterals(boolean signatureMode, Document document)
private boolean
isThisOperation(OperationDefinition operationDefinition, java.lang.String operationName)
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.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)
private Document
removeAliases(Document document)
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.private Document
sortAST(Document document)
private Document
transformDoc(Document document, NodeVisitorStub visitor)
-
-
-
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 fromoperationName
- 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 fromsignatureQuery(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 fromoperationName
- 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
-
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)
-
transformDoc
private Document transformDoc(Document document, NodeVisitorStub visitor)
-
-