package graphql.schema;

import graphql.PublicApi;
import graphql.execution.ExecutionId;
import graphql.language.Field;
import graphql.language.FragmentDefinition;

import java.util.List;
import java.util.Map;

/**
 * A DataFetchingEnvironment instance of passed to a {@link DataFetcher} as an execution context parameter
 */
@PublicApi
public interface DataFetchingEnvironment {
    /**
     * @param <T> you decide what type it is
     * @return the current object being queried
     */
    <T> T getSource();

    /**
     * @return the arguments that have been passed in via the graphql query
     */
    Map<String, Object> getArguments();

    /**
     * Returns true of the named argument is present
     *
     * @param name the name of the argument
     * @return true of the named argument is present
     */
    boolean containsArgument(String name);

    /**
     * Returns the named argument
     *
     * @param name the name of the argument
     * @param <T>  you decide what type it is
     * @return the named argument or null if its not [present
     */
    <T> T getArgument(String name);

    /**
     * Returns a context argument that is set up when the {@link graphql.GraphQL#execute(String, Object)} method
     * is invoked
     *
     * @param <T> you decide what type it is
     * @return a context object
     */
    <T> T getContext();

    <T> T getRoot();

    /**
     * @return the list of fields currently in query context
     */
    List<Field> getFields();

    /**
     * @return graphql type of the current field
     */
    GraphQLOutputType getFieldType();

    /**
     * @return the type of the parent of the current field
     */
    GraphQLType getParentType();

    /**
     * @return the underlying graphql schema
     */
    GraphQLSchema getGraphQLSchema();

    /**
     * @return the {@link FragmentDefinition} map for the current operation
     */
    Map<String, FragmentDefinition> getFragmentsByName();

    /**
     * @return the {@link ExecutionId} for the current operation
     */
    ExecutionId getExecutionId();

    /**
     * @return the {@link DataFetchingFieldSelectionSet} for the current operation
     */
    DataFetchingFieldSelectionSet getSelectionSet();
}

@@ -373,16 +373,17 @@
 nment %7B%0A
+%0A
     /**%0A
@@ -393,93 +393,352 @@
   * 
-@param %3CT%3E you decide what type it is%0A     * @return the current object being queried
+This is the value of the current object to be queried.%0A     * Or to put it differently: it is the value of the parent field.%0A     * %3Cp%3E%0A     * For the root query, it is equal to %7B%7B@link DataFetchingEnvironment#getRoot%7D%0A     *%0A     * @param %3CT%3E you decide what type it is%0A     * @return can be null for the root query, otherwise it is never null
 %0A   
@@ -1462,24 +1462,8 @@
 cute
-(String, Object)
 %7D me
@@ -1484,16 +1484,134 @@
  invoked
+.%0A     * %3Cp%3E%0A     * This is a info object which is provided to all DataFetcher, but never used by graphql-java itself.
 %0A     *%0A
@@ -1674,24 +1674,19 @@
 urn 
-a context object
+can be null
 %0A   
@@ -1711,24 +1711,145 @@
 Context();%0A%0A
+    /**%0A     * This is the source object for the root query.%0A     *%0A     * @param %3CT%3E%0A     * @return can be null%0A     */%0A
     %3CT%3E T ge

improve javadoc