Class ExecutionStepInfo
- java.lang.Object
-
- graphql.execution.ExecutionStepInfo
-
@PublicApi public class ExecutionStepInfo extends java.lang.Object
As the graphql query executes, it forms a hierarchy from parent fields (and their type) to their child fields (and their type) until a scalar type is encountered; this class captures that execution type information.The static graphql type system (rightly) does not contain a hierarchy of child to parent types nor the nonnull ness of type instances, so this helper class adds this information during query execution.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExecutionStepInfo.Builder
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Supplier<ImmutableMapWithNullValues<java.lang.String,java.lang.Object>>argumentsprivate MergedFieldfieldfield, fieldDefinition, fieldContainer and arguments differ per field StepInfo.private GraphQLObjectTypefieldContainerprivate GraphQLFieldDefinitionfieldDefinitionprivate ExecutionStepInfoparentprivate ResultPathpathA list element is characterized by having a path ending with an index segment.private GraphQLOutputTypetypeIf this StepInfo represent a field the type is equal to fieldDefinition.getType()
-
Constructor Summary
Constructors Modifier Constructor Description privateExecutionStepInfo(ExecutionStepInfo.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ExecutionStepInfochangeTypeWithPreservedNonNull(GraphQLOutputType newType)This allows you to morph a type into a more specialized form yet return the same parent and non-null ness, for example taking aGraphQLInterfaceTypeand turning it into a specificGraphQLObjectTypeafter type resolution has occurred<T> TgetArgument(java.lang.String name)Returns the named argumentjava.util.Map<java.lang.String,java.lang.Object>getArguments()MergedFieldgetField()This returns the AST fields that matches thegetFieldDefinition()during executionGraphQLObjectTypegetFieldContainer()Deprecated.usegetObjectType()instead as it is named betterGraphQLFieldDefinitiongetFieldDefinition()This returns the field definition that is in play when this type info was created or null if the type is a root query typeGraphQLObjectTypegetObjectType()The GraphQLObjectType where fieldDefinition is defined.ExecutionStepInfogetParent()ResultPathgetPath()java.lang.StringgetResultKey()GraphQLOutputTypegetType()This returns the type for the current step.GraphQLOutputTypegetUnwrappedNonNullType()This returns the type which is unwrapped if it wasGraphQLNonNullwrappedbooleanhasParent()booleanisListType()booleanisNonNullType()static ExecutionStepInfo.BuildernewExecutionStepInfo()static ExecutionStepInfo.BuildernewExecutionStepInfo(ExecutionStepInfo existing)java.lang.StringsimplePrint()java.lang.StringtoString()ExecutionStepInfotransform(java.util.function.Consumer<ExecutionStepInfo.Builder> builderConsumer)
-
-
-
Field Detail
-
type
private final GraphQLOutputType type
If this StepInfo represent a field the type is equal to fieldDefinition.getType()if this StepInfo is a list element this type is the actual current list element. For example: Query.pets: [[Pet]] with Pet either a Dog or Cat and the actual result is [[Dog1],[[Cat1]] Then the type is (for a query "{pets{name}}"): [[Pet]] for /pets (representing the field Query.pets, not a list element) [Pet] fot /pets[0] [Pet] for /pets[1] Dog for /pets[0][0] Cat for /pets[1][0] String for /pets[0][0]/name (representing the field Dog.name, not a list element) String for /pets[1][0]/name (representing the field Cat.name, not a list element)
-
path
private final ResultPath path
A list element is characterized by having a path ending with an index segment. (ResultPath.isListSegment())
-
parent
private final ExecutionStepInfo parent
-
field
private final MergedField field
field, fieldDefinition, fieldContainer and arguments differ per field StepInfo.But for list StepInfos these properties are the same as the field returning the list.
-
fieldDefinition
private final GraphQLFieldDefinition fieldDefinition
-
fieldContainer
private final GraphQLObjectType fieldContainer
-
arguments
private final java.util.function.Supplier<ImmutableMapWithNullValues<java.lang.String,java.lang.Object>> arguments
-
-
Constructor Detail
-
ExecutionStepInfo
private ExecutionStepInfo(ExecutionStepInfo.Builder builder)
-
-
Method Detail
-
getFieldContainer
@Deprecated public GraphQLObjectType getFieldContainer()
Deprecated.usegetObjectType()instead as it is named better- Returns:
- the GraphQLObjectType defining the
getFieldDefinition() - See Also:
getObjectType()
-
getObjectType
public GraphQLObjectType getObjectType()
The GraphQLObjectType where fieldDefinition is defined. Note: For the Introspection field __typename the returned object type doesn't actually contain the fieldDefinition.- Returns:
- the GraphQLObjectType defining the
getFieldDefinition()
-
getType
public GraphQLOutputType getType()
This returns the type for the current step.- Returns:
- the graphql type in question
-
getUnwrappedNonNullType
public GraphQLOutputType getUnwrappedNonNullType()
This returns the type which is unwrapped if it wasGraphQLNonNullwrapped- Returns:
- the graphql type in question
-
getFieldDefinition
public GraphQLFieldDefinition getFieldDefinition()
This returns the field definition that is in play when this type info was created or null if the type is a root query type- Returns:
- the field definition or null if there is not one
-
getField
public MergedField getField()
This returns the AST fields that matches thegetFieldDefinition()during execution- Returns:
- the merged fields
-
getPath
public ResultPath getPath()
- Returns:
- the
ResultPathto this info
-
isNonNullType
public boolean isNonNullType()
- Returns:
- true if the type must be nonnull
-
isListType
public boolean isListType()
- Returns:
- true if the type is a list
-
getArguments
public java.util.Map<java.lang.String,java.lang.Object> getArguments()
- Returns:
- the resolved arguments that have been passed to this field
-
getArgument
public <T> T getArgument(java.lang.String name)
Returns the named argument- Type Parameters:
T- you decide what type it is- Parameters:
name- the name of the argument- Returns:
- the named argument or null if it's not present
-
getParent
public ExecutionStepInfo getParent()
- Returns:
- the parent type information
-
hasParent
public boolean hasParent()
- Returns:
- true if the type has a parent (most do)
-
changeTypeWithPreservedNonNull
public ExecutionStepInfo changeTypeWithPreservedNonNull(GraphQLOutputType newType)
This allows you to morph a type into a more specialized form yet return the same parent and non-null ness, for example taking aGraphQLInterfaceTypeand turning it into a specificGraphQLObjectTypeafter type resolution has occurred- Parameters:
newType- the new type to be- Returns:
- a new type info with the same
-
simplePrint
public java.lang.String simplePrint()
- Returns:
- the type in graphql SDL format, eg [typeName!]!
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
transform
public ExecutionStepInfo transform(java.util.function.Consumer<ExecutionStepInfo.Builder> builderConsumer)
-
getResultKey
public java.lang.String getResultKey()
-
newExecutionStepInfo
public static ExecutionStepInfo.Builder newExecutionStepInfo()
- Returns:
- a builder of type info
-
newExecutionStepInfo
public static ExecutionStepInfo.Builder newExecutionStepInfo(ExecutionStepInfo existing)
-
-