Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c03d15e

Browse files
Fixed content resolution for IHtmlEncodedStrings
1 parent 94409ca commit c03d15e

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using GraphQL.Language.AST;
2+
using GraphQL.Types;
3+
using Umbraco.Cms.Core.Strings;
4+
5+
namespace Our.Umbraco.GraphQL.Adapters.PublishedContent.Types
6+
{
7+
public class HtmlEncodedStringGraphType : ScalarGraphType
8+
{
9+
public HtmlEncodedStringGraphType()
10+
{
11+
Name = "HtmlEncodedString";
12+
Description = "A string containing HTML code.";
13+
}
14+
15+
public override object ParseLiteral(IValue value)
16+
{
17+
if (value is StringValue stringValue)
18+
return ParseValue(stringValue.Value);
19+
return null;
20+
}
21+
22+
public override object ParseValue(object value)
23+
{
24+
if (value is string stringValue)
25+
return new HtmlEncodedString(stringValue);
26+
27+
return null;
28+
}
29+
30+
public override object Serialize(object value)
31+
{
32+
if (value is IHtmlEncodedString htmlString)
33+
return htmlString.ToHtmlString();
34+
35+
return null;
36+
}
37+
}
38+
}

‎src/Our.Umbraco.GraphQL/Adapters/Types/Resolution/TypeRegistry.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Our.Umbraco.GraphQL.Types;
1212
using Our.Umbraco.GraphQL.Types.Relay;
1313
using Umbraco.Cms.Core.Models.Blocks;
14+
using Umbraco.Cms.Core.Strings;
1415

1516
namespace Our.Umbraco.GraphQL.Adapters.Types.Resolution
1617
{
@@ -42,6 +43,7 @@ public TypeRegistry()
4243
Add<Id, IdGraphType>();
4344
Add<PageInfo, PageInfoGraphType>();
4445
Add<BlockListItem, BlockListItemGraphType>();
46+
Add<IHtmlEncodedString, HtmlEncodedStringGraphType>();
4547
}
4648

4749
public void Add<TType, TGraphType>() where TGraphType : IGraphType =>

‎src/Our.Umbraco.GraphQL/Compose/GraphQLComposer.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public override void Compose(IUmbracoBuilder builder)
6969
builder.Services.AddTransient<UdiGraphType>();
7070
builder.Services.AddTransient<LinkGraphType>();
7171
builder.Services.AddTransient<JsonGraphType>();
72+
builder.Services.AddTransient<HtmlEncodedStringGraphType>();
7273
builder.Services.AddTransient<SearchResultsInterfaceGraphType>();
7374
builder.Services.AddTransient<SearchResultInterfaceGraphType>();
7475
builder.Services.AddTransient<SearchResultFieldsGraphType>();

‎src/Our.Umbraco.GraphQL/Our.Umbraco.GraphQL.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<packageTags>umbraco umbracocms graphql</packageTags>
1010
<copyright>Copyright © 2021 Rasmus John Pedersen</copyright>
1111
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12-
<versionPrefix>9.0.0-alpha002</versionPrefix>
12+
<versionPrefix>9.0.0-alpha003</versionPrefix>
1313
</PropertyGroup>
1414

1515
<PropertyGroup>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /