Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7c4d319

Browse files
committedSep 30, 2024·
Removed Resolve overload that doesn't capture the result type
1 parent 7270474 commit 7c4d319

File tree

4 files changed

+51
-56
lines changed

4 files changed

+51
-56
lines changed
 

‎src/HotChocolate/Core/src/Types/Types/Descriptors/Contracts/IObjectFieldDescriptor.cs

-44
Original file line numberDiff line numberDiff line change
@@ -102,50 +102,6 @@ IObjectFieldDescriptor Argument(
102102
/// </param>
103103
IObjectFieldDescriptor Ignore(bool ignore = true);
104104

105-
/// <summary>
106-
/// Adds a resolver to the field. A resolver is a method that resolves the value for a
107-
/// field. The resolver can access parent object, arguments, services and more through the
108-
/// <see cref="IResolverContext"/>.
109-
/// </summary>
110-
/// <param name="fieldResolver">The resolver of the field</param>
111-
/// <example>
112-
/// Resolver accessing the parent
113-
/// <code>
114-
/// <![CDATA[
115-
/// descriptor
116-
/// .Field(x => x.Foo)
117-
/// .Resolve(context => context.Parent<Example>().Foo);
118-
/// ]]>
119-
/// </code>
120-
/// Resolver with static value
121-
/// <code>
122-
/// <![CDATA[
123-
/// descriptor
124-
/// .Field(x => x.Foo)
125-
/// .Resolve("Static Value");
126-
/// ]]>
127-
/// </code>
128-
/// Resolver accessing service
129-
/// <code>
130-
/// <![CDATA[
131-
/// descriptor
132-
/// .Field(x => x.Foo)
133-
/// .Resolve(context => context.Service<ISomeService>().GetFoo());
134-
/// ]]>
135-
/// </code>
136-
/// Resolver accessing argument
137-
/// <code>
138-
/// <![CDATA[
139-
/// descriptor
140-
/// .Field(x => x.Foo)
141-
/// .Argument("arg1", x => x.Type<StringType>())
142-
/// .Resolve(context => context.ArgumentValue<string>("arg1"));
143-
/// ]]>
144-
/// </code>
145-
/// </example>
146-
/// <returns></returns>
147-
IObjectFieldDescriptor Resolve(FieldResolverDelegate fieldResolver);
148-
149105
/// <summary>
150106
/// Adds a resolver to the field. A resolver is a method that resolves the value for a
151107
/// field. The resolver can access parent object, arguments, services and more through the

‎src/HotChocolate/Core/src/Types/Types/Descriptors/ObjectFieldDescriptor.cs

-12
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,6 @@ public IObjectFieldDescriptor StreamResult(bool hasStreamResult = true)
319319
return this;
320320
}
321321

322-
/// <inheritdoc />
323-
public IObjectFieldDescriptor Resolve(FieldResolverDelegate fieldResolver)
324-
{
325-
if (fieldResolver is null)
326-
{
327-
throw new ArgumentNullException(nameof(fieldResolver));
328-
}
329-
330-
Definition.Resolver = fieldResolver;
331-
return this;
332-
}
333-
334322
/// <inheritdoc />
335323
public IObjectFieldDescriptor Resolve(
336324
FieldResolverDelegate fieldResolver,

‎src/HotChocolate/Data/test/Data.Sorting.Tests/IntegrationTests.cs

+36
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,42 @@ public async Task Sorting_Should_Work_When_UsedWithNonNullDateTime()
3131
// assert
3232
result.MatchSnapshot();
3333
}
34+
35+
[Fact]
36+
public async Task Sorting_Should_Work_When_UsedOnAsyncResolver()
37+
{
38+
// arrange
39+
var executor = await new ServiceCollection()
40+
.AddGraphQL()
41+
.AddQueryType(
42+
d => d
43+
.Name(OperationTypeNames.Query)
44+
.Field("foos")
45+
.Type(typeof(List<Foo>))
46+
.Resolve(async _ => await Task.FromResult(new List<Foo>(
47+
[
48+
new Foo { CreatedUtc = new DateTime(2000, 1, 1, 1, 1, 1) },
49+
new Foo { CreatedUtc = new DateTime(2010, 1, 1, 1, 1, 1) },
50+
new Foo { CreatedUtc = new DateTime(2020, 1, 1, 1, 1, 1) }
51+
])))
52+
.UseSorting())
53+
.AddSorting()
54+
.BuildRequestExecutorAsync();
55+
56+
const string query = @"
57+
{
58+
foos(order: { createdUtc: DESC }) {
59+
createdUtc
60+
}
61+
}
62+
";
63+
64+
// act
65+
var result = await executor.ExecuteAsync(query);
66+
67+
// assert
68+
result.MatchSnapshot();
69+
}
3470
}
3571

3672
public class Query
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"data": {
3+
"foos": [
4+
{
5+
"createdUtc": "2020-01-01"
6+
},
7+
{
8+
"createdUtc": "2010-01-01"
9+
},
10+
{
11+
"createdUtc": "2000-01-01"
12+
}
13+
]
14+
}
15+
}

0 commit comments

Comments
 (0)
Please sign in to comment.