/// <summary> /// Creates a GraphQL type from <typeparamref name="TSourceType"/>. /// </summary> public AutoObjectGraphType() { GraphTypeHelper.ConfigureGraph <TSourceType>(this, GetDefaultName); //check if there is a default concurrency setting var concurrentAttribute = typeof(TSourceType).GetCustomAttribute <ConcurrentAttribute>(); if (concurrentAttribute != null) { DefaultConcurrent = true; DefaultCreateScope = concurrentAttribute.CreateNewScope; } GraphTypeHelper.AddFields(this, CreateFieldTypeList()); }
/// <summary> /// Processes the specified property and returns a <see cref="FieldType"/> /// </summary> /// <param name="property"></param> /// <returns></returns> protected virtual FieldType?ProcessProperty(PropertyInfo property) { var fieldType = GraphTypeHelper.CreateField( property, () => InferGraphType(ApplyAttributes(GetTypeInformation(property)))); if (fieldType == null) { return(null); } //load the default value fieldType.DefaultValue = property.GetCustomAttribute <DefaultValueAttribute>()?.Value; //return the field return(fieldType); }
/// <summary> /// Processes the specified property and returns a <see cref="FieldType"/> /// </summary> /// <param name="property"></param> /// <returns></returns> protected virtual FieldType?ProcessProperty(PropertyInfo property) { var fieldType = GraphTypeHelper.CreateField( property, () => InferGraphType(ApplyAttributes(GetTypeInformation(property)))); if (fieldType == null) { return(null); } //create the field resolver fieldType.Resolver = new PropertyResolver(property); //return the field return(fieldType); }
/// <summary> /// Creates a GraphQL type from <typeparamref name="TSourceType"/>. /// </summary> public AutoInputObjectGraphType() { GraphTypeHelper.ConfigureGraph <TSourceType>(this, GetDefaultName); GraphTypeHelper.AddFields(this, CreateFieldTypeList()); }