Exemplo n.º 1
0
        public static ComplexGraphType <IPublishedContent> AddContentDataProperties(this ComplexGraphType <IPublishedContent> graphType)
        {
            //TODO: black/whitelist properties
            graphType.Field <NonNullGraphType <DateGraphType> >("createDate", "Create date of the content.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <StringGraphType> >("creatorName", "Name of the content creator.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <StringGraphType> >("documentTypeAlias", "Document type alias of the content.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <IdGraphType> >("id", "Unique id of the content.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <IntGraphType> >("index", "Index of the content.", resolve: context => context.Source.GetIndex()).SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <IntGraphType> >("level", "Level of the content.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <BooleanGraphType> >("isFirst", "Is the content first in the list.", resolve: context => context.Source.IsFirst()).SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <BooleanGraphType> >("isLast", "Is the content last in the list.", resolve: context => context.Source.IsLast()).SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <BooleanGraphType> >("isVisible", "Is the content visible.", resolve: context => context.Source.IsVisible()).SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <StringGraphType> >("name", "Name of the content.").SetPermissions(graphType, true);
            graphType.Field <PublishedContentGraphType>("parent", "Parent of the content.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <IntGraphType> >("sortOrder", "SortOrder of the content.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <DateGraphType> >("updateDate", "Update date of the content.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <StringGraphType> >("url", "Url of the content.").SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <StringGraphType> >("urlAbsolute", "Absolute url of the content.", resolve: context => context.Source.UrlAbsolute()).SetPermissions(graphType, true);
            graphType.Field <NonNullGraphType <StringGraphType> >("writerName", "Name of the content writer.").SetPermissions(graphType, true);

            graphType.FilteredConnection <PublishedContentGraphType, IPublishedContent>()
            .Name("ancestors")
            .Description("Ancestors of the content.")
            .Argument <BooleanGraphType>("includeSelf", "include self in list")
            .Bidirectional()
            .Resolve(context =>
                     (context.GetArgument <bool?>("includeSelf") == true
                        ? context.Source.AncestorsOrSelf()
                        : context.Source.Ancestors()).Filter(context).ToConnection(context)
                     );

            graphType.FilteredConnection <PublishedContentGraphType, IPublishedContent>()
            .Name("siblings")
            .Description("Siblings of the content.")
            .Bidirectional()
            .Resolve(context => context.Source.Siblings().Filter(context).ToConnection(context));

            graphType.FilteredConnection <PublishedContentGraphType, IPublishedContent>()
            .Name("children")
            .Description("Children of the content.")
            .Bidirectional()
            .Resolve(context => context.Source.Children.Filter(context).ToConnection(context));

            return(graphType);
        }