Skip to content

Commit 4b23907

Browse files
committed
Nesting built in Umbraco properties under a ContentData field
1 parent 25bc258 commit 4b23907

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/Our.Umbraco.GraphQL/Types/ComplexGraphTypeOfIPublishedContentExtensions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ namespace Our.Umbraco.GraphQL.Types
1818
internal static class ComplexGraphTypeOfIPublishedContentExtensions
1919
{
2020
public static ComplexGraphType<IPublishedContent> AddUmbracoBuiltInProperties(this ComplexGraphType<IPublishedContent> graphType)
21+
{
22+
// TODO: set this field name as a reserved property alias
23+
graphType.Field<BuildInContentDataGraphType>("_contentData", "Built in published content data.", resolve: context => context.Source);
24+
25+
return graphType;
26+
}
27+
28+
public static ComplexGraphType<IPublishedContent> AddContentDataProperties(this ComplexGraphType<IPublishedContent> graphType)
2129
{
2230
//TODO: black/whitelist properties
2331
graphType.Field<NonNullGraphType<DateGraphType>>("createDate", "Create date of the content.");
@@ -47,13 +55,13 @@ public static ComplexGraphType<IPublishedContent> AddUmbracoBuiltInProperties(th
4755
? context.Source.AncestorsOrSelf()
4856
: context.Source.Ancestors()).Filter(context).ToConnection(context)
4957
);
50-
58+
5159
graphType.FilteredConnection<PublishedContentGraphType, IPublishedContent>()
5260
.Name("siblings")
5361
.Description("Siblings of the content.")
5462
.Bidirectional()
5563
.Resolve(context => context.Source.Siblings().Filter(context).ToConnection(context));
56-
64+
5765
graphType.FilteredConnection<PublishedContentGraphType, IPublishedContent>()
5866
.Name("children")
5967
.Description("Children of the content.")

src/Our.Umbraco.GraphQL/Types/PublishedContentGraphType.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,14 @@ public PublishedContentGraphType()
1212
this.AddUmbracoBuiltInProperties();
1313
}
1414
}
15+
16+
public class BuildInContentDataGraphType : ObjectGraphType<IPublishedContent>
17+
{
18+
public BuildInContentDataGraphType()
19+
{
20+
Name = "ContentData";
21+
22+
this.AddContentDataProperties();
23+
}
24+
}
1525
}

0 commit comments

Comments
 (0)