public class DataFetchingEnvironmentImpl extends java.lang.Object implements DataFetchingEnvironment
Modifier and Type | Class and Description |
---|---|
static class |
DataFetchingEnvironmentImpl.Builder |
Modifier 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() |
<T> T |
getContext()
Returns a context argument that is set up when the
GraphQL.execute(graphql.ExecutionInput) )} 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 |
org.dataloader.DataLoaderRegistry |
getDataLoaderRegistry() |
Document |
getDocument() |
ExecutionId |
getExecutionId() |
ExecutionStepInfo |
getExecutionStepInfo() |
Field |
getField() |
GraphQLFieldDefinition |
getFieldDefinition() |
java.util.List<Field> |
getFields() |
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 DataFetchingEnvironment.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.
|
static DataFetchingEnvironmentImpl.Builder |
newDataFetchingEnvironment() |
static DataFetchingEnvironmentImpl.Builder |
newDataFetchingEnvironment(DataFetchingEnvironment environment) |
static DataFetchingEnvironmentImpl.Builder |
newDataFetchingEnvironment(ExecutionContext executionContext) |
java.lang.String |
toString() |
public static DataFetchingEnvironmentImpl.Builder newDataFetchingEnvironment()
DataFetchingEnvironmentImpl.Builder
public static DataFetchingEnvironmentImpl.Builder newDataFetchingEnvironment(DataFetchingEnvironment environment)
public static DataFetchingEnvironmentImpl.Builder newDataFetchingEnvironment(ExecutionContext executionContext)
public <T> T getSource()
DataFetchingEnvironment
For the root query, it is equal to {DataFetchingEnvironment.getRoot()
getSource
in interface DataFetchingEnvironment
T
- you decide what type it ispublic java.util.Map<java.lang.String,java.lang.Object> getArguments()
getArguments
in interface DataFetchingEnvironment
public boolean containsArgument(java.lang.String name)
DataFetchingEnvironment
containsArgument
in interface DataFetchingEnvironment
name
- the name of the argumentpublic <T> T getArgument(java.lang.String name)
DataFetchingEnvironment
getArgument
in interface DataFetchingEnvironment
T
- you decide what type it isname
- the name of the argumentpublic <T> T getArgumentOrDefault(java.lang.String name, T defaultValue)
DataFetchingEnvironment
getArgumentOrDefault
in interface DataFetchingEnvironment
T
- you decide what type it isname
- the name of the argumentdefaultValue
- the default value if the argument is not presentpublic <T> T getContext()
DataFetchingEnvironment
GraphQL.execute(graphql.ExecutionInput)
)} method
is invoked.
This is a info object which is provided to all DataFetchers, but never used by graphql-java itself.
getContext
in interface DataFetchingEnvironment
T
- you decide what type it ispublic <T> T getLocalContext()
DataFetchingEnvironment
DataFetcherResult.getLocalContext()
which can be used to pass down extra information to
fields beyond the normal DataFetchingEnvironment.getSource()
This differs from DataFetchingEnvironment.getContext()
in that its field specific and passed from parent field to child field,
whilst DataFetchingEnvironment.getContext()
is global for the whole query.
If the field is a top level field then 'localContext' equals null since its never be set until those fields execute.
getLocalContext
in interface DataFetchingEnvironment
T
- you decide what type it ispublic <T> T getRoot()
DataFetchingEnvironment
getRoot
in interface DataFetchingEnvironment
T
- you decide what type it ispublic GraphQLFieldDefinition getFieldDefinition()
getFieldDefinition
in interface DataFetchingEnvironment
public java.util.List<Field> getFields()
getFields
in interface DataFetchingEnvironment
public Field getField()
getField
in interface DataFetchingEnvironment
DataFetchingEnvironment.getMergedField()
.public MergedField getMergedField()
DataFetchingEnvironment
Most of the time you probably want to use DataFetchingEnvironment.getField()
.
Example query with more than one Field returned:
query Foo {
bar
...BarFragment
}
fragment BarFragment on Query {
bar
}
getMergedField
in interface DataFetchingEnvironment
public GraphQLOutputType getFieldType()
getFieldType
in interface DataFetchingEnvironment
public GraphQLType getParentType()
getParentType
in interface DataFetchingEnvironment
public GraphQLSchema getGraphQLSchema()
getGraphQLSchema
in interface DataFetchingEnvironment
public java.util.Map<java.lang.String,FragmentDefinition> getFragmentsByName()
getFragmentsByName
in interface DataFetchingEnvironment
FragmentDefinition
map for the current data fetch operationpublic ExecutionId getExecutionId()
getExecutionId
in interface DataFetchingEnvironment
ExecutionId
for the current data fetch operationpublic DataFetchingFieldSelectionSet getSelectionSet()
getSelectionSet
in interface DataFetchingEnvironment
DataFetchingFieldSelectionSet
for the current data fetch operationpublic QueryDirectives getQueryDirectives()
DataFetchingEnvironment
getQueryDirectives
in interface DataFetchingEnvironment
QueryDirectives
for the currently executing fieldfor more information
public ExecutionStepInfo getExecutionStepInfo()
getExecutionStepInfo
in interface DataFetchingEnvironment
ExecutionStepInfo
for the current data fetch operationpublic <K,V> org.dataloader.DataLoader<K,V> getDataLoader(java.lang.String dataLoaderName)
DataFetchingEnvironment
DataLoaderRegistry
getDataLoader
in interface DataFetchingEnvironment
K
- the key typeV
- the value typedataLoaderName
- the name of the data loader to fetchDataLoaderRegistry.getDataLoader(String)
public org.dataloader.DataLoaderRegistry getDataLoaderRegistry()
getDataLoaderRegistry
in interface DataFetchingEnvironment
DataLoaderRegistry
in playpublic CacheControl getCacheControl()
getCacheControl
in interface DataFetchingEnvironment
CacheControl
instance used to add cache hints to the responsepublic java.util.Locale getLocale()
getLocale
in interface DataFetchingEnvironment
Locale
instance used for this requestpublic OperationDefinition getOperationDefinition()
getOperationDefinition
in interface DataFetchingEnvironment
public Document getDocument()
getDocument
in interface DataFetchingEnvironment
public java.util.Map<java.lang.String,java.lang.Object> getVariables()
DataFetchingEnvironment
DataFetchingEnvironment.getArguments()
The field arguments are created by interpolating any referenced variables and AST literals and resolving them into the arguments
getVariables
in interface DataFetchingEnvironment
public java.lang.String toString()
toString
in class java.lang.Object