// Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeFactory.java
// public interface ITypeFactory {
// 	/**
// 	 * This object needs to know how to convert objects to the specified type. This is used
// 	 * to convert query Parameters to the correct type before method invocation.
// 	 * Object type of the arg can be any object type within java we exposed through GraphQL as a parameter.
// 	 * IE everyone of your query/mutation parameter objects must be handled by this object.
// 	 * Jackson object mapper is a simple way of doing this. IE:
// 	 * <pre>
// 	 * {@code
// 	 * {@liter @Override}
// 	 * public Object convertToType(Type type, Object arg) {
// 	 *		try {
// 	 *			return objectMapper.readValue(objectMapper.writeValueAsString(arg), TypeFactory.defaultInstance().constructType(type));
// 	 *		} catch(IOException ex) {
// 	 *			return Throwables.propagate(ex);
// 	 *		}
// 	 *
// 	 *	}
// 	 * }</pre>
// 	 *
// 	 * @param type The type to convert the object to. This is a ParameterizedType if the original value is so you can recursively determine
// 	 *             what value you should convert to. IE: {@code List<List<Object>>}
// 	 * @param arg The GraphQL version of the argument value IE: Primitive, Object, List of ...
// 	 * @return
// 	 */
// 	Object convertToType(Type type, Object arg);
// }


import com.bretpatterson.schemagen.graphql.ITypeFactory;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import graphql.language.Field;
import graphql.schema.DataFetchingEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;
import java.util.Map;
package com.bretpatterson.schemagen.graphql.datafetchers;



/**
 * Implementation of a IMethodDataFetcher that will invoke a method call with the provided GraphQL arguments. If null and a default value is
 * provided for the argument then the default value will be used, otherwise null will be sent to the method. Parameter objects are converted
 * from <i>GraphQL</i> Deserialized types to the arguments declared type using the regisered {@link ITypeFactory}.
 */
public class DefaultMethodDataFetcher implements IMethodDataFetcher {

	private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMethodDataFetcher.class);
// Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeFactory.java
// public interface ITypeFactory {
// 	/**
// 	 * This object needs to know how to convert objects to the specified type. This is used
// 	 * to convert query Parameters to the correct type before method invocation.
// 	 * Object type of the arg can be any object type within java we exposed through GraphQL as a parameter.
// 	 * IE everyone of your query/mutation parameter objects must be handled by this object.
// 	 * Jackson object mapper is a simple way of doing this. IE:
// 	 * <pre>
// 	 * {@code
// 	 * {@liter @Override}
// 	 * public Object convertToType(Type type, Object arg) {
// 	 *		try {
// 	 *			return objectMapper.readValue(objectMapper.writeValueAsString(arg), TypeFactory.defaultInstance().constructType(type));
// 	 *		} catch(IOException ex) {
// 	 *			return Throwables.propagate(ex);
// 	 *		}
// 	 *
// 	 *	}
// 	 * }</pre>
// 	 *
// 	 * @param type The type to convert the object to. This is a ParameterizedType if the original value is so you can recursively determine
// 	 *             what value you should convert to. IE: {@code List<List<Object>>}
// 	 * @param arg The GraphQL version of the argument value IE: Primitive, Object, List of ...
// 	 * @return
// 	 */
// 	Object convertToType(Type type, Object arg);
// }


// Path: src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/DefaultMethodDataFetcher.java
import com.bretpatterson.schemagen.graphql.ITypeFactory;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import graphql.language.Field;
import graphql.schema.DataFetchingEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;
import java.util.Map;

package com.bretpatterson.schemagen.graphql.datafetchers;



/**
 * Implementation of a IMethodDataFetcher that will invoke a method call with the provided GraphQL arguments. If null and a default value is
 * provided for the argument then the default value will be used, otherwise null will be sent to the method. Parameter objects are converted
 * from <i>GraphQL</i> Deserialized types to the arguments declared type using the regisered {@link ITypeFactory}.
 */
public class DefaultMethodDataFetcher implements IMethodDataFetcher {

	private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMethodDataFetcher.class);
	protected ITypeFactory typeFactory;