Skip to content

Commit

Permalink
Migrated Legacy Stitching to Version 13 (#5537)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Dec 1, 2022
1 parent 4f49949 commit fae7aa7
Show file tree
Hide file tree
Showing 550 changed files with 34,014 additions and 512 deletions.
Expand Up @@ -44,11 +44,7 @@ public static class HotChocolateAuthorizeRequestExecutorBuilder
var jsonOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
#if NET5_0_OR_GREATER
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
#else
IgnoreNullValues = true
#endif
};
jsonOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase, false));
o.JsonSerializerOptions = jsonOptions;
Expand Down
Expand Up @@ -25,11 +25,9 @@ private static async Task Run()

Console.WriteLine("Warmup 1");
await queryBench.Sessions_DataLoader_Large().ConfigureAwait(false);
;

Console.WriteLine("Warmup 2");
await queryBench.Sessions_DataLoader_Large().ConfigureAwait(false);
;

Console.WriteLine("Run");

Expand Down
Expand Up @@ -138,7 +138,7 @@ public Task LargeQueryFiveParallelRequests()
}

// var jsonWriter = new HotChocolate.Execution.Serialization.JsonQueryResultSerializer(true);
// Console.WriteLine(jsonWriter.Serialize((IReadOnlyQueryResult)result));
// Console.WriteLine(jsonWriter.Serialize((IQueryResult)result));
await result.DisposeAsync();
}

Expand Down
203 changes: 0 additions & 203 deletions src/HotChocolate/Core/src/Abstractions/NameString.cs.txt

This file was deleted.

Expand Up @@ -74,7 +74,7 @@ public static class ExecutionRequestExecutorExtensions
public static Task<IExecutionResult> ExecuteAsync(
this IRequestExecutor executor,
string query,
IReadOnlyDictionary<string, object?> variableValues)
Dictionary<string, object?> variableValues)
{
if (executor is null)
{
Expand Down
9 changes: 7 additions & 2 deletions src/HotChocolate/Core/src/Execution/Processing/Selection.cs
Expand Up @@ -6,6 +6,7 @@
using HotChocolate.Language;
using HotChocolate.Resolvers;
using HotChocolate.Types;
using Microsoft.Extensions.ObjectPool;

namespace HotChocolate.Execution.Processing;

Expand Down Expand Up @@ -46,7 +47,9 @@ public class Selection : ISelection

_includeConditions = includeConditions ?? Array.Empty<long>();

_flags = isInternal ? Flags.Internal : Flags.None;
_flags = isInternal
? Flags.Internal
: Flags.None;

if (Type.IsListType())
{
Expand Down Expand Up @@ -162,6 +165,7 @@ public bool IsIncluded(long includeFlags, bool allowInternals = false)
// if there are flags in most cases we just have one so we can
// check the first and optimize for this.
var includeCondition = _includeConditions[0];

if ((includeFlags & includeCondition) == includeCondition)
{
return !IsInternal || allowInternals;
Expand All @@ -177,6 +181,7 @@ public bool IsIncluded(long includeFlags, bool allowInternals = false)
for (var i = 1; i < _includeConditions.Length; i++)
{
includeCondition = _includeConditions[i];

if ((includeFlags & includeCondition) == includeCondition)
{
return !IsInternal || allowInternals;
Expand Down Expand Up @@ -247,7 +252,7 @@ internal void AddSelection(FieldNode selectionSyntax, long includeCondition = 0)
{
var selections = new ISelectionNode[
selectionSet.Selections.Count +
other.SelectionSet.Selections.Count];
other.SelectionSet.Selections.Count];
var next = 0;

for (var i = 0; i < selectionSet.Selections.Count; i++)
Expand Down
Expand Up @@ -2,4 +2,5 @@

[assembly: InternalsVisibleTo("HotChocolate.Execution.Tests")]
[assembly: InternalsVisibleTo("HotChocolate.Execution.Benchmarks")]
[assembly: InternalsVisibleTo("HotChocolate.Stitching")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
Expand Up @@ -7,6 +7,7 @@

namespace HotChocolate.Fetching;

// ReSharper disable once ClassNeverInstantiated.Global
public sealed class DataLoaderParameterExpressionBuilder : CustomParameterExpressionBuilder
{
private static readonly MethodInfo _dataLoader;
Expand All @@ -29,7 +30,7 @@ public override bool CanHandle(ParameterInfo parameter)

public override Expression Build(ParameterInfo parameter, Expression context)
{
DataLoaderAttribute? attribute = parameter.GetCustomAttribute<DataLoaderAttribute>();
var attribute = parameter.GetCustomAttribute<DataLoaderAttribute>();

return string.IsNullOrEmpty(attribute?.Key)
? Expression.Call(
Expand Down
Expand Up @@ -10,6 +10,7 @@

#nullable enable

// ReSharper disable once CheckNamespace
namespace HotChocolate.Types;

public static class DataLoaderResolverContextExtensions
Expand Down Expand Up @@ -74,8 +75,8 @@ public static class DataLoaderResolverContextExtensions
throw new ArgumentNullException(nameof(fetch));
}

IServiceProvider services = context.Services;
IDataLoaderRegistry reg = services.GetRequiredService<IDataLoaderRegistry>();
var services = context.Services;
var reg = services.GetRequiredService<IDataLoaderRegistry>();
FetchBatchDataLoader<TKey, TValue> Loader()
=> new(
dataLoaderName ?? "default",
Expand Down Expand Up @@ -180,8 +181,8 @@ public static class DataLoaderResolverContextExtensions
throw new ArgumentNullException(nameof(fetch));
}

IServiceProvider services = context.Services;
IDataLoaderRegistry reg = services.GetRequiredService<IDataLoaderRegistry>();
var services = context.Services;
var reg = services.GetRequiredService<IDataLoaderRegistry>();
FetchGroupedDataLoader<TKey, TValue> Loader()
=> new(
dataLoaderName ?? "default",
Expand Down Expand Up @@ -271,8 +272,8 @@ public static class DataLoaderResolverContextExtensions
throw new ArgumentNullException(nameof(fetch));
}

IServiceProvider services = context.Services;
IDataLoaderRegistry reg = services.GetRequiredService<IDataLoaderRegistry>();
var services = context.Services;
var reg = services.GetRequiredService<IDataLoaderRegistry>();
FetchCacheDataLoader<TKey, TValue> Loader()
=> new(
key ?? "default",
Expand Down Expand Up @@ -359,8 +360,8 @@ public static T DataLoader<T>(this IResolverContext context, string key)
throw new ArgumentNullException(nameof(key));
}

IServiceProvider services = context.Services;
IDataLoaderRegistry reg = services.GetRequiredService<IDataLoaderRegistry>();
var services = context.Services;
var reg = services.GetRequiredService<IDataLoaderRegistry>();
return reg.GetOrRegister(key, () => CreateDataLoader<T>(services));
}

Expand All @@ -373,15 +374,15 @@ public static T DataLoader<T>(this IResolverContext context)
throw new ArgumentNullException(nameof(context));
}

IServiceProvider services = context.Services;
IDataLoaderRegistry reg = services.GetRequiredService<IDataLoaderRegistry>();
var services = context.Services;
var reg = services.GetRequiredService<IDataLoaderRegistry>();
return reg.GetOrRegister(() => CreateDataLoader<T>(services));
}

private static T CreateDataLoader<T>(IServiceProvider services)
where T : IDataLoader
{
T registeredDataLoader = services.GetService<T>();
var registeredDataLoader = services.GetService<T>();

if (registeredDataLoader is null)
{
Expand Down

0 comments on commit fae7aa7

Please sign in to comment.