Skip to content

Commit 1c9d18c

Browse files
committed
Get compiling with v9 beta 3 and GraphQL 4.5
1 parent 74e345f commit 1c9d18c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+379
-777
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ Visual Studio 2017/*
2323
/src/Our.Umbraco.GraphQL/umbraco/UmbracoInstall/
2424
/src/Our.Umbraco.GraphQL/umbraco/UmbracoWebsite/
2525
/src/Our.Umbraco.GraphQL/wwwroot/umbraco/
26+
/samples/Website/umbraco
27+
/samples/Website/wwwroot/umbraco

samples/Website/GraphQLComponent.cs

-53
This file was deleted.

samples/Website/Program.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.AspNetCore.Hosting;
2-
using Microsoft.Extensions.Configuration;
32
using Microsoft.Extensions.Hosting;
43
using Microsoft.Extensions.Logging;
54

samples/Website/Startup.cs

+19-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.AspNetCore.Hosting;
44
using Microsoft.Extensions.Configuration;
55
using Microsoft.Extensions.DependencyInjection;
6+
using Microsoft.Extensions.Hosting;
67
using Umbraco.Cms.Core.DependencyInjection;
78
using Umbraco.Extensions;
89

@@ -51,10 +52,25 @@ public void ConfigureServices(IServiceCollection services)
5152
/// <summary>
5253
/// Configures the application
5354
/// </summary>
54-
public void Configure(IApplicationBuilder app)
55+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5556
{
56-
app.UseUmbracoBackOffice();
57-
app.UseUmbracoWebsite();
57+
if (env.IsDevelopment())
58+
{
59+
app.UseDeveloperExceptionPage();
60+
}
61+
62+
app.UseUmbraco()
63+
.WithMiddleware(u =>
64+
{
65+
u.WithBackOffice();
66+
u.WithWebsite();
67+
})
68+
.WithEndpoints(u =>
69+
{
70+
u.UseInstallerEndpoints();
71+
u.UseBackOfficeEndpoints();
72+
u.UseWebsiteEndpoints();
73+
});
5874
}
5975
}
6076
}

samples/Website/Starwars/StarwarsComponent.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
using System;
22
using Our.Umbraco.GraphQL.Adapters.Types.Resolution;
33
using Our.Umbraco.GraphQL.Types;
4-
using Umbraco.Cms.Core;
4+
using Umbraco.Extensions;
55
using Umbraco.Cms.Core.Composing;
6+
using Umbraco.Cms.Core.DependencyInjection;
67
using Website.Starwars.Data;
78
using Website.Starwars.Schema;
89

910
namespace Website
1011
{
11-
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
1212
public class StarwarsComposer : ComponentComposer<StarwarsComponent>, IUserComposer
1313
{
14-
public override void Compose(Composition composition)
14+
public override void Compose(IUmbracoBuilder builder)
1515
{
16-
base.Compose(composition);
16+
base.Compose(builder);
1717

18-
composition.Register<StarWarsData>(Lifetime.Singleton);
18+
builder.Services.AddUnique<StarWarsData>();
1919
}
2020
}
2121

samples/Website/Website.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44
</PropertyGroup>
55

66
<ItemGroup>
7-
<PackageReference Include="Umbraco.Cms" Version="9.0.0-alpha004" />
7+
<PackageReference Include="Umbraco.Cms" Version="9.0.0-beta003" />
8+
<PackageReference Include="Umbraco.Cms.SqlCe" Version="9.0.0-beta003" />
89
</ItemGroup>
910

1011

1112
<ItemGroup>
1213
<Compile Remove="umbraco\Data\**" />
1314
<Compile Remove="umbraco\logs\**" />
1415
<Compile Remove="umbraco\MediaCache\**" />
15-
<Compile Remove="umbraco\models\**" />
1616
</ItemGroup>
1717
<ItemGroup>
1818
<EmbeddedResource Remove="umbraco\Data\**" />
1919
<EmbeddedResource Remove="umbraco\logs\**" />
2020
<EmbeddedResource Remove="umbraco\MediaCache\**" />
21-
<EmbeddedResource Remove="umbraco\models\**" />
2221
</ItemGroup>
2322
<ItemGroup>
24-
<None Remove="umbraco\models\**" />
2523
<None Remove="umbraco\Data\**" />
2624
<None Remove="umbraco\logs\**" />
2725
<None Remove="umbraco\MediaCache\**" />
@@ -38,7 +36,9 @@
3836
<Content Remove="umbraco\Data\**" />
3937
<Content Remove="umbraco\logs\**" />
4038
<Content Remove="umbraco\MediaCache\**" />
41-
<Content Remove="umbraco\models\**" />
39+
</ItemGroup>
40+
<ItemGroup>
41+
<ProjectReference Include="..\..\src\Our.Umbraco.GraphQL\Our.Umbraco.GraphQL.csproj" />
4242
</ItemGroup>
4343

4444
<!--Set this to true ModelsBuilder mode is not PureLive -->

samples/Website/appsettings.Development.json

+6-16
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
},
1919
"Umbraco": {
2020
"CMS": {
21+
"Content": {
22+
"MacroErrors": "Throw"
23+
},
2124
"Global": {
2225
"Smtp": {
23-
//"From": "your@email.here",
24-
//"Host": "localhost",
25-
// "Port": "25"
26+
"From": "your@email.here",
27+
"Host": "localhost",
28+
"Port": "25"
2629
}
2730
},
2831
"Hosting": {
@@ -31,20 +34,7 @@
3134
"RuntimeMinification": {
3235
"useInMemoryCache": true,
3336
"cacheBuster": "Timestamp"
34-
},
35-
"RichTextEditor": {
36-
"Commands": [
37-
{
38-
"Alias": "fullscreen",
39-
"Name": "Full Screen",
40-
"Mode": "All"
41-
}
42-
],
43-
"Plugins": [
44-
"fullscreen"
45-
]
4637
}
4738
}
48-
4939
}
5040
}

samples/Website/appsettings.json

+9-52
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ConnectionStrings": {
3-
"umbracoDbDSN": ""
3+
"umbracoDbDSN": "Data Source=|DataDirectory|\\Umbraco.sdf;Flush Interval=1;"
44
},
55
"Serilog": {
66
"MinimumLevel": {
@@ -14,61 +14,18 @@
1414
},
1515
"Umbraco": {
1616
"CMS": {
17-
"Content": {
18-
"Notifications": {
19-
"Email": "your@email.here"
20-
},
21-
"MacroErrors": "throw"
22-
},
23-
"Global": {
24-
"DefaultUILanguage": "en-us",
25-
"HideTopLevelNodeFromPath": true,
26-
"UmbracoPath": "~/umbraco",
27-
"TimeOutInMinutes": 20,
28-
"UseHttps": false
29-
},
3017
"Hosting": {
3118
"Debug": false
3219
},
33-
"KeepAlive": {
34-
"DisableKeepAliveTask": false,
35-
"KeepAlivePingUrl": "{umbracoApplicationUrl}/api/keepalive/ping"
36-
},
37-
"RequestHandler": {
38-
"ConvertUrlsToAscii": "try"
39-
},
40-
"RuntimeMinification": {
41-
"dataFolder": "umbraco/Data/TEMP/Smidge",
42-
"version": "637510451273675926"
43-
},
44-
"Security": {
45-
"KeepUserLoggedIn": false,
46-
"UsernameIsEmail": true,
47-
"HideDisabledUsersInBackoffice": false,
48-
"UserPassword": {
49-
"RequiredLength": 10,
50-
"RequireNonLetterOrDigit": false,
51-
"RequireDigit": false,
52-
"RequireLowercase": false,
53-
"RequireUppercase": false,
54-
"MaxFailedAccessAttemptsBeforeLockout": 5
55-
},
56-
"MemberPassword": {
57-
"RequiredLength": 10,
58-
"RequireNonLetterOrDigit": false,
59-
"RequireDigit": false,
60-
"RequireLowercase": false,
61-
"RequireUppercase": false,
62-
"MaxFailedAccessAttemptsBeforeLockout": 5
63-
}
64-
},
65-
"Tours": {
66-
"EnableTours": true
67-
},
68-
"ModelsBuilder": {
69-
"ModelsMode": "PureLive",
70-
"Enable": true
20+
"Global": {
21+
"Id": "a6a18915-b6f1-490b-9ab7-d33f7aa09e68"
7122
}
7223
}
24+
},
25+
"GraphQL": {
26+
"Server": {
27+
"EnablePlayground": true,
28+
"EnableMetrics": true
29+
}
7330
}
7431
}

src/Our.Umbraco.GraphQL/Adapters/Builders/FieldBuilderExtensions.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ public static FieldBuilder<TSourceType, object> Metadata<TSourceType>(
1313
return builder;
1414
}
1515

16-
public static ConnectionBuilder<TNodeType, TSourceType> Metadata<TNodeType, TSourceType>(
17-
this ConnectionBuilder<TNodeType, TSourceType> builder, string key, object value)
18-
where TNodeType : IGraphType
16+
public static ConnectionBuilder<TSourceType> Metadata<TSourceType>(
17+
this ConnectionBuilder<TSourceType> builder, string key, object value)
1918
{
2019
builder.FieldType.Metadata.Add(key, value);
2120
return builder;
2221
}
2322

24-
public static ConnectionBuilder<TNodeType, TSourceType> Orderable<TNodeType, TSourceType>(
25-
this ConnectionBuilder<TNodeType, TSourceType> builder) where TNodeType : IComplexGraphType
23+
public static ConnectionBuilder<TSourceType> Orderable<TSourceType, TNodeType>(
24+
this ConnectionBuilder<TSourceType> builder) where TNodeType : IComplexGraphType
2625
{
2726
builder.Argument<ListGraphType<NonNullGraphType<OrderByGraphType<TNodeType>>>>("orderBy", "");
2827
return builder;

src/Our.Umbraco.GraphQL/Adapters/Examine/Types/ExamineGraphTypeExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static void AddBuiltInFields(this ComplexGraphType<ISearchResult> graphTy
4444
graphType.Connection<SearchResultFieldsGraphType>().Name("fields")
4545
.Metadata(nameof(MemberInfo), GetMember((ISearchResult x) => x.AllValues))
4646
.Bidirectional()
47-
.Orderable()
47+
.Orderable<ISearchResult, SearchResultFieldsGraphType>()
4848
.Resolve(ctx =>
4949
ctx.Source.AllValues
5050
.OrderBy(ctx.GetArgument<IList<OrderBy>>("orderBy"))

src/Our.Umbraco.GraphQL/Adapters/Examine/Types/ExamineSearcherGraphType.cs

+10-25
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using Examine;
2-
using Examine.LuceneEngine.Providers;
2+
using Examine.Lucene.Providers;
33
using Examine.Search;
4+
using GraphQL;
45
using GraphQL.Types;
5-
using Lucene.Net.Index;
66
using System;
7-
using System.Collections.Generic;
87
using System.Linq;
98
using System.Reflection;
109
using Umbraco.Cms.Core.PublishedCache;
@@ -20,15 +19,16 @@ public class ExamineSearcherGraphType : ObjectGraphType<ExamineSearcherQuery>
2019
public ExamineSearcherGraphType(IPublishedSnapshotAccessor snapshotAccessor, ISearcher searcher, string searcherSafeName)
2120
{
2221
Name = $"{searcherSafeName}Searcher";
23-
var fields = GetFieldNames(searcher as LuceneSearcher) ?? (searcher is BaseLuceneSearcher bls ? bls.GetAllIndexedFields() : null);
22+
var fields = searcher is BaseLuceneSearcher bls ? bls.GetSearchContext().SearchableFields : null;
2423

2524
Field<SearchResultsInterfaceGraphType>()
2625
.Name("query")
2726
.Description("Queries the Examine searcher using a raw Lucene syntax query")
2827
.Argument<StringGraphType>("query", "The raw Lucene query to execute in this searcher")
2928
.Argument<StringGraphType, string>("category", "The category of data to include in the results. For Umbraco content indexes, this is the content type alias", null)
3029
.Argument<BooleanOperationGraphType, BooleanOperation>("defaultOperation", "The default operation to use when searching", BooleanOperation.And)
31-
.Argument<IntGraphType, int>("maxResults", "The maximum number of results to return", 500)
30+
.Argument<IntGraphType, int>("skip", "The number of results to skip over", 0)
31+
.Argument<IntGraphType, int>("take", "The maximum number of results to return", 500)
3232
.Argument<StringGraphType>("sortFields", "A comma-separated list of field names to sort by. If you need to specify a sort field type, do so with a pipe and then the type, i.e. fieldName|bool")
3333
.Argument<SortDirectionGraphType, SortDirection>("sortDir", "The direction for Examine to sort", SortDirection.ASC)
3434
.Resolve(GetQueryResults);
@@ -38,30 +38,15 @@ public ExamineSearcherGraphType(IPublishedSnapshotAccessor snapshotAccessor, ISe
3838
.Name("search")
3939
.Description("Queries the Examine searcher using the natural language Search method")
4040
.Argument<StringGraphType>("query", "The text to search for")
41+
.Argument<IntGraphType, int>("skip", "The number of results to skip over", 0)
4142
.Argument<IntGraphType, int>("maxResults", "The maximum number of results to return", 500)
4243
.Resolve(GetSearchResults);
4344
GetField("search").ResolvedType = new SearchResultsGraphType(snapshotAccessor, $"{searcherSafeName}Search", fields);
4445

4546
_searcher = searcher;
4647
}
4748

48-
private ICollection<string> GetFieldNames(LuceneSearcher searcher)
49-
{
50-
if (searcher == null) return null;
51-
52-
try
53-
{
54-
_validateSearcherMethod.Invoke(searcher, new object[0]);
55-
var reader = _resultField.GetValue(searcher) as IndexReader;
56-
return reader?.GetFieldNames(IndexReader.FieldOption.ALL);
57-
}
58-
catch
59-
{
60-
return null;
61-
}
62-
}
63-
64-
private ISearchResults GetQueryResults(ResolveFieldContext<ExamineSearcherQuery> ctx)
49+
private ISearchResults GetQueryResults(IResolveFieldContext<ExamineSearcherQuery> ctx)
6550
{
6651
var query = _searcher.CreateQuery(ctx.GetArgument<string>("category"), ctx.GetArgument<bool>("defaultAnd") ? BooleanOperation.And : BooleanOperation.Or)
6752
.NativeQuery(ctx.GetArgument<string>("query")) as IOrdering;
@@ -80,13 +65,13 @@ private ISearchResults GetQueryResults(ResolveFieldContext<ExamineSearcherQuery>
8065
else query = query.OrderByDescending(sortableFields);
8166
}
8267

83-
var results = query.Execute(ctx.GetArgument<int>("maxResults"));
68+
var results = query.Execute(new QueryOptions(ctx.GetArgument<int>("skip"), ctx.GetArgument<int>("take")));
8469
return results;
8570
}
8671

87-
private ISearchResults GetSearchResults(ResolveFieldContext<ExamineSearcherQuery> ctx)
72+
private ISearchResults GetSearchResults(IResolveFieldContext<ExamineSearcherQuery> ctx)
8873
{
89-
var results = _searcher.Search(ctx.GetArgument<string>("query"), ctx.GetArgument<int>("maxResults"));
74+
var results = _searcher.Search(ctx.GetArgument<string>("query"), new QueryOptions(ctx.GetArgument<int>("skip"), ctx.GetArgument<int>("take")));
9075
return results;
9176
}
9277
}

0 commit comments

Comments
 (0)