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 legacy 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() |
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 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.Builderpublic 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 IntrospectionDataFetchingEnvironmentgetSource in interface DataFetchingEnvironmentT - you decide what type it ispublic java.util.Map<java.lang.String,java.lang.Object> getArguments()
getArguments in interface IntrospectionDataFetchingEnvironmentgetArguments in interface DataFetchingEnvironmentpublic boolean containsArgument(java.lang.String name)
DataFetchingEnvironmentcontainsArgument in interface DataFetchingEnvironmentname - the name of the argumentpublic <T> T getArgument(java.lang.String name)
DataFetchingEnvironmentgetArgument in interface IntrospectionDataFetchingEnvironmentgetArgument in interface DataFetchingEnvironmentT - you decide what type it isname - the name of the argumentpublic <T> T getArgumentOrDefault(java.lang.String name,
T defaultValue)
DataFetchingEnvironmentgetArgumentOrDefault in interface DataFetchingEnvironmentT - you decide what type it isname - the name of the argumentdefaultValue - the default value if the argument is not presentpublic <T> T getContext()
DataFetchingEnvironmentGraphQL.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 DataFetchingEnvironmentT - you decide what type it ispublic GraphQLContext getGraphQlContext()
DataFetchingEnvironmentGraphQL.execute(graphql.ExecutionInput) )} method
is invoked.
This is a info object which is provided to all DataFetchers.
getGraphQlContext in interface DataFetchingEnvironmentpublic <T> T getLocalContext()
DataFetchingEnvironmentDataFetcherResult.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 DataFetchingEnvironmentT - you decide what type it ispublic <T> T getRoot()
DataFetchingEnvironmentgetRoot in interface DataFetchingEnvironmentT - you decide what type it ispublic GraphQLFieldDefinition getFieldDefinition()
getFieldDefinition in interface DataFetchingEnvironmentpublic java.util.List<Field> getFields()
getFields in interface DataFetchingEnvironmentpublic Field getField()
getField in interface DataFetchingEnvironmentDataFetchingEnvironment.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 DataFetchingEnvironmentpublic GraphQLOutputType getFieldType()
getFieldType in interface DataFetchingEnvironmentpublic GraphQLType getParentType()
getParentType in interface IntrospectionDataFetchingEnvironmentgetParentType in interface DataFetchingEnvironmentpublic GraphQLSchema getGraphQLSchema()
getGraphQLSchema in interface IntrospectionDataFetchingEnvironmentgetGraphQLSchema in interface DataFetchingEnvironmentpublic java.util.Map<java.lang.String,FragmentDefinition> getFragmentsByName()
getFragmentsByName in interface DataFetchingEnvironmentFragmentDefinition map for the current data fetch operationpublic ExecutionId getExecutionId()
getExecutionId in interface DataFetchingEnvironmentExecutionId for the current data fetch operationpublic DataFetchingFieldSelectionSet getSelectionSet()
getSelectionSet in interface DataFetchingEnvironmentDataFetchingFieldSelectionSet for the current data fetch operationpublic QueryDirectives getQueryDirectives()
DataFetchingEnvironmentgetQueryDirectives in interface DataFetchingEnvironmentQueryDirectives for the currently executing fieldfor more informationpublic ExecutionStepInfo getExecutionStepInfo()
getExecutionStepInfo in interface DataFetchingEnvironmentExecutionStepInfo for the current data fetch operationpublic <K,V> org.dataloader.DataLoader<K,V> getDataLoader(java.lang.String dataLoaderName)
DataFetchingEnvironmentDataLoaderRegistrygetDataLoader in interface DataFetchingEnvironmentK - the key typeV - the value typedataLoaderName - the name of the data loader to fetchDataLoaderRegistry.getDataLoader(String)public org.dataloader.DataLoaderRegistry getDataLoaderRegistry()
getDataLoaderRegistry in interface DataFetchingEnvironmentDataLoaderRegistry in playpublic CacheControl getCacheControl()
getCacheControl in interface DataFetchingEnvironmentCacheControl instance used to add cache hints to the responsepublic java.util.Locale getLocale()
getLocale in interface DataFetchingEnvironmentLocale instance used for this requestpublic OperationDefinition getOperationDefinition()
getOperationDefinition in interface DataFetchingEnvironmentpublic Document getDocument()
getDocument in interface DataFetchingEnvironmentpublic java.util.Map<java.lang.String,java.lang.Object> getVariables()
DataFetchingEnvironmentDataFetchingEnvironment.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.
getVariables in interface DataFetchingEnvironmentpublic java.lang.String toString()
toString in class java.lang.Object