Skip to content

Commit ba9cb5d

Browse files
committed
- Updated for HotChocolate v12 support!
- All Unit Tests passing! - Enhanced StarWars Demo for testing/validating with v12 for additional manual tests. - Validated functionality of BananaCakePop GraphQL IDE Web App as well as functionality via Insomnia (third party IDE). - With this major update, I'm now correctly calling the GraphQL IDE "Banana Cake Pop" instead of "Playground" (which is the Old IDE). - GraphQL IDE naming is now updated consistently to be called BananaCakePop (new IDE from v11) in code, comments, and Readme; updated Readme sample code also. - Deprecated as obsolete the old EnablePlaygroundWebApp option which will be removed in future release; but remains in place and supported at this time for easier upgrade/transition of projects using the AzureFunctionsProxy. - Updated Nuget version notes and version to correllate to v12.0.0 release and push to Nuget!
1 parent 5c5d8f2 commit ba9cb5d

11 files changed

+78
-65
lines changed

GraphQL.AzureFunctionsProxy.Tests/GraphQLSdlAndPlaygroundTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace GraphQL.AzureFunctionsProxy.Tests
1212
{
1313
[TestClass]
14-
public class GraphQLSdlAndPlaygroundTests : AzureFunctionGraphQLTestBase
14+
public class GraphQLSdlAndBananaCakePopTests : AzureFunctionGraphQLTestBase
1515
{
1616
[TestMethod]
1717
public async Task TestSDLRetrieval()
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QL/@EntryIndexedValue">QL</s:String>
33
<s:Boolean x:Key="/Default/UserDictionary/Words/=GRAPHQL/@EntryIndexedValue">True</s:Boolean>
4-
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serverless/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
4+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serverless/@EntryIndexedValue">True</s:Boolean>
5+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Starship/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

GraphQL.AzureFunctionsProxy/GraphQL.AzureFunctionsProxy.csproj

+13-7
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,27 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
<Version>11.3.8.1</Version>
5+
<Version>12.0.0.1</Version>
66
<Authors>BBernard / CajunCoding</Authors>
77
<Company>CajunCoding</Company>
8-
<Description>This is a extension package for HotChocolate GraphQL framework to enable execution within AzureFunctions using the new v11 API. Provides very easy integration with Azure Functions with maximum support for out-of-the-box HotChocolate functionality.</Description>
8+
<Description>This is a extension package for HotChocolate GraphQL framework to enable execution within AzureFunctions V1 using the new v12 API. Provides very easy integration with Azure Functions with maximum support for out-of-the-box HotChocolate functionality.</Description>
99
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1010
<PackageProjectUrl>https://github.com/cajuncoding/HotChocolate.AzureFunctionsProxy</PackageProjectUrl>
1111
<RepositoryUrl>https://github.com/cajuncoding/HotChocolate.AzureFunctionsProxy</RepositoryUrl>
1212
<PackageTags>graphql, graph-ql, hotchocolate, azure, functions, serverless</PackageTags>
13-
<PackageReleaseNotes>- Bumped to HC v11.3.8
14-
- Update Nuget package for deployment of latest (last) version compatible with v11; v12 is being released today (09/28/2021)
13+
<PackageReleaseNotes>- Fully updated for new Hot Chocolate v12 released today (09/28/2021) with no significant breaking changes.
14+
- Corrected GraphQL IDE naming to now be "Banana Cake Pop" instead of incorrrectly calling it "Playground" (the old IDE).
15+
- Original option EnablePlaygroundWebApp is now deprecated as obsolete and will be removed in a future release; use EnableBananaCakePop instead.
16+
- Default route is now /graphql/bcp/ instead of /graphql/playground.
17+
- Otherwise there are no other breaking changes other than IDE route path.
1518

1619
Prior Releases Notes:
20+
- Bumped to HC v11.3.8
21+
- Update Nuget package for deployment of latest (last) version compatible with v11; v12 is being released today (09/28/2021)
1722
- Bumped to HC v11.0.7
1823
- Added support for download of the Schema (?SDL)
19-
- Added support for functioning Playground (when configured correctly in the Azure Function HttpTrigger &amp; Route Binding)- Added ConfigureAwait(false) to all awaits for performance.
24+
- Added support for functioning GraphQL IDE (when configured correctly in the Azure Function HttpTrigger &amp; Route Binding)
25+
- Added ConfigureAwait(false) to all awaits for performance.
2026
- Bumped to HC v11.0.4
2127
- Bump to HotChocolate v11.0.1 which now resolves a bug that we helped identify with interfaces in the initial release of v11.0.0.
2228
- Updated to support namespace changes in HotChocolate v11 rc.03 with synced version here as v11.0.0.3. Bumped HotChocolate version to v11-rc.03.
@@ -32,8 +38,8 @@ Prior Releases Notes:
3238
</ItemGroup>
3339

3440
<ItemGroup>
35-
<PackageReference Include="HotChocolate.AspNetCore" Version="11.3.8" />
36-
<PackageReference Include="HotChocolate.Data" Version="11.3.8" />
41+
<PackageReference Include="HotChocolate.AspNetCore" Version="12.0.0" />
42+
<PackageReference Include="HotChocolate.Data" Version="12.0.0" />
3743
</ItemGroup>
3844

3945
</Project>

GraphQL.AzureFunctionsProxy/GraphQLAzureFunctionsConfigOptions.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ public class GraphQLAzureFunctionsConfigOptions
88
{
99
public string AzureFunctionsRoutePath { get; set; } = "/api/graphql";
1010
public bool EnableSchemaDefinitionDownload { get; set; } = true;
11-
public bool EnablePlaygroundWebApp { get; set; } = true;
11+
12+
[Obsolete("Use EnableBananaCakePop property instead; this will be removed in future updates.")]
13+
public bool EnablePlaygroundWebApp
14+
{
15+
get => EnableBananaCakePop;
16+
set => EnableBananaCakePop = value;
17+
}
18+
19+
public bool EnableBananaCakePop { get; set; } = true;
20+
1221
public bool EnableGETRequests { get; set; } = true;
1322
}
1423
}

GraphQL.AzureFunctionsProxy/GraphQLAzureFunctionsMiddlewareProxy.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private MiddlewareBase ConfigureMiddlewareChainOfResponsibility()
8282
//BBernard - Initialize the middleware proxy and pipeline with support for both Http GET & POST processing...
8383
//NOTE: Middleware uses the Pipeline Pattern (e.g. Chain Of Responsibility), therefore
8484
// we adapt that here to manually build up the key middleware handlers for Http Get & Http Post processing.
85-
//NOTE: Other key features such as Schema download and the Playground (Banana Cake Pop Dynamic UI) are all
85+
//NOTE: Other key features such as Schema download and the GraphQL IDE (Banana Cake Pop Dynamic UI) are all
8686
// delivered by other Middleware also.
8787
//NOTE: Middleware MUST be configured in the correct order of dependency to support the functionality and
8888
// the chain of responsibility is executed inside-out; or last registered middleware will run first and
@@ -109,7 +109,7 @@ private MiddlewareBase ConfigureMiddlewareChainOfResponsibility()
109109
this.MiddlewareProxyDelegate = (httpContext) => httpGetMiddlewareShim.InvokeAsync(httpContext);
110110
}
111111

112-
if (Options.EnablePlaygroundWebApp)
112+
if (Options.EnableBananaCakePop)
113113
{
114114
var toolStaticFileMiddlewareShim = new ToolStaticFileMiddleware(
115115
this.MiddlewareProxyDelegate,
@@ -119,10 +119,8 @@ private MiddlewareBase ConfigureMiddlewareChainOfResponsibility()
119119
this.MiddlewareProxyDelegate = (httpContext) => toolStaticFileMiddlewareShim.Invoke(httpContext);
120120

121121
var toolOptionsFileMiddlewareShim = new ToolOptionsFileMiddleware(
122+
//New for v12 The Constructor for this Middleware is simplified and no longer requires the injection of GraphQL dependencies because it's simply a File Handler for BCP
122123
this.MiddlewareProxyDelegate,
123-
this.ExecutorResolver,
124-
this.ResultSerializer,
125-
this.SchemaName,
126124
this.RoutePath
127125
);
128126
this.MiddlewareProxyDelegate = (httpContext) => toolOptionsFileMiddlewareShim.Invoke(httpContext);
@@ -141,7 +139,9 @@ private MiddlewareBase ConfigureMiddlewareChainOfResponsibility()
141139
this.MiddlewareProxyDelegate,
142140
this.ExecutorResolver,
143141
this.ResultSerializer,
144-
this.SchemaName
142+
this.SchemaName,
143+
//New v12 parameter set to Integrated to enable integrated/default functionality (compatible with v11 behavior).
144+
MiddlewareRoutingType.Integrated
145145
);
146146
this.MiddlewareProxyDelegate = (httpContext) => httpGetSchemaMiddlewareShim.InvokeAsync(httpContext);
147147
}
@@ -175,7 +175,7 @@ public virtual Task InvokeAsync(HttpContext httpContext)
175175

176176
/// <summary>
177177
/// Internal helper to retrieve the current Error handler needed for Error processing.
178-
/// Matches logic used by existing HttpPostMiddlware.
178+
/// Matches logic used by existing HttpPostMiddleware.
179179
/// </summary>
180180
/// <returns></returns>
181181
public virtual async Task<IErrorHandler> GetErrorHandlerAsync(CancellationToken cancellationToken)
@@ -192,7 +192,7 @@ public virtual async Task<IErrorHandler> GetErrorHandlerAsync(CancellationToken
192192
/// Borrowed this code to make error handling easier for writing errors to the Response
193193
/// in the same way that the existing Http Get/Post Middleware does.
194194
///
195-
/// NOTE: Attempted to inherit from HttpPostMiddlware to expose existing method, but due to
195+
/// NOTE: Attempted to inherit from HttpPostMiddleware to expose existing method, but due to
196196
/// constructor chaining order of processing and next() pipeline references being private in
197197
/// the base class, it wasn't effectively possible without resorting to brute-force reflection,
198198
/// so we duplicate some small amount of code here to provide the same Write logic for writing

PureCodeFirst-AzureFunctions-v11/Characters/ICharacter.cs

-10
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ namespace StarWars.Characters
1010
[InterfaceType(Name = "Character")]
1111
public interface ICharacter : ISearchResult
1212
{
13-
/// <summary>
14-
/// The unique identifier for the character.
15-
/// </summary>
16-
int Id { get; }
17-
18-
/// <summary>
19-
/// The name of the character.
20-
/// </summary>
21-
string Name { get; }
22-
2313
/// <summary>
2414
/// The ids of the character's friends.
2515
/// </summary>

PureCodeFirst-AzureFunctions-v11/Characters/ISearchResult.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22

33
namespace StarWars.Characters
44
{
5-
[UnionType(Name = "SearchResult")]
5+
[InterfaceType(Name = "SearchResult")]
66
public interface ISearchResult
77
{
8+
/// <summary>
9+
/// The unique identifier for the character.
10+
/// </summary>
11+
int Id { get; }
12+
13+
/// <summary>
14+
/// The name of the character.
15+
/// </summary>
16+
string Name { get; }
817
}
918
}

PureCodeFirst-AzureFunctions-v11/GraphQLPlaygroundEndpoint.cs renamed to PureCodeFirst-AzureFunctions-v11/GraphQLBananaCakePopIDEEndpoint.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,30 @@ namespace StarWars.AzureFunctions
1818
/// NOTE: This class is not marked as static so that .Net Core DI handles injecting
1919
/// the Executor Proxy for us.
2020
/// </summary>
21-
public class GraphQLPlaygroundEndpoint
21+
public class GraphQLBananaCakePopEndpoint
2222
{
2323
private readonly IGraphQLAzureFunctionsExecutorProxy _graphQLExecutorProxy;
2424

25-
public GraphQLPlaygroundEndpoint(IGraphQLAzureFunctionsExecutorProxy graphQLExecutorProxy)
25+
public GraphQLBananaCakePopEndpoint(IGraphQLAzureFunctionsExecutorProxy graphQLExecutorProxy)
2626
{
2727
_graphQLExecutorProxy = graphQLExecutorProxy;
2828
}
2929

30-
[FunctionName(nameof(GraphQLPlaygroundEndpoint))]
30+
[FunctionName(nameof(GraphQLBananaCakePopEndpoint))]
3131
public async Task<IActionResult> Run(
32-
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "graphql/playground/{*path}")] HttpRequest req,
32+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "graphql/bcp/{*path}")] HttpRequest req,
3333
ILogger logger,
3434
CancellationToken cancellationToken
3535
)
3636
{
3737
logger.LogInformation("C# GraphQL Request processing via Serverless AzureFunctions...");
3838

3939
//SECURE this endpoint against actual Data Queries
40-
// This is useful for exposing the playground anonymously, but keeping the actual GraphQL data endpoint
40+
// This is useful for exposing the GraphQL IDE (Banana Cake Pop) anonymously, but keeping the actual GraphQL data endpoint
4141
// secured with AzureFunction token security and/or other authorization approach.
4242
if (HttpMethods.IsPost(req.Method) || (HttpMethods.IsGet(req.Method) && !string.IsNullOrWhiteSpace(req.Query["query"])))
4343
{
44-
return new BadRequestErrorMessageResult("POST or GET GraphQL queries are invalid for the Playground endpoint.");
44+
return new BadRequestErrorMessageResult("POST or GET GraphQL queries are invalid for the GraphQL IDE endpoint.");
4545
}
4646

4747
return await _graphQLExecutorProxy.ExecuteFunctionsQueryAsync(

PureCodeFirst-AzureFunctions-v11/Repositories/CharacterRepository.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,15 @@ public ICharacter GetHero(Episode episode)
4545
public IEnumerable<ISearchResult> Search(string text)
4646
{
4747
IEnumerable<ICharacter> filteredCharacters = _characters.Values
48-
.Where(t => t.Name.Contains(text,
49-
StringComparison.OrdinalIgnoreCase));
48+
.Where(t => t.Name.Contains(text, StringComparison.OrdinalIgnoreCase));
5049

5150
foreach (ICharacter character in filteredCharacters)
5251
{
5352
yield return character;
5453
}
5554

5655
IEnumerable<Starship> filteredStarships = _starships.Values
57-
.Where(t => t.Name.Contains(text,
58-
StringComparison.OrdinalIgnoreCase));
56+
.Where(t => t.Name.Contains(text, StringComparison.OrdinalIgnoreCase));
5957

6058
foreach (Starship starship in filteredStarships)
6159
{

PureCodeFirst-AzureFunctions-v11/Startup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public override void Configure(IFunctionsHostBuilder builder)
5858
//The Path must match the exact routing path that the Azure Function HttpTrigger is bound to.
5959
//NOTE: ThIs includes the /api/ prefix unless it was specifically removed or changed in the host.json file.
6060
//NOTE: THe default value is `/api/graphql`, but it's being done here to illustrate how to set the value.
61-
options.AzureFunctionsRoutePath = "/api/graphql/playground";
61+
options.AzureFunctionsRoutePath = "/api/graphql/bcp";
6262
});
6363
}
6464
}

0 commit comments

Comments
 (0)