Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency apollographql.hotchocolate.federation to v1 #13

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Oct 24, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
ApolloGraphQL.HotChocolate.Federation 0.3.0 -> 1.0.0 age adoption passing confidence

Release Notes

apollographql/federation-hotchocolate (ApolloGraphQL.HotChocolate.Federation)

v1.0.0

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

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@dylan-apollo dylan-apollo merged commit a6c758f into main Oct 24, 2023
3 checks passed
@dylan-apollo dylan-apollo deleted the renovate/major-apollo-graphql-packages branch October 24, 2023 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant