Esempio n. 1
0
        public NestedGraphType(IGraphModel model, ISchemaEntity schema, IArrayField field, string fieldName)
        {
            var schemaType = schema.TypeName();
            var schemaName = schema.DisplayName();

            var fieldDisplayName = field.DisplayName();

            Name = $"{schemaType}{fieldName}ChildDto";

            foreach (var(nestedField, nestedName, typeName) in field.Fields.SafeFields().Where(x => x.Field.IsForApi()))
            {
                var(resolvedType, valueResolver, args) = model.GetGraphType(schema, nestedField, typeName);

                if (resolvedType != null && valueResolver != null)
                {
                    AddField(new FieldType
                    {
                        Name         = nestedName,
                        Arguments    = args,
                        ResolvedType = resolvedType,
                        Resolver     = ContentResolvers.NestedValue(valueResolver, nestedField.Name),
                        Description  = $"The {fieldDisplayName}/{nestedField.DisplayName()} nested field."
                    });
                }
            }

            Description = $"The structure of the {schemaName}.{fieldDisplayName} nested schema.";
        }
Esempio n. 2
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,
                            Resolver     = ContentResolvers.Partition(valueResolver, partitionKey),
                            ResolvedType = resolvedType,
                            Description  = field.RawProperties.Hints
                        });
                    }

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

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

            Description = $"The structure of the {schemaName} data type.";
        }
Esempio n. 3
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,
                        Resolver     = ContentResolvers.FlatPartition(valueResolver, field.Name),
                        ResolvedType = resolvedType,
                        Description  = field.RawProperties.Hints
                    });
                }
            }

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