Skip to content

Commit 70ca8ef

Browse files
drowhuntermichaelstaib
authored andcommitted
Add missing non-generic dataloader configration extensions (#383)
1 parent 91e3924 commit 70ca8ef

File tree

2 files changed

+67
-23
lines changed

2 files changed

+67
-23
lines changed

src/Core/DataLoaderConfigurationExtensions.cs

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@ public static void RegisterDataLoader<TLoader>(
1313
Func<IServiceProvider, TLoader> loaderFactory)
1414
where TLoader : IDispatchableDataLoader
1515
{
16-
configuration.RegisterDataLoader<TLoader>(
17-
key, scope, loaderFactory,
18-
(d, c) => d.DispatchAsync());
16+
configuration.RegisterDataLoader<TLoader>(key, scope, loaderFactory,(d, c) => d.DispatchAsync());
17+
}
18+
19+
public static void RegisterDataLoader(
20+
this ISchemaConfiguration configuration,
21+
Type type,
22+
string key,
23+
ExecutionScope scope,
24+
Func<IServiceProvider, IDispatchableDataLoader> loaderFactory)
25+
26+
{
27+
configuration.RegisterDataLoader(type,key, scope, loaderFactory,(d, c) => ((IDispatchableDataLoader)d).DispatchAsync());
1928
}
2029

2130
public static void RegisterDataLoader<TLoader>(
@@ -24,19 +33,33 @@ public static void RegisterDataLoader<TLoader>(
2433
Func<IServiceProvider, TLoader> loaderFactory)
2534
where TLoader : IDispatchableDataLoader
2635
{
27-
RegisterDataLoader<TLoader>(
28-
configuration, typeof(TLoader).FullName,
29-
scope, loaderFactory);
36+
RegisterDataLoader<TLoader>(configuration, typeof(TLoader).FullName,scope, loaderFactory);
37+
}
38+
39+
public static void RegisterDataLoader(
40+
this ISchemaConfiguration configuration,
41+
Type type,
42+
ExecutionScope scope,
43+
Func<IServiceProvider, IDispatchableDataLoader> loaderFactory)
44+
{
45+
RegisterDataLoader(configuration, type, type.FullName, scope, loaderFactory);
3046
}
3147

3248
public static void RegisterDataLoader<TLoader>(
3349
this ISchemaConfiguration configuration,
3450
Func<IServiceProvider, TLoader> loaderFactory)
3551
where TLoader : IDispatchableDataLoader
3652
{
37-
RegisterDataLoader<TLoader>(
38-
configuration, typeof(TLoader).FullName,
39-
ExecutionScope.Request, loaderFactory);
53+
RegisterDataLoader<TLoader>(configuration, typeof(TLoader).FullName,ExecutionScope.Request, loaderFactory);
54+
}
55+
56+
public static void RegisterDataLoader(
57+
this ISchemaConfiguration configuration,
58+
Type type,
59+
Func<IServiceProvider, IDispatchableDataLoader> loaderFactory)
60+
61+
{
62+
RegisterDataLoader(configuration, type,type.FullName,ExecutionScope.Request, loaderFactory);
4063
}
4164

4265
public static void RegisterDataLoader<TLoader>(
@@ -45,28 +68,49 @@ public static void RegisterDataLoader<TLoader>(
4568
ExecutionScope scope)
4669
where TLoader : class, IDispatchableDataLoader
4770
{
48-
configuration.RegisterDataLoader<TLoader>(
49-
key, scope, triggerLoaderAsync:
50-
(d, c) => d.DispatchAsync());
71+
configuration.RegisterDataLoader<TLoader>(key, scope, triggerLoaderAsync:(d, c) => d.DispatchAsync());
72+
}
73+
74+
public static void RegisterDataLoader(
75+
this ISchemaConfiguration configuration,
76+
Type type,
77+
string key,
78+
ExecutionScope scope)
79+
80+
{
81+
configuration.RegisterDataLoader(type,key, scope, triggerLoaderAsync:(d, c) => ((IDispatchableDataLoader)d).DispatchAsync());
5182
}
5283

5384
public static void RegisterDataLoader<TLoader>(
5485
this ISchemaConfiguration configuration,
5586
ExecutionScope scope)
5687
where TLoader : class, IDispatchableDataLoader
5788
{
58-
RegisterDataLoader<TLoader>(
59-
configuration, typeof(TLoader).FullName,
60-
scope);
89+
RegisterDataLoader<TLoader>(configuration, typeof(TLoader).FullName,scope);
90+
}
91+
92+
public static void RegisterDataLoader(
93+
this ISchemaConfiguration configuration,
94+
Type type,
95+
ExecutionScope scope)
96+
97+
{
98+
RegisterDataLoader(configuration, type, type.FullName,scope);
6199
}
62100

63101
public static void RegisterDataLoader<TLoader>(
64102
this ISchemaConfiguration configuration)
65103
where TLoader : class, IDispatchableDataLoader
66104
{
67-
RegisterDataLoader<TLoader>(
68-
configuration, typeof(TLoader).FullName,
69-
ExecutionScope.Request);
105+
106+
RegisterDataLoader<TLoader>(configuration, typeof(TLoader).FullName,ExecutionScope.Request);
107+
}
108+
109+
public static void RegisterDataLoader(
110+
this ISchemaConfiguration configuration, Type type)
111+
112+
{
113+
RegisterDataLoader(configuration,type, type.FullName,ExecutionScope.Request);
70114
}
71115
}
72116
}

src/Types/Configuration/SchemaConfiguration.DataLoader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ public void RegisterDataLoader<T>(
5151
Func<T, CancellationToken, Task> triggerLoaderAsync = null)
5252
{
5353

54-
Func<IServiceProvider,object> f = null;
54+
Func<IServiceProvider,object> factory = null;
5555
if(loaderFactory != null)
56-
f = s => loaderFactory(s);
57-
Func<object,CancellationToken,Task> g = null;
56+
factory = s => loaderFactory(s);
57+
Func<object,CancellationToken,Task> trigger = null;
5858
if(triggerLoaderAsync != null)
59-
g = (a,b) => triggerLoaderAsync((T)a,b);
59+
trigger = (a,b) => triggerLoaderAsync((T)a,b);
6060

61-
RegisterDataLoader(typeof(T),key,scope,f,g);
61+
RegisterDataLoader(typeof(T),key,scope,factory,trigger);
6262

6363
}
6464
}

0 commit comments

Comments
 (0)