Skip to content

Releases: apollographql/federation-hotchocolate

v1.3.0

27 Nov 15:12
469ea61
Compare
Choose a tag to compare

Minor Changes

Patch Changes

  • chore(deps): update all non-major dependencies (#41) @renovate
  • chore(deps): update dependency microsoft.sourcelink.github to v8 (#57) @renovate

Other Changes

v1.2.1

14 Nov 16:21
e938d44
Compare
Choose a tag to compare

Patch Changes

Other Changes

v1.2.0

01 Nov 19:53
Compare
Choose a tag to compare

Minor Changes

  • feat: expose IRequestExecutorBuilder extensions to apply schema directives (#47) @dariuszkuc

Patch Changes

Other Changes

v1.1.0

26 Oct 14:07
1ef8c47
Compare
Choose a tag to compare

Minor Changes

Adds support for HotChocolate v13.6.0.

v1.0.0

24 Oct 16:56
Compare
Choose a tag to compare

Apollo Federation for HotChocolate

Apollo Federation is a powerful, open architecture that helps you create a unified supergraph that combines multiple GraphQL APIs. ApolloGraphQL.HotChocolate.Federation provides Apollo Federation support for building subgraphs in the HotChocolate ecosystem. Individual subgraphs can be run independently of each other but can also specify relationships to the other subgraphs by using Federated directives. See Apollo Federation documentation for details.

Generating Federated Schemas

ApolloGraphQL.HotChocolate.Federation package is published to Nuget. Update your .csproj file with following package references

  <ItemGroup>
    <!-- make sure to also include HotChocolate package -->
    <PackageReference Include="HotChocolate.AspNetCore" Version="13.5.1" />
    <!-- federation package -->
    <PackageReference Include="ApolloGraphQL.HotChocolate.Federation" Version="$LatestVersion" />
  </ItemGroup>

After installing the necessary packages, you need to register Apollo Federation with your GraphQL service. You need to opt-in to Federation v1 or v2 schema by invoking corresponding builder extension

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddGraphQLServer()
    // .AddApolloFederation() // use this instead if you want to opt-in to fed v1 
    .AddApolloFederationV2() 
    // register your types and services
    ;

var app = builder.Build();
app.MapGraphQL();
app.Run();

Apollo Federation requires subgraphs to provide some additional metadata to make them supergraph aware. Entities are GraphQL objects that can be uniquely identified across the supergraph by the specified @keys. Since entities can be extended by various subgraphs, we need an extra entry point to access the entities, i.e. subgraphs need to implement reference resolvers for entities that they support.

All federated directives are provided as attributes that can be applied directly on classes/fields/methods. Alternatively, if you need more granular control, you can use code first approach and manually populate federation information on the underlying GraphQL type descriptor. All federated directives expose corresponding methods on the applicable descriptor. Example attribute usage

[Key("id")]
public class Product
{
    public Product(string id, string name, string? description)
    {
        Id = id;
        Name = name;
        Description = description;
    }

    [ID]
    public string Id { get; }

    public string Name { get; }

    public string? Description { get; }

    // assumes ProductRepository with GetById method exists
    // reference resolver method must be public static
    [ReferenceResolver]
    public static Product GetByIdAsync(
        string id,
        ProductRepository productRepository)
        => productRepository.GetById(id);
}

Federation v1 directives

Federation v2 directives (includes all of the v1 directives)

Entity resolution

  • Map applicable on entity resolver method paramaters, allows you to map complex argument to a simpler representation value, e.g. [Map("foo.bar")] string bar
  • ReferenceResolver applicable on public static methods within an entity class to indicate entity resolver

v0.3.0

19 Oct 19:20
Compare
Choose a tag to compare

Minor Changes

  • feat: support @authenticated and @requiresScopes (#33) @dariuszkuc
  • feat: new AddApolloFederationV2 that accepts target version (#32) @dariuszkuc
  • feat: allow users specifying supported federation version (#23) @dariuszkuc

Other Changes

  • chore(deps): update dependency coverlet.msbuild to v6 (#31) @renovate
  • chore(deps): update dependency snapshooter.xunit to v0.13.0 (#29) @renovate
  • chore(deps): update actions/checkout action to v4 (#12) @renovate
  • chore(deps): update xunit-dotnet monorepo to v2.5.3 (#30) @renovate
  • chore(deps): update dependency moq to v4.20.69 (#28) @renovate
  • chore(deps): update dependency microsoft.net.test.sdk to v17.7.2 (#27) @renovate
  • chore(deps): update dependency coverlet.msbuild to v3.2.0 (#26) @renovate
  • chore: simplify project structure (#25) @dariuszkuc

v0.2.0

18 Oct 03:56
97674e7
Compare
Choose a tag to compare

Minor Changes

Patch Changes

  • fix: handle non-null in arg parser (#18) @dariuszkuc
  • fix federation directive attribute targets

Other Changes

v0.1.1

12 Oct 19:40
6ef10cd
Compare
Choose a tag to compare

Patch Changes

  • fix: simplify branching logic when applying fed directives (#8) @dariuszkuc
  • fix: ability to configure interface entities (#7) @dariuszkuc

v0.1.0

12 Oct 06:19
b8c82e6
Compare
Choose a tag to compare

Apollo Federation V2 Support

ApolloGraphQL.Federation.HotChocolate module now supports Apollo Federation v1 and Apollo Federation v2 subgraphs.

Federation v2 is an evolution of the Federation spec to make it more powerful, flexible and easier to adapt. While v1 and v2 schemas are similar in many ways, Federation v2 relaxes some of the constraints and adds additional capabilities. See Apollo documentation for details.

Generating Federated Schemas

You need to opt-in to Federation v1 or v2 schema by invoking corresponding builder extension

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddGraphQLServer()
    // .AddApolloFederation() // use this instead if you want to opt-in to fed v1 
    .AddApolloFederationV2() 
    // register your types and services
    ;

var app = builder.Build();
app.MapGraphQL();
app.Run();

Federation v1 Directive Attributes

Federation v2 Directive Attributes

Includes all of the v1 directive attributes.

v0.0.2

11 Oct 19:24
53c2813
Compare
Choose a tag to compare

Major/Breaking Changes

  • We changed namespace from ApolloGraphQL.HotChocolate.Federation to ApolloGraphQL.Federation.HotChocolate to better align the structure of the library for future Federation v2 support