Esempio n. 1
0
        public ContentDataGraphType(ISchemaEntity schema, string schemaName, string schemaType, IGraphModel model)
        {
            Name = $"{schemaType}DataDto";

            foreach (var(field, fieldName, typeName) in schema.SchemaDef.Fields.SafeFields())
            {
                var(resolvedType, valueResolver, args) = model.GetGraphType(schema, field, typeName);

                if (valueResolver != null)
                {
                    var displayName = field.DisplayName();

                    var fieldGraphType = new ObjectGraphType
                    {
                        Name = $"{schemaType}Data{typeName}Dto"
                    };

                    var partitioning = model.ResolvePartition(field.Partitioning);

                    foreach (var partitionKey in partitioning.AllKeys)
                    {
                        fieldGraphType.AddField(new FieldType
                        {
                            Name         = partitionKey.EscapePartition(),
                            Arguments    = args,
                            ResolvedType = resolvedType,
                            Resolver     = ContentResolvers.Partition(valueResolver, partitionKey),
                            Description  = field.RawProperties.Hints
                        });
                    }

                    fieldGraphType.Description = $"The structure of the {displayName} field of the {schemaName} content type.";

                    AddField(new FieldType
                    {
                        Name         = fieldName,
                        ResolvedType = fieldGraphType,
                        Resolver     = ContentResolvers.Field(field),
                        Description  = $"The {displayName} field."
                    });
                }
            }

            Description = $"The structure of the {schemaName} data type.";
        }
Esempio n. 2
0
        public ContentDataFlatGraphType(ISchemaEntity schema, string schemaName, string schemaType, IGraphModel model)
        {
            Name = $"{schemaType}DataFlatDto";

            foreach (var(field, fieldName, _) in schema.SchemaDef.Fields.SafeFields())
            {
                var(resolvedType, valueResolver, args) = model.GetGraphType(schema, field, fieldName);

                if (valueResolver != null)
                {
                    AddField(new FieldType
                    {
                        Name         = fieldName,
                        Arguments    = args,
                        ResolvedType = resolvedType,
                        Resolver     = ContentResolvers.FlatPartition(valueResolver, field.Name),
                        Description  = field.RawProperties.Hints
                    });
                }
            }

            Description = $"The structure of the flat {schemaName} data type.";
        }