Markind.HotChocolate.AzureFunctions 0.0.2

dotnet add package Markind.HotChocolate.AzureFunctions --version 0.0.2
NuGet\Install-Package Markind.HotChocolate.AzureFunctions -Version 0.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Markind.HotChocolate.AzureFunctions" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Markind.HotChocolate.AzureFunctions --version 0.0.2
#r "nuget: Markind.HotChocolate.AzureFunctions, 0.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Markind.HotChocolate.AzureFunctions as a Cake Addin
#addin nuget:?package=Markind.HotChocolate.AzureFunctions&version=0.0.2

// Install Markind.HotChocolate.AzureFunctions as a Cake Tool
#tool nuget:?package=Markind.HotChocolate.AzureFunctions&version=0.0.2

Multi Schema/Endpoint for HotChocolate Azure Functions.

Azure supports multiple endpoints using multiple functions, official implementation of HotChocolate (as 13.0.0-preview.66) does not yet.

I let it be as mush as possible aspnet like implementation, so we do not need to change a lot of code when coming from server project.

Azure Functions in process

Install

dotnet add package Markind.HotChocolate.AzureFunctions

Why Markind? it is the name of the company I am willing to build. It is about to left mark in the earth.

Startup

[assembly: FunctionsStartup(typeof(Startup))]

public class Startup : FunctionsStartup
{
    public override void Configure(IFunctionsHostBuilder builder)
    {
        builder.Services.AddGraphQLServer("persons") // schema 1
                        .AddQueryType<Query>();

        builder.Services.AddGraphQLServer("persons2") // schema 2, etc..
                        .AddQueryType<Query2>();

        builder.AddGraphQLFunctions(); // Add support for Azure FunctionS
    }
}

Function

Make sure to use IMultiSchemaRequestExecutor.

public class GraphQLFunction
{
    [FunctionName("GraphQLHttpFunction")]
    public Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "persons/{**slug}")] 
        HttpRequest request,
        [GraphQL] 
        IMultiSchemaRequestExecutor executor)
        => executor.ExecuteAsync(request, "persons");
}

Create the other functions and make sure to set the schema name executor.ExecuteAsync(request, "persons2");

Full sample at samples/Azf

Glad to be of help, it took me more than a week cracking my head 😂 to understand how it should work and give the easiest and smoothly solution possible. I am willing to improve it or fix issues if needed. So if you wish ❤️

Mentions

Base code is using official implementation of HotChocolate.AzureFunctions and I reviewed a lot GraphQL.AzureFunctionsProxy

Notice

This implementation has original implementation from HotChocolate.AzureFunctions as well, I made this way with the hope of integrate it in the official HotChocolate repo. Be sure to use .AddGraphQLFunctions() with s at the end, using without it you will be using original implementation that has no multi schema support.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Markind.HotChocolate.AzureFunctions:

Package Downloads
Markind.HotChocolate.AzureFunctions.IsolatedProcess

This package contains the GraphQL AzureFunctions Isolated Process integration for Hot Chocolate.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.2 523 10/18/2022
0.0.1 558 10/17/2022