Package graphql.normalized.nf
Class NormalizedOperation
- java.lang.Object
-
- graphql.normalized.nf.NormalizedOperation
-
@ExperimentalApi public class NormalizedOperation extends java.lang.Object
ANormalizedOperation
represent how the text of a graphql operation (sometimes known colloquially as a query) will be executed at runtime according to the graphql specification. It handles complex mechanisms like merging duplicate fields into one and also detecting when the types of a given field may actually be for more than one possible object type.An operation consists of a list of
NormalizedField
s in a parent child hierarchy
-
-
Constructor Summary
Constructors Constructor Description NormalizedOperation(OperationDefinition.Operation operation, java.lang.String operationName, java.util.List<NormalizedField> rootFields, com.google.common.collect.ImmutableListMultimap<Field,NormalizedField> fieldToNormalizedField, java.util.Map<NormalizedField,MergedField> normalizedFieldToMergedField, java.util.Map<NormalizedField,QueryDirectives> normalizedFieldToQueryDirectives, com.google.common.collect.ImmutableListMultimap<FieldCoordinates,NormalizedField> coordinatesToNormalizedFields, int operationFieldCount, int operationDepth)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.collect.ImmutableListMultimap<FieldCoordinates,NormalizedField>
getCoordinatesToNormalizedFields()
This multimap shows how a givenNormalizedField
maps to a one or more field coordinate in the schemacom.google.common.collect.ImmutableListMultimap<Field,NormalizedField>
getFieldToNormalizedField()
This is a multimap and the size of it reflects all the normalized fields in the operationMergedField
getMergedField(NormalizedField NormalizedField)
Looks up theMergedField
given aNormalizedField
NormalizedField
getNormalizedField(MergedField mergedField, GraphQLFieldsContainer fieldsContainer, ResultPath resultPath)
This will find aNormalizedField
given a merged field and a result path.java.util.List<NormalizedField>
getNormalizedFields(Field field)
Looks up one or moreNormalizedField
s given aField
AST element in the operationjava.util.Map<NormalizedField,MergedField>
getNormalizedFieldToMergedField()
java.util.Map<NormalizedField,QueryDirectives>
getNormalizedFieldToQueryDirectives()
OperationDefinition.Operation
getOperation()
int
getOperationDepth()
int
getOperationFieldCount()
java.lang.String
getOperationName()
QueryDirectives
getQueryDirectives(NormalizedField NormalizedField)
This looks up theQueryDirectives
associated with the givenNormalizedField
java.util.List<NormalizedField>
getRootFields()
-
-
-
Constructor Detail
-
NormalizedOperation
public NormalizedOperation(OperationDefinition.Operation operation, java.lang.String operationName, java.util.List<NormalizedField> rootFields, com.google.common.collect.ImmutableListMultimap<Field,NormalizedField> fieldToNormalizedField, java.util.Map<NormalizedField,MergedField> normalizedFieldToMergedField, java.util.Map<NormalizedField,QueryDirectives> normalizedFieldToQueryDirectives, com.google.common.collect.ImmutableListMultimap<FieldCoordinates,NormalizedField> coordinatesToNormalizedFields, int operationFieldCount, int operationDepth)
-
-
Method Detail
-
getOperation
public OperationDefinition.Operation getOperation()
- Returns:
- operation AST being executed
-
getOperationName
public java.lang.String getOperationName()
- Returns:
- the operation name, which can be null
-
getOperationFieldCount
public int getOperationFieldCount()
- Returns:
- This returns how many
NormalizedField
s are in the operation.
-
getOperationDepth
public int getOperationDepth()
- Returns:
- This returns the depth of the operation
-
getCoordinatesToNormalizedFields
public com.google.common.collect.ImmutableListMultimap<FieldCoordinates,NormalizedField> getCoordinatesToNormalizedFields()
This multimap shows how a givenNormalizedField
maps to a one or more field coordinate in the schema- Returns:
- a multimap of fields to schema field coordinates
-
getRootFields
public java.util.List<NormalizedField> getRootFields()
- Returns:
- a list of the top level
NormalizedField
s in this operation.
-
getFieldToNormalizedField
public com.google.common.collect.ImmutableListMultimap<Field,NormalizedField> getFieldToNormalizedField()
This is a multimap and the size of it reflects all the normalized fields in the operation- Returns:
- an immutable list multimap of
Field
toNormalizedField
-
getNormalizedFields
public java.util.List<NormalizedField> getNormalizedFields(Field field)
Looks up one or moreNormalizedField
s given aField
AST element in the operation- Parameters:
field
- the field to look up- Returns:
- zero, one or more possible
NormalizedField
s that represent that field
-
getNormalizedFieldToMergedField
public java.util.Map<NormalizedField,MergedField> getNormalizedFieldToMergedField()
- Returns:
- a map of
NormalizedField
toMergedField
s
-
getMergedField
public MergedField getMergedField(NormalizedField NormalizedField)
Looks up theMergedField
given aNormalizedField
- Parameters:
NormalizedField
- the field to use the key- Returns:
- a
MergedField
or null if its not present
-
getNormalizedFieldToQueryDirectives
public java.util.Map<NormalizedField,QueryDirectives> getNormalizedFieldToQueryDirectives()
- Returns:
- a map of
NormalizedField
to itsQueryDirectives
-
getQueryDirectives
public QueryDirectives getQueryDirectives(NormalizedField NormalizedField)
This looks up theQueryDirectives
associated with the givenNormalizedField
- Parameters:
NormalizedField
- the executable normalised field in question- Returns:
- the fields query directives or null
-
getNormalizedField
public NormalizedField getNormalizedField(MergedField mergedField, GraphQLFieldsContainer fieldsContainer, ResultPath resultPath)
This will find aNormalizedField
given a merged field and a result path. If this does not find a field it will assert with an exception- Parameters:
mergedField
- the merged fieldfieldsContainer
- the containing type of that fieldresultPath
- the result path in play- Returns:
- the NormalizedField
-
-