Пример #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>()?.Description;

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

            foreach (var field in fields)
            {
                AddField(field);
            }
        }
Пример #2
0
        public FieldType GetFieldType(Boolean 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);
        }
Пример #3
0
 public IGraphType GetQueryItemType(Type modelType, Boolean isInput)
 {
     return(QueryParametersHelper.GetQueryItemType(this, modelType, isInput));
 }