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

feat[ApolloFederation]: add support for federation v2.6 and v2.7 #6864

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static class ApolloFederationRequestExecutorBuilderExtensions
/// </exception>
public static IRequestExecutorBuilder AddApolloFederation(
this IRequestExecutorBuilder builder,
FederationVersion version = FederationVersion.Latest)
FederationVersion version = FederationVersion.Default)
{
ArgumentNullException.ThrowIfNull(builder);
builder.SetContextData(FederationContextData.FederationVersion, version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ [new Uri(FederationVersionUrls.Federation22)] = FederationVersion.Federation22,
[new Uri(FederationVersionUrls.Federation23)] = FederationVersion.Federation23,
[new Uri(FederationVersionUrls.Federation24)] = FederationVersion.Federation24,
[new Uri(FederationVersionUrls.Federation25)] = FederationVersion.Federation25,
[new Uri(FederationVersionUrls.Federation26)] = FederationVersion.Federation26,
[new Uri(FederationVersionUrls.Federation27)] = FederationVersion.Federation27,
};

private static readonly Dictionary<FederationVersion, Uri> _versionToUri = new()
{
[FederationVersion.Federation20] = new(FederationVersionUrls.Federation20),
Expand All @@ -24,8 +26,10 @@ [new Uri(FederationVersionUrls.Federation25)] = FederationVersion.Federation25,
[FederationVersion.Federation23] = new(FederationVersionUrls.Federation23),
[FederationVersion.Federation24] = new(FederationVersionUrls.Federation24),
[FederationVersion.Federation25] = new(FederationVersionUrls.Federation25),
[FederationVersion.Federation26] = new(FederationVersionUrls.Federation26),
[FederationVersion.Federation27] = new(FederationVersionUrls.Federation27),
};

public static FederationVersion GetFederationVersion<T>(
this IDescriptor<T> descriptor)
where T : DefinitionBase
Expand All @@ -40,7 +44,7 @@ public static FederationVersion GetFederationVersion<T>(
// TODO : resources
throw new InvalidOperationException("The configuration state is invalid.");
}

public static FederationVersion GetFederationVersion(
this IDescriptorContext context)
{
Expand All @@ -56,26 +60,26 @@ public static FederationVersion GetFederationVersion(

public static Uri ToUrl(this FederationVersion version)
{
if(_versionToUri.TryGetValue(version, out var url))
if (_versionToUri.TryGetValue(version, out var url))
{
return url;
}

// TODO : resources
throw new ArgumentException("The federation version is not supported.", nameof(version));
}

public static FederationVersion ToVersion(this Uri url)
{
if(_uriToVersion.TryGetValue(url, out var version))
if (_uriToVersion.TryGetValue(url, out var version))
{
return version;
}

// TODO : resources
throw new ArgumentException("The federation url is not supported.", nameof(url));
}

public static bool TryToVersion(this Uri url, out FederationVersion version)
=> _uriToVersion.TryGetValue(url, out version);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ internal static class FederationTypeNames
public const string KeyDirective_Name = "key";
public const string LinkDirective_Name = "link";
public const string OverrideDirective_Name = "override";
public const string PolicyDirective_Name = "policy";
public const string ProvidesDirective_Name = "provides";
public const string RequiresDirective_Name = "requires";
public const string RequiresScopesDirective_Name = "requiresScopes";
public const string ShareableDirective_Name = "shareable";
public const string FieldSetType_Name = "FieldSet";
public const string ScopeType_Name = "Scope";
public const string PolicyType_Name = "Policy";
public const string AnyType_Name = "_Any";
public const string EntityType_Name = "_Entity";
public const string ServiceType_Name = "_Service";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public enum FederationVersion
Federation23 = 2_3,
Federation24 = 2_4,
Federation25 = 2_5,
// Federation26 = 2_6,
Latest = Federation25,
}
Federation26 = 2_6,
Federation27 = 2_7,
// default to latest-1
dariuszkuc marked this conversation as resolved.
Show resolved Hide resolved
Default = Federation26,
Latest = Federation27
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ internal static class FederationVersionUrls
public const string Federation23 = "https://specs.apollo.dev/federation/v2.3";
public const string Federation24 = "https://specs.apollo.dev/federation/v2.4";
public const string Federation25 = "https://specs.apollo.dev/federation/v2.5";
}
public const string Federation26 = "https://specs.apollo.dev/federation/v2.6";
public const string Federation27 = "https://specs.apollo.dev/federation/v2.7";
}
Loading
Loading