public NestedInputGraphType(IGraphModel model, ISchemaEntity schema, IArrayField field, string fieldName) { var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); var fieldDisplayName = field.DisplayName(); Name = $"{schemaType}{fieldName}InputChildDto"; foreach (var(nestedField, nestedName, typeName) in field.Fields.SafeFields().Where(x => x.Field.IsForApi(true))) { var resolvedType = model.GetInputGraphType(schema, nestedField, typeName); if (resolvedType != null) { AddField(new FieldType { Name = nestedName, ResolvedType = resolvedType, Resolver = null, Description = $"The {fieldDisplayName}/{nestedField.DisplayName()} nested field." }).WithSourceName(nestedField.Name); } } Description = $"The structure of the {schemaName}.{fieldDisplayName} nested schema."; }
public ContentDataGraphInputType(IGraphModel model, ISchemaEntity schema) { var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); Name = $"{schemaType}InputDto"; foreach (var field in schema.SchemaDef.Fields.Where(x => !x.IsHidden)) { var inputType = model.GetInputGraphType(field); if (inputType != null) { if (field.RawProperties.IsRequired) { inputType = new NonNullGraphType(inputType); } var fieldName = field.RawProperties.Label.WithFallback(field.Name); var fieldGraphType = new InputObjectGraphType { Name = $"{schemaType}Data{field.Name.ToPascalCase()}InputDto" }; var partition = model.ResolvePartition(field.Partitioning); foreach (var partitionItem in partition) { fieldGraphType.AddField(new FieldType { Name = partitionItem.Key, ResolvedType = inputType, Resolver = null, Description = field.RawProperties.Hints }); } fieldGraphType.Description = $"The input structure of the {fieldName} of a {schemaName} content type."; var fieldResolver = new FuncFieldResolver <NamedContentData, ContentFieldData>(c => c.Source.GetOrDefault(field.Name)); AddField(new FieldType { Name = field.Name.ToCamelCase(), Resolver = fieldResolver, ResolvedType = fieldGraphType, Description = $"The {fieldName} field." }); } } Description = $"The structure of a {schemaName} content type."; }
public ContentDataInputGraphType(ISchemaEntity schema, string schemaName, string schemaType, IGraphModel model) { Name = $"{schemaType}DataInputDto"; foreach (var(field, fieldName, typeName) in schema.SchemaDef.Fields.SafeFields().Where(x => x.Field.IsForApi(true))) { var resolvedType = model.GetInputGraphType(schema, field, typeName); if (resolvedType != null) { var displayName = field.DisplayName(); var fieldGraphType = new InputObjectGraphType { Name = $"{schemaType}Data{typeName}InputDto" }; var partitioning = model.ResolvePartition(field.Partitioning); foreach (var partitionKey in partitioning.AllKeys) { fieldGraphType.AddField(new FieldType { Name = partitionKey.EscapePartition(), ResolvedType = resolvedType, Resolver = null, Description = field.RawProperties.Hints }).WithSourceName(partitionKey); } fieldGraphType.Description = $"The structure of the {displayName} field of the {schemaName} content input type."; AddField(new FieldType { Name = fieldName, ResolvedType = fieldGraphType, Resolver = null, Description = $"The {displayName} field." }).WithSourceName(field.Name); } } Description = $"The structure of the {schemaName} data input type."; }