Beispiel #1
0
        public void Initialize(Builder builder, SchemaInfo schemaInfo, IEnumerable <SchemaInfo> allSchemas)
        {
            AddField(ContentFields.Id);
            AddField(ContentFields.Version);
            AddField(ContentFields.Created);
            AddField(ContentFields.CreatedBy);
            AddField(ContentFields.CreatedByUser);
            AddField(ContentFields.EditToken);
            AddField(ContentFields.LastModified);
            AddField(ContentFields.LastModifiedBy);
            AddField(ContentFields.LastModifiedByUser);
            AddField(ContentFields.Status);
            AddField(ContentFields.StatusColor);
            AddField(ContentFields.NewStatus);
            AddField(ContentFields.NewStatusColor);
            AddField(ContentFields.Url);

            var contentDataType = new DataGraphType(builder, schemaInfo);

            if (contentDataType.Fields.Any())
            {
                AddField(new FieldType
                {
                    Name         = "data",
                    ResolvedType = new NonNullGraphType(contentDataType),
                    Resolver     = ContentResolvers.Data,
                    Description  = FieldDescriptions.ContentData
                });
            }

            var contentDataTypeFlat = new DataFlatGraphType(builder, schemaInfo);

            if (contentDataTypeFlat.Fields.Any())
            {
                AddField(new FieldType
                {
                    Name         = "flatData",
                    ResolvedType = new NonNullGraphType(contentDataTypeFlat),
                    Resolver     = ContentResolvers.FlatData,
                    Description  = FieldDescriptions.ContentFlatData
                });
            }

            foreach (var other in allSchemas.Where(IsReferencingThis))
            {
                AddReferencingQueries(builder, other);
            }

            AddResolvedInterface(builder.SharedTypes.ContentInterface);

            Description = $"The structure of a {schemaInfo.DisplayName} content type.";
        }
        public void Initialize(Builder builder, SchemaInfo schemaInfo, IEnumerable <SchemaInfo> allSchemas)
        {
            AddField(new FieldType
            {
                Name         = "url",
                ResolvedType = AllTypes.NonNullString,
                Resolver     = ContentResolvers.Url,
                Description  = "The url to the content."
            });

            var contentDataType = new DataGraphType(builder, schemaInfo);

            if (contentDataType.Fields.Any())
            {
                AddField(new FieldType
                {
                    Name         = "data",
                    ResolvedType = new NonNullGraphType(contentDataType),
                    Resolver     = ContentResolvers.Data,
                    Description  = "The data of the content."
                });
            }

            var contentDataTypeFlat = new DataFlatGraphType(builder, schemaInfo);

            if (contentDataTypeFlat.Fields.Any())
            {
                AddField(new FieldType
                {
                    Name         = "flatData",
                    ResolvedType = new NonNullGraphType(contentDataTypeFlat),
                    Resolver     = ContentResolvers.FlatData,
                    Description  = "The flat data of the content."
                });
            }

            foreach (var other in allSchemas.Where(IsReferencingThis))
            {
                AddReferencingQueries(builder, other);
            }
        }