Beispiel #1
0
        public InputObjectGraphTypeFromModel(Type modelType, IGraphQueryHandler graphQueryHandler)
        {
            var modelType1 = modelType;

            //IsTypeOf = type => type.GetType().IsAssignableFrom(modelType1);

            Name        = "Input" + (!modelType1.Name.EndsWith("Model") ? modelType1.Name : modelType1.Name.Substring(0, modelType1.Name.Length - "Model".Length));
            Description = modelType1.GetCustomAttribute <DescriptionAttribute>() != null?modelType1.GetCustomAttribute <DescriptionAttribute>()?.Description : null;

            var fields = QueryParametersHelper.GetFields(modelType1, graphQueryHandler, true);

            foreach (var field in fields)
            {
                AddField(field);
            }
        }
Beispiel #2
0
        public FieldType GetFieldType(bool isInput)
        {
            if (_fieldType != null)
            {
                return(_fieldType);
            }

            var name = typeof(TQuery).Name;

            name       = !name.EndsWith("Query") ? name : name.Substring(0, name.Length - "Query".Length);
            _fieldType = new FieldType
            {
                ResolvedType = QueryParametersHelper.GetQueryItemType(this, typeof(TResult), false),
                Name         = name,
                Description  = typeof(TQuery).GetCustomAttribute <DescriptionAttribute>()?.Description,
                Arguments    = QueryParametersHelper.GetArguments(typeof(TQuery), this, true),
                Resolver     = new FuncFieldResolver <TResult>(context => ExecuteQuery(context).GetAwaiter().GetResult()),
            };
            return(_fieldType);
        }
Beispiel #3
0
 public IGraphType GetQueryItemType(Type modelType, bool isInput)
 {
     return(QueryParametersHelper.GetQueryItemType(this, modelType, isInput));
 }