Skip to content

Commit e2308ce

Browse files
authored
Add support for apollo federation v2.6 and v2.7 (#6864)
1 parent 2013cb6 commit e2308ce

37 files changed

+975
-222
lines changed

src/HotChocolate/ApolloFederation/src/ApolloFederation/Extensions/ApolloFederationRequestExecutorBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static class ApolloFederationRequestExecutorBuilderExtensions
2727
/// </exception>
2828
public static IRequestExecutorBuilder AddApolloFederation(
2929
this IRequestExecutorBuilder builder,
30-
FederationVersion version = FederationVersion.Latest)
30+
FederationVersion version = FederationVersion.Default)
3131
{
3232
ArgumentNullException.ThrowIfNull(builder);
3333
builder.SetContextData(FederationContextData.FederationVersion, version);

src/HotChocolate/ApolloFederation/src/ApolloFederation/Extensions/FederationVersionExtensions.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ [new Uri(FederationVersionUrls.Federation22)] = FederationVersion.Federation22,
1414
[new Uri(FederationVersionUrls.Federation23)] = FederationVersion.Federation23,
1515
[new Uri(FederationVersionUrls.Federation24)] = FederationVersion.Federation24,
1616
[new Uri(FederationVersionUrls.Federation25)] = FederationVersion.Federation25,
17+
[new Uri(FederationVersionUrls.Federation26)] = FederationVersion.Federation26,
18+
[new Uri(FederationVersionUrls.Federation27)] = FederationVersion.Federation27,
1719
};
18-
20+
1921
private static readonly Dictionary<FederationVersion, Uri> _versionToUri = new()
2022
{
2123
[FederationVersion.Federation20] = new(FederationVersionUrls.Federation20),
@@ -24,8 +26,10 @@ [new Uri(FederationVersionUrls.Federation25)] = FederationVersion.Federation25,
2426
[FederationVersion.Federation23] = new(FederationVersionUrls.Federation23),
2527
[FederationVersion.Federation24] = new(FederationVersionUrls.Federation24),
2628
[FederationVersion.Federation25] = new(FederationVersionUrls.Federation25),
29+
[FederationVersion.Federation26] = new(FederationVersionUrls.Federation26),
30+
[FederationVersion.Federation27] = new(FederationVersionUrls.Federation27),
2731
};
28-
32+
2933
public static FederationVersion GetFederationVersion<T>(
3034
this IDescriptor<T> descriptor)
3135
where T : DefinitionBase
@@ -40,7 +44,7 @@ public static FederationVersion GetFederationVersion<T>(
4044
// TODO : resources
4145
throw new InvalidOperationException("The configuration state is invalid.");
4246
}
43-
47+
4448
public static FederationVersion GetFederationVersion(
4549
this IDescriptorContext context)
4650
{
@@ -56,26 +60,26 @@ public static FederationVersion GetFederationVersion(
5660

5761
public static Uri ToUrl(this FederationVersion version)
5862
{
59-
if(_versionToUri.TryGetValue(version, out var url))
63+
if (_versionToUri.TryGetValue(version, out var url))
6064
{
6165
return url;
6266
}
63-
67+
6468
// TODO : resources
6569
throw new ArgumentException("The federation version is not supported.", nameof(version));
6670
}
67-
71+
6872
public static FederationVersion ToVersion(this Uri url)
6973
{
70-
if(_uriToVersion.TryGetValue(url, out var version))
74+
if (_uriToVersion.TryGetValue(url, out var version))
7175
{
7276
return version;
7377
}
74-
78+
7579
// TODO : resources
7680
throw new ArgumentException("The federation url is not supported.", nameof(url));
7781
}
78-
82+
7983
public static bool TryToVersion(this Uri url, out FederationVersion version)
8084
=> _uriToVersion.TryGetValue(url, out version);
81-
}
85+
}

src/HotChocolate/ApolloFederation/src/ApolloFederation/FederationTypeNames.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ internal static class FederationTypeNames
1212
public const string KeyDirective_Name = "key";
1313
public const string LinkDirective_Name = "link";
1414
public const string OverrideDirective_Name = "override";
15+
public const string PolicyDirective_Name = "policy";
1516
public const string ProvidesDirective_Name = "provides";
1617
public const string RequiresDirective_Name = "requires";
1718
public const string RequiresScopesDirective_Name = "requiresScopes";
1819
public const string ShareableDirective_Name = "shareable";
1920
public const string FieldSetType_Name = "FieldSet";
2021
public const string ScopeType_Name = "Scope";
22+
public const string PolicyType_Name = "Policy";
2123
public const string AnyType_Name = "_Any";
2224
public const string EntityType_Name = "_Entity";
2325
public const string ServiceType_Name = "_Service";
24-
}
26+
}

src/HotChocolate/ApolloFederation/src/ApolloFederation/FederationVersion.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public enum FederationVersion
1313
Federation23 = 2_3,
1414
Federation24 = 2_4,
1515
Federation25 = 2_5,
16-
// Federation26 = 2_6,
17-
Latest = Federation25,
18-
}
16+
Federation26 = 2_6,
17+
Federation27 = 2_7,
18+
// default to latest-1
19+
Default = Federation26,
20+
Latest = Federation27
21+
}

src/HotChocolate/ApolloFederation/src/ApolloFederation/FederationVersionUrls.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ internal static class FederationVersionUrls
88
public const string Federation23 = "https://specs.apollo.dev/federation/v2.3";
99
public const string Federation24 = "https://specs.apollo.dev/federation/v2.4";
1010
public const string Federation25 = "https://specs.apollo.dev/federation/v2.5";
11-
}
11+
public const string Federation26 = "https://specs.apollo.dev/federation/v2.6";
12+
public const string Federation27 = "https://specs.apollo.dev/federation/v2.7";
13+
}

0 commit comments

Comments
 (0)