public ISchemaType AddAllFields(bool autoCreateNewComplexTypes = false, bool autoCreateEnumTypes = true) { if (IsEnum) { foreach (var field in ContextType.GetTypeInfo().GetFields()) { if (field.Name == "value__") { continue; } var enumName = Enum.Parse(ContextType, field.Name).ToString(); var description = (field.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute)?.Description; AddField(new Field(enumName, null, description, Name, ContextType, null)); } } else { var fields = SchemaBuilder.GetFieldsFromObject(ContextType, schema, autoCreateEnumTypes, autoCreateNewComplexTypes); AddFields(fields); } return(this); }
public ISchemaType AddAllFields(bool autoCreateNewComplexTypes = false, bool autoCreateEnumTypes = true) { if (IsEnum) { foreach (var field in ContextType.GetTypeInfo().GetFields()) { if (field.Name == "value__") { continue; } var enumName = Enum.Parse(ContextType, field.Name).ToString(); var description = (field.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute)?.Description; var attributes = field.GetCustomAttributes(typeof(GraphQLAuthorizeAttribute), true).Cast <GraphQLAuthorizeAttribute>(); AddField(new Field(enumName, null, description, new GqlTypeInfo(() => schema.Type(ContextType), ContextType), new RequiredClaims(attributes))); } } else { var fields = SchemaBuilder.GetFieldsFromObject(ContextType, schema, autoCreateEnumTypes, schema.SchemaFieldNamer, autoCreateNewComplexTypes); AddFields(fields); } return(this); }
protected ResolverParameterCompilerBase() { ContextType = typeof(T); ContextTypeInfo = ContextType.GetTypeInfo(); }