Markind.HotChocolate.AzureFunctions.IsolatedProcess 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Markind.HotChocolate.AzureFunctions.IsolatedProcess --version 0.0.1                
NuGet\Install-Package Markind.HotChocolate.AzureFunctions.IsolatedProcess -Version 0.0.1                
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.IsolatedProcess" Version="0.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Markind.HotChocolate.AzureFunctions.IsolatedProcess --version 0.0.1                
#r "nuget: Markind.HotChocolate.AzureFunctions.IsolatedProcess, 0.0.1"                
#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.IsolatedProcess as a Cake Addin
#addin nuget:?package=Markind.HotChocolate.AzureFunctions.IsolatedProcess&version=0.0.1

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

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 Isolated Process

Install

dotnet add package Markind.HotChocolate.AzureFunctions.IsolatedProcess

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

Program

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureServices(s =>{
        s.AddGraphQLServer("persons") // schema 1
        .AddQueryType<Query>();

        s.AddGraphQLServer("persons2") // schema 2 , etc.
        .AddQueryType<Query2>();
    })
    .AddGraphQLFunctions()// Add support for Azure FunctionS
    .Build();

host.Run();

Similarly if using Startup.cs

Function

Again make sure to use IMultiSchemaRequestExecutor.

public class GraphQLFunction
{
    private readonly IMultiSchemaRequestExecutor _executor;

    public GraphQLFunction(IMultiSchemaRequestExecutor executor)
    {
        _executor = executor;
    }

    [Function("GraphQLHttpFunction")]
    public Task<HttpResponseData> Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "persons/{**slug}")]
        HttpRequestData request)
        => _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.IsolatedProcess

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.2 821 10/18/2022
0.0.1 854 10/17/2022