Skip to content

Commit d6b58a4

Browse files
authored
Upgrade GraphiQL to 1.5.1 (#649)
1 parent bed99b0 commit d6b58a4

File tree

12 files changed

+203
-137
lines changed

12 files changed

+203
-137
lines changed

samples/Samples.Schemas.Chat/IChat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Message AddMessage(ReceivedMessage message)
4444
return AddMessage(new Message
4545
{
4646
Content = message.Content,
47-
SentAt = message.SentAt,
47+
SentAt = message.SentAt ?? DateTime.UtcNow,
4848
From = new MessageFrom
4949
{
5050
DisplayName = displayName,

samples/Samples.Schemas.Chat/Message.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public class Message
1010

1111
public string Content { get; set; }
1212

13-
public DateTime SentAt { get; set; }
13+
public DateTime? SentAt { get; set; }
1414
}
1515
}

samples/Samples.Schemas.Chat/MessageType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class MessageType : ObjectGraphType<Message>
77
public MessageType()
88
{
99
Field(o => o.Content);
10-
Field(o => o.SentAt, type: typeof(DateGraphType));
10+
Field(o => o.SentAt, type: typeof(DateTimeGraphType));
1111
Field(o => o.Sub);
1212
Field(o => o.From, false, typeof(MessageFromType)).Resolve(ResolveFrom);
1313
}

samples/Samples.Schemas.Chat/ReceivedMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public class ReceivedMessage
88

99
public string Content { get; set; }
1010

11-
public DateTime SentAt { get; set; }
11+
public DateTime? SentAt { get; set; }
1212
}
1313
}

samples/Samples.Server/Samples.Server.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="GraphQL.SystemReactive" Version="4.6.1" />
1213
<PackageReference Include="Serilog.AspNetCore" Version="4.0.0" />
1314
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
1415
<PackageReference Include="GraphQL.MicrosoftDI" Version="4.6.1" />

samples/Samples.Server/Startup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using GraphQL.Server.Ui.GraphiQL;
88
using GraphQL.Server.Ui.Playground;
99
using GraphQL.Server.Ui.Voyager;
10+
using GraphQL.SystemReactive;
1011
using Microsoft.AspNetCore.Builder;
1112
using Microsoft.AspNetCore.Hosting;
1213
using Microsoft.Extensions.Configuration;
@@ -34,6 +35,7 @@ public void ConfigureServices(IServiceCollection services)
3435
services.AddSingleton<IChat, Chat>();
3536

3637
MicrosoftDI.GraphQLBuilderExtensions.AddGraphQL(services)
38+
.AddSubscriptionDocumentExecuter()
3739
.AddServer(true)
3840
.AddSchema<ChatSchema>()
3941
.ConfigureExecution(options =>

samples/Samples.Server/StartupWithRouting.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using GraphQL.Server.Ui.GraphiQL;
88
using GraphQL.Server.Ui.Playground;
99
using GraphQL.Server.Ui.Voyager;
10+
using GraphQL.SystemReactive;
1011
using Microsoft.AspNetCore.Builder;
1112
using Microsoft.AspNetCore.Hosting;
1213
using Microsoft.Extensions.Configuration;
@@ -35,6 +36,7 @@ public void ConfigureServices(IServiceCollection services)
3536
services.AddSingleton<IChat, Chat>();
3637

3738
MicrosoftDI.GraphQLBuilderExtensions.AddGraphQL(services)
39+
.AddSubscriptionDocumentExecuter()
3840
.AddServer(true)
3941
.AddSchema<ChatSchema>()
4042
.ConfigureExecution(options =>

src/Ui.GraphiQL/GraphiQLOptions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,19 @@ public class GraphiQLOptions
3535
/// Gets or sets a delegate that is called after all transformations of the GraphiQL UI page.
3636
/// </summary>
3737
public Func<GraphiQLOptions, string, string> PostConfigure { get; set; } = (options, result) => result;
38+
39+
/// <summary>
40+
/// Enables the header editor when <see langword="true"/>.
41+
/// Not supported when <see cref="ExplorerExtensionEnabled"/> is <see langword="true"/>.
42+
/// </summary>
43+
/// <remarks>
44+
/// Original setting from <see href="https://github.com/graphql/graphiql/blob/08250feb6ee8335c3b1ca83a912911ae92a75722/packages/graphiql/src/components/GraphiQL.tsx#L186">GraphiQL</see>.
45+
/// </remarks>
46+
public bool HeaderEditorEnabled { get; set; } = true;
47+
48+
/// <summary>
49+
/// Enables the explorer extension when <see langword="true"/>.
50+
/// </summary>
51+
public bool ExplorerExtensionEnabled { get; set; } = true;
3852
}
3953
}

src/Ui.GraphiQL/Internal/GraphiQLPageModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public string Render()
3939
var builder = new StringBuilder(streamReader.ReadToEnd())
4040
.Replace("@Model.GraphQLEndPoint", _options.GraphQLEndPoint)
4141
.Replace("@Model.SubscriptionsEndPoint", _options.SubscriptionsEndPoint)
42-
.Replace("@Model.Headers", JsonSerializer.Serialize<object>(headers));
42+
.Replace("@Model.Headers", JsonSerializer.Serialize<object>(headers))
43+
.Replace("@Model.HeaderEditorEnabled", _options.HeaderEditorEnabled ? "true" : "false")
44+
.Replace("@Model.GraphiQLElement", _options.ExplorerExtensionEnabled ? "GraphiQLWithExtensions.GraphiQLWithExtensions" : "GraphiQL");
4345

4446
_graphiQLCSHtml = _options.PostConfigure(_options, builder.ToString());
4547
}

0 commit comments

Comments
 (0)