graphql.schema.DataFetchingEnvironmentImpl Maven / Gradle / Ivy
The newest version!
package graphql.schema;
import graphql.execution.ExecutionContext;
import graphql.execution.ExecutionId;
import graphql.language.Field;
import graphql.language.FragmentDefinition;
import java.util.List;
import java.util.Map;
@SuppressWarnings("unchecked")
public class DataFetchingEnvironmentImpl implements DataFetchingEnvironment {
private final Object source;
private final Map arguments;
private final Object context;
private final List fields;
private final GraphQLOutputType fieldType;
private final GraphQLType parentType;
private final GraphQLSchema graphQLSchema;
private Map fragmentsByName;
private ExecutionId executionId;
public DataFetchingEnvironmentImpl(Object source, Map arguments, List fields, GraphQLOutputType fieldType, GraphQLType parentType, ExecutionContext executionContext) {
this(source, arguments, executionContext.getRoot(), fields, fieldType, parentType, executionContext.getGraphQLSchema(), executionContext.getFragmentsByName(), executionContext.getExecutionId());
}
public DataFetchingEnvironmentImpl(Object source, Map arguments, Object context, List fields, GraphQLOutputType fieldType, GraphQLType parentType, GraphQLSchema graphQLSchema, Map fragmentsByName, ExecutionId executionId) {
this.source = source;
this.arguments = arguments;
this.context = context;
this.fields = fields;
this.fieldType = fieldType;
this.parentType = parentType;
this.graphQLSchema = graphQLSchema;
this.fragmentsByName = fragmentsByName;
this.executionId = executionId;
}
@Override
public T getSource() {
return (T) source;
}
@Override
public Map getArguments() {
return arguments;
}
@Override
public boolean containsArgument(String name) {
return arguments.containsKey(name);
}
@Override
public T getArgument(String name) {
return (T) arguments.get(name);
}
@Override
public T getContext() {
return (T) context;
}
@Override
public List getFields() {
return fields;
}
@Override
public GraphQLOutputType getFieldType() {
return fieldType;
}
@Override
public GraphQLType getParentType() {
return parentType;
}
@Override
public GraphQLSchema getGraphQLSchema() {
return graphQLSchema;
}
@Override
public Map getFragmentsByName() {
return fragmentsByName;
}
@Override
public ExecutionId getExecutionId() {
return executionId;
}
}