@PublicApi public interface DataFetchingEnvironment
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
|
java.util.Map<java.lang.String,java.lang.Object> |
getArguments() |
CacheControl |
getCacheControl() |
<T> T |
getContext()
Returns a context argument that is set up when the
GraphQL.execute(java.lang.String) method
is invoked. |
<K,V> org.dataloader.DataLoader<K,V> |
getDataLoader(java.lang.String dataLoaderName)
This allows you to retrieve a named dataloader from the underlying
DataLoaderRegistry |
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() |
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() |
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()
T
- you decide what type it isjava.util.Map<java.lang.String,java.lang.Object> getArguments()
boolean containsArgument(java.lang.String name)
name
- the name of the argument<T> T getArgument(java.lang.String name)
T
- you decide what type it isname
- the name of the argument<T> T getContext()
GraphQL.execute(java.lang.String)
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 is<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 its 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 the global 'context'
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()
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()
GraphQLSchema getGraphQLSchema()
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 fetchExecutionContext.getDataLoaderRegistry()
,
DataLoaderRegistry.getDataLoader(String)
CacheControl getCacheControl()
CacheControl
instance used to add cache hints to the responseOperationDefinition 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