-
-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue with predicates and selectors in generated DataLoader. (#…
- Loading branch information
1 parent
6df0802
commit 8be6806
Showing
5 changed files
with
314 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...erTests.GenerateSource_BatchDataLoader_With_PredicateBuilder_MatchesSnapshot.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# GenerateSource_BatchDataLoader_With_PredicateBuilder_MatchesSnapshot | ||
|
||
## GreenDonutDataLoader.735550c.g.cs | ||
|
||
```csharp | ||
// <auto-generated/> | ||
#nullable enable | ||
#pragma warning disable | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using GreenDonut; | ||
|
||
namespace TestNamespace | ||
{ | ||
public interface IEntityByIdDataLoader | ||
: global::GreenDonut.IDataLoader<int, string> | ||
{ | ||
} | ||
|
||
public sealed class EntityByIdDataLoader | ||
: global::GreenDonut.DataLoaderBase<int, string> | ||
, IEntityByIdDataLoader | ||
{ | ||
private readonly global::System.IServiceProvider _services; | ||
|
||
public EntityByIdDataLoader( | ||
global::System.IServiceProvider services, | ||
global::GreenDonut.IBatchScheduler batchScheduler, | ||
global::GreenDonut.DataLoaderOptions options) | ||
: base(batchScheduler, options) | ||
{ | ||
_services = services ?? | ||
throw new global::System.ArgumentNullException(nameof(services)); | ||
} | ||
|
||
protected override async global::System.Threading.Tasks.ValueTask FetchAsync( | ||
global::System.Collections.Generic.IReadOnlyList<int> keys, | ||
global::System.Memory<GreenDonut.Result<string?>> results, | ||
global::GreenDonut.DataLoaderFetchContext<string> context, | ||
global::System.Threading.CancellationToken ct) | ||
{ | ||
var p1 = context.GetState<global::GreenDonut.Predicates.IPredicateBuilder>("GreenDonut.Predicates.IPredicateBuilder") | ||
?? new global::GreenDonut.Predicates.DefaultPredicateBuilder(); | ||
var temp = await TestNamespace.TestClass.GetEntityByIdAsync(keys, p1, ct).ConfigureAwait(false); | ||
CopyResults(keys, results.Span, temp); | ||
} | ||
|
||
private void CopyResults( | ||
global::System.Collections.Generic.IReadOnlyList<int> keys, | ||
global::System.Span<GreenDonut.Result<string?>> results, | ||
global::System.Collections.Generic.IDictionary<int, string> resultMap) | ||
{ | ||
for (var i = 0; i < keys.Count; i++) | ||
{ | ||
var key = keys[i]; | ||
if (resultMap.TryGetValue(key, out var value)) | ||
{ | ||
results[i] = global::GreenDonut.Result<string?>.Resolve(value); | ||
} | ||
else | ||
{ | ||
results[i] = global::GreenDonut.Result<string?>.Resolve(default(string)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
``` | ||
|
||
## HotChocolateTypeModule.735550c.g.cs | ||
|
||
```csharp | ||
// <auto-generated/> | ||
#nullable enable | ||
#pragma warning disable | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using HotChocolate; | ||
using HotChocolate.Types; | ||
using HotChocolate.Execution.Configuration; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
public static partial class TestsTypesRequestExecutorBuilderExtensions | ||
{ | ||
public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) | ||
{ | ||
builder.AddDataLoader<global::TestNamespace.IEntityByIdDataLoader, global::TestNamespace.EntityByIdDataLoader>(); | ||
return builder; | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
## Compilation Diagnostics | ||
|
||
```json | ||
[ | ||
{ | ||
"Id": "GD0002", | ||
"Title": "Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", | ||
"Severity": "Error", | ||
"WarningLevel": 0, | ||
"Location": ": (13,8)-(13,47)", | ||
"HelpLinkUri": "https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS9204)", | ||
"MessageFormat": "'{0}' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", | ||
"Message": "'GreenDonut.Predicates.IPredicateBuilder' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", | ||
"Category": "Compiler", | ||
"CustomTags": [ | ||
"Compiler", | ||
"Telemetry", | ||
"CustomObsolete" | ||
] | ||
} | ||
] | ||
``` | ||
|
125 changes: 125 additions & 0 deletions
125
...derTests.GenerateSource_BatchDataLoader_With_SelectorBuilder_MatchesSnapshot.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# GenerateSource_BatchDataLoader_With_SelectorBuilder_MatchesSnapshot | ||
|
||
## GreenDonutDataLoader.735550c.g.cs | ||
|
||
```csharp | ||
// <auto-generated/> | ||
#nullable enable | ||
#pragma warning disable | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using GreenDonut; | ||
|
||
namespace TestNamespace | ||
{ | ||
public interface IEntityByIdDataLoader | ||
: global::GreenDonut.IDataLoader<int, string> | ||
{ | ||
} | ||
|
||
public sealed class EntityByIdDataLoader | ||
: global::GreenDonut.DataLoaderBase<int, string> | ||
, IEntityByIdDataLoader | ||
{ | ||
private readonly global::System.IServiceProvider _services; | ||
|
||
public EntityByIdDataLoader( | ||
global::System.IServiceProvider services, | ||
global::GreenDonut.IBatchScheduler batchScheduler, | ||
global::GreenDonut.DataLoaderOptions options) | ||
: base(batchScheduler, options) | ||
{ | ||
_services = services ?? | ||
throw new global::System.ArgumentNullException(nameof(services)); | ||
} | ||
|
||
protected override async global::System.Threading.Tasks.ValueTask FetchAsync( | ||
global::System.Collections.Generic.IReadOnlyList<int> keys, | ||
global::System.Memory<GreenDonut.Result<string?>> results, | ||
global::GreenDonut.DataLoaderFetchContext<string> context, | ||
global::System.Threading.CancellationToken ct) | ||
{ | ||
var p1 = context.GetState<global::GreenDonut.Selectors.ISelectorBuilder>("GreenDonut.Selectors.ISelectorBuilder") | ||
?? new global::GreenDonut.Selectors.DefaultSelectorBuilder(); | ||
var temp = await TestNamespace.TestClass.GetEntityByIdAsync(keys, p1, ct).ConfigureAwait(false); | ||
CopyResults(keys, results.Span, temp); | ||
} | ||
|
||
private void CopyResults( | ||
global::System.Collections.Generic.IReadOnlyList<int> keys, | ||
global::System.Span<GreenDonut.Result<string?>> results, | ||
global::System.Collections.Generic.IDictionary<int, string> resultMap) | ||
{ | ||
for (var i = 0; i < keys.Count; i++) | ||
{ | ||
var key = keys[i]; | ||
if (resultMap.TryGetValue(key, out var value)) | ||
{ | ||
results[i] = global::GreenDonut.Result<string?>.Resolve(value); | ||
} | ||
else | ||
{ | ||
results[i] = global::GreenDonut.Result<string?>.Resolve(default(string)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
``` | ||
|
||
## HotChocolateTypeModule.735550c.g.cs | ||
|
||
```csharp | ||
// <auto-generated/> | ||
#nullable enable | ||
#pragma warning disable | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using HotChocolate; | ||
using HotChocolate.Types; | ||
using HotChocolate.Execution.Configuration; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
public static partial class TestsTypesRequestExecutorBuilderExtensions | ||
{ | ||
public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) | ||
{ | ||
builder.AddDataLoader<global::TestNamespace.IEntityByIdDataLoader, global::TestNamespace.EntityByIdDataLoader>(); | ||
return builder; | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
## Compilation Diagnostics | ||
|
||
```json | ||
[ | ||
{ | ||
"Id": "GD0001", | ||
"Title": "Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", | ||
"Severity": "Error", | ||
"WarningLevel": 0, | ||
"Location": ": (13,8)-(13,45)", | ||
"HelpLinkUri": "https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS9204)", | ||
"MessageFormat": "'{0}' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", | ||
"Message": "'GreenDonut.Selectors.ISelectorBuilder' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", | ||
"Category": "Compiler", | ||
"CustomTags": [ | ||
"Compiler", | ||
"Telemetry", | ||
"CustomObsolete" | ||
] | ||
} | ||
] | ||
``` | ||
|