Last active
August 30, 2019 16:26
-
-
Save serbasii/8cb59a411d390386354b9b2aa5bab2de to your computer and use it in GitHub Desktop.
dotnet-graphql override AddField, get register type's description attribute and set FieldType
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyObjectType : ObjectGraphType<MyObject> | |
{ | |
public MyObjectType() | |
{ | |
Field(t => t.Code); | |
} | |
public override FieldType AddField(FieldType fieldType) | |
{ | |
//var type_ = fieldType.Resolver.GetType().GetTypeInfo().GenericTypeArguments[0]; | |
Type type = fieldType.Resolver.GetType().GetGenericArguments()[0]; | |
string description = type.GetProperty(fieldType.Name).GetCustomAttribute<DescriptionAttribute>().Description; | |
fieldType.Description = description; | |
return base.AddField(fieldType); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment