@PublicApi public interface DataFetchingEnvironment extends IntrospectionDataFetchingEnvironment
DataFetcher
as a execution context and its
the place where you can find out information to help you resolve a data value given a graphql field inputModifier and Type | Method and Description |
---|---|
boolean |
containsArgument(java.lang.String name)
Returns true of the named argument is present
|
<T> T |
getArgument(java.lang.String name)
Returns the named argument
|
<T> T |
getArgumentOrDefault(java.lang.String name,
T defaultValue)
Returns the named argument or the default value
|
java.util.Map<java.lang.String,java.lang.Object> |
getArguments() |
CacheControl |
getCacheControl()
Deprecated.
- Apollo has deprecated the Cache Control specification
|
<T> T |
getContext()
Deprecated.
- use
getGraphQlContext() instead |
<K,V> org.dataloader.DataLoader<K,V> |
getDataLoader(java.lang.String dataLoaderName)
This allows you to retrieve a named dataloader from the underlying
DataLoaderRegistry |
org.dataloader.DataLoaderRegistry |
getDataLoaderRegistry() |
Document |
getDocument() |
ExecutionId |
getExecutionId() |
ExecutionStepInfo |
getExecutionStepInfo() |
Field |
getField() |
GraphQLFieldDefinition |
getFieldDefinition() |
java.util.List<Field> |
getFields()
Deprecated.
Use
getMergedField() . |
GraphQLOutputType |
getFieldType() |
java.util.Map<java.lang.String,FragmentDefinition> |
getFragmentsByName() |
GraphQLContext |
getGraphQlContext()
Returns a shared context argument that is set up when the
GraphQL.execute(graphql.ExecutionInput) )} method
is invoked. |
GraphQLSchema |
getGraphQLSchema() |
<T> T |
getLocalContext()
This returns a context object that parent fields may have returned returned
via
DataFetcherResult.getLocalContext() which can be used to pass down extra information to
fields beyond the normal getSource() |
java.util.Locale |
getLocale() |
MergedField |
getMergedField()
It can happen that a query has overlapping fields which are
are querying the same data.
|
OperationDefinition |
getOperationDefinition() |
GraphQLType |
getParentType() |
QueryDirectives |
getQueryDirectives()
This gives you access to the directives related to this field
|
<T> T |
getRoot()
This is the source object for the root query.
|
DataFetchingFieldSelectionSet |
getSelectionSet() |
<T> T |
getSource()
This is the value of the current object to be queried.
|
java.util.Map<java.lang.String,java.lang.Object> |
getVariables()
This returns the variables that have been passed into the query.
|
<T> T getSource()
For the root query, it is equal to {getRoot()
getSource
in interface IntrospectionDataFetchingEnvironment
T
- you decide what type it isjava.util.Map<java.lang.String,java.lang.Object> getArguments()
getArguments
in interface IntrospectionDataFetchingEnvironment
boolean containsArgument(java.lang.String name)
name
- the name of the argument<T> T getArgument(java.lang.String name)
getArgument
in interface IntrospectionDataFetchingEnvironment
T
- you decide what type it isname
- the name of the argument<T> T getArgumentOrDefault(java.lang.String name, T defaultValue)
T
- you decide what type it isname
- the name of the argumentdefaultValue
- the default value if the argument is not present@Deprecated <T> T getContext()
getGraphQlContext()
insteadGraphQL.execute(graphql.ExecutionInput)
)} method
is invoked.
This is a info object which is provided to all DataFetchers, but never used by graphql-java itself.
T
- you decide what type it isGraphQLContext getGraphQlContext()
GraphQL.execute(graphql.ExecutionInput)
)} method
is invoked.
This is a info object which is provided to all DataFetchers.
<T> T getLocalContext()
DataFetcherResult.getLocalContext()
which can be used to pass down extra information to
fields beyond the normal getSource()
This differs from getContext()
in that it's field specific and passed from parent field to child field,
whilst getContext()
is global for the whole query.
If the field is a top level field then 'localContext' equals null since it's never be set until those fields execute.
T
- you decide what type it is<T> T getRoot()
T
- you decide what type it isGraphQLFieldDefinition getFieldDefinition()
@Deprecated java.util.List<Field> getFields()
getMergedField()
.MergedField getMergedField()
Most of the time you probably want to use getField()
.
Example query with more than one Field returned:
query Foo {
bar
...BarFragment
}
fragment BarFragment on Query {
bar
}
Field getField()
getMergedField()
.GraphQLOutputType getFieldType()
ExecutionStepInfo getExecutionStepInfo()
ExecutionStepInfo
for the current data fetch operationGraphQLType getParentType()
getParentType
in interface IntrospectionDataFetchingEnvironment
GraphQLSchema getGraphQLSchema()
getGraphQLSchema
in interface IntrospectionDataFetchingEnvironment
java.util.Map<java.lang.String,FragmentDefinition> getFragmentsByName()
FragmentDefinition
map for the current data fetch operationExecutionId getExecutionId()
ExecutionId
for the current data fetch operationDataFetchingFieldSelectionSet getSelectionSet()
DataFetchingFieldSelectionSet
for the current data fetch operationQueryDirectives getQueryDirectives()
QueryDirectives
for the currently executing fieldfor more information
<K,V> org.dataloader.DataLoader<K,V> getDataLoader(java.lang.String dataLoaderName)
DataLoaderRegistry
K
- the key typeV
- the value typedataLoaderName
- the name of the data loader to fetchDataLoaderRegistry.getDataLoader(String)
org.dataloader.DataLoaderRegistry getDataLoaderRegistry()
DataLoaderRegistry
in play@Deprecated CacheControl getCacheControl()
CacheControl
instance used to add cache hints to the responsejava.util.Locale getLocale()
Locale
instance used for this requestOperationDefinition getOperationDefinition()
Document getDocument()
java.util.Map<java.lang.String,java.lang.Object> getVariables()
getArguments()
The field arguments are created by interpolating any referenced variables and AST literals and resolving them into the arguments.
Also note that the raw query variables are "coerced" into a map where the leaf scalar and enum types are called to create
input coerced values. So the values you get here are not exactly as passed via ExecutionInput.getVariables()
but have been processed.