Package graphql.normalized
Class ExecutableNormalizedField
- java.lang.Object
-
- graphql.normalized.ExecutableNormalizedField
-
public class ExecutableNormalizedField extends java.lang.Object
Intentionally Mutable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExecutableNormalizedField.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(ExecutableNormalizedField executableNormalizedField)
void
addObjectTypeNames(java.util.Collection<java.lang.String> objectTypeNames)
void
clearChildren()
java.lang.String
getAlias()
com.google.common.collect.ImmutableList<Argument>
getAstArguments()
java.util.List<ExecutableNormalizedField>
getChildren()
java.util.List<ExecutableNormalizedField>
getChildren(int includingRelativeLevel)
java.util.List<ExecutableNormalizedField>
getChildren(java.lang.String objectTypeName)
This returns the child fields that can be used if the object is of the specified object typejava.util.List<ExecutableNormalizedField>
getChildrenWithSameResultKey(java.lang.String resultKey)
java.util.List<GraphQLFieldDefinition>
getFieldDefinitions(GraphQLSchema schema)
java.lang.String
getFieldName()
int
getLevel()
java.util.List<java.lang.String>
getListOfResultKeys()
java.lang.String
getName()
All merged fields have the same name.NormalizedInputValue
getNormalizedArgument(java.lang.String name)
com.google.common.collect.ImmutableMap<java.lang.String,NormalizedInputValue>
getNormalizedArguments()
java.util.Set<java.lang.String>
getObjectTypeNames()
ExecutableNormalizedField
getParent()
java.util.LinkedHashMap<java.lang.String,java.lang.Object>
getResolvedArguments()
java.lang.String
getResultKey()
Returns the key of this MergedFieldWithType for the overall result.java.lang.String
getSingleObjectTypeName()
GraphQLOutputType
getType(GraphQLSchema schema)
java.util.List<GraphQLOutputType>
getTypes(GraphQLSchema schema)
boolean
hasChildren()
boolean
isConditional(@NotNull GraphQLSchema schema)
Determines whether this NF needs a fragment to select the field.static ExecutableNormalizedField.Builder
newNormalizedField()
java.lang.String
objectTypeNamesToString()
java.lang.String
printDetails()
void
replaceParent(ExecutableNormalizedField newParent)
void
setObjectTypeNames(java.util.Collection<java.lang.String> objectTypeNames)
java.lang.String
toString()
ExecutableNormalizedField
transform(java.util.function.Consumer<ExecutableNormalizedField.Builder> builderConsumer)
void
traverseSubTree(java.util.function.Consumer<ExecutableNormalizedField> consumer)
-
-
-
Method Detail
-
isConditional
public boolean isConditional(@NotNull @NotNull GraphQLSchema schema)
Determines whether this NF needs a fragment to select the field. However, it considers the parent output type when determining whether it needs a fragment.Consider the following schema
interface Animal { name: String parent: Animal } type Cat implements Animal { name: String parent: Cat } type Dog implements Animal { name: String parent: Dog isGoodBoy: Boolean } type Query { animal: Animal }
and the following query
{ animal { parent { name } } }
Then we would get the following normalized operation tree
-Query.animal: Animal --[Cat, Dog].parent: Cat, Dog ---[Cat, Dog].name: String
If we simply checked the
parent
'sgetFieldDefinitions(GraphQLSchema)
that would point us toCat.parent
andDog.parent
whose output types would incorrectly answer our question whether this is conditional?We MUST consider that the output type of the
parent
field isAnimal
and NOTCat
orDog
as their respective impls would say.- Parameters:
schema
- - the graphql schema in play- Returns:
- true if the field is conditional
-
hasChildren
public boolean hasChildren()
-
getType
public GraphQLOutputType getType(GraphQLSchema schema)
-
getTypes
public java.util.List<GraphQLOutputType> getTypes(GraphQLSchema schema)
-
getFieldDefinitions
public java.util.List<GraphQLFieldDefinition> getFieldDefinitions(GraphQLSchema schema)
-
addObjectTypeNames
public void addObjectTypeNames(java.util.Collection<java.lang.String> objectTypeNames)
-
setObjectTypeNames
public void setObjectTypeNames(java.util.Collection<java.lang.String> objectTypeNames)
-
addChild
public void addChild(ExecutableNormalizedField executableNormalizedField)
-
clearChildren
public void clearChildren()
-
getName
public java.lang.String getName()
All merged fields have the same name.WARNING: This is not always the key in the execution result, because of possible aliases. See
getResultKey()
- Returns:
- the name of of the merged fields.
-
getResultKey
public java.lang.String getResultKey()
Returns the key of this MergedFieldWithType for the overall result. This is either an alias or the FieldWTC name.- Returns:
- the key for this MergedFieldWithType.
-
getAlias
public java.lang.String getAlias()
-
getAstArguments
public com.google.common.collect.ImmutableList<Argument> getAstArguments()
-
getNormalizedArgument
public NormalizedInputValue getNormalizedArgument(java.lang.String name)
-
getNormalizedArguments
public com.google.common.collect.ImmutableMap<java.lang.String,NormalizedInputValue> getNormalizedArguments()
-
getResolvedArguments
public java.util.LinkedHashMap<java.lang.String,java.lang.Object> getResolvedArguments()
-
newNormalizedField
public static ExecutableNormalizedField.Builder newNormalizedField()
-
getFieldName
public java.lang.String getFieldName()
-
transform
public ExecutableNormalizedField transform(java.util.function.Consumer<ExecutableNormalizedField.Builder> builderConsumer)
-
getObjectTypeNames
public java.util.Set<java.lang.String> getObjectTypeNames()
- Returns:
- Warning: returns a Mutable Set. No defensive copy is made for performance reasons.
-
getSingleObjectTypeName
public java.lang.String getSingleObjectTypeName()
-
printDetails
public java.lang.String printDetails()
-
objectTypeNamesToString
public java.lang.String objectTypeNamesToString()
-
getListOfResultKeys
public java.util.List<java.lang.String> getListOfResultKeys()
-
getChildren
public java.util.List<ExecutableNormalizedField> getChildren()
-
getChildrenWithSameResultKey
public java.util.List<ExecutableNormalizedField> getChildrenWithSameResultKey(java.lang.String resultKey)
-
getChildren
public java.util.List<ExecutableNormalizedField> getChildren(int includingRelativeLevel)
-
getChildren
public java.util.List<ExecutableNormalizedField> getChildren(java.lang.String objectTypeName)
This returns the child fields that can be used if the object is of the specified object type- Parameters:
objectTypeName
- the object type- Returns:
- a list of child fields that would apply to that object type
-
getLevel
public int getLevel()
-
getParent
public ExecutableNormalizedField getParent()
-
replaceParent
public void replaceParent(ExecutableNormalizedField newParent)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
traverseSubTree
public void traverseSubTree(java.util.function.Consumer<ExecutableNormalizedField> consumer)
-
-