public void Initialize(IGraphModel model)
        {
            AddField(new FieldType
            {
                Name         = "url",
                ResolvedType = AllTypes.NonNullString,
                Resolver     = model.ResolveContentUrl(schema),
                Description  = $"The url to the the {schemaName} content."
            });

            var contentDataType = new ContentDataGraphType(schema, schemaName, schemaType, model);

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

                AddField(new FieldType
                {
                    Name         = "dataDraft",
                    ResolvedType = contentDataType,
                    Resolver     = Resolve(x => x.DataDraft),
                    Description  = $"The draft data of the {schemaName} content."
                });
            }

            var contentDataTypeFlat = new ContentDataFlatGraphType(schema, schemaName, schemaType, model);

            if (contentDataTypeFlat.Fields.Any())
            {
                AddField(new FieldType
                {
                    Name         = "flatData",
                    ResolvedType = new NonNullGraphType(contentDataTypeFlat),
                    Resolver     = ResolveFlat(x => x.Data),
                    Description  = $"The flat data of the {schemaName} content."
                });

                AddField(new FieldType
                {
                    Name         = "flatDataDraft",
                    ResolvedType = contentDataTypeFlat,
                    Resolver     = ResolveFlat(x => x.DataDraft),
                    Description  = $"The flat draft data of the {schemaName} content."
                });
            }
        }
Esempio n. 2
0
        public void Initialize(IGraphModel model, ISchemaEntity schema, IEnumerable <ISchemaEntity> all, int pageSize)
        {
            var schemaType = schema.TypeName();
            var schemaName = schema.DisplayName();

            AddField(new FieldType
            {
                Name         = "url",
                ResolvedType = AllTypes.NonNullString,
                Resolver     = ContentResolvers.Url,
                Description  = $"The url to the the {schemaName} content."
            });

            var contentDataType = new ContentDataGraphType(schema, schemaName, schemaType, model);

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

            var contentDataTypeFlat = new ContentDataFlatGraphType(schema, schemaName, schemaType, model);

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

            foreach (var other in all.Where(x => References(x, schema)))
            {
                var referencingId   = other.Id;
                var referencingType = other.TypeName();
                var referencingName = other.DisplayName();

                var contentType = model.GetContentType(referencingId);

                AddReferencingQueries(referencingId, referencingType, referencingName, contentType, pageSize);
            }
        }
Esempio n. 3
0
        public void Initialize(IGraphModel model)
        {
            AddField(new FieldType
            {
                Name         = "url",
                ResolvedType = AllTypes.NonNullString,
                Resolver     = ContentResolvers.Url,
                Description  = $"The url to the the {schemaName} content."
            });

            var contentDataType = new ContentDataGraphType(schema, schemaName, schemaType, model);

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

            var contentDataTypeFlat = new ContentDataFlatGraphType(schema, schemaName, schemaType, model);

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