-
Notifications
You must be signed in to change notification settings - Fork 193
Description
Dear graphql-dotnet team, thank you all for this great software! I am updating the NuGet packages in my GraphQL server project and got some deprecated warnings. So of course I checked the examples in this repo and noticed that they are also still using old NuGets and a deprecated Field syntax.
Expected Behaviour
Examples should use more up-to-date NuGet Package (e.g. the latest 8.5.x) and avoid deprecated methods.
Actual Behaviour
The StarWars example uses an older NuGet package (5.1.x) and deprecated Field syntax. I haven't verified the other examples.
// Deprecated syntax
FieldAsync<CharacterInterface>("hero", resolve: async context => await data.GetDroidByIdAsync("3"));Steps to reproduce
git clone https://github.com/graphql-dotnet/examples.git- Open \src\AspNetCore\AspNetCore.sln in Visual Studio
- In the NuGet Package Manager, update the GraphQL package
After these steps, the project fails to compile, and there are several deprecated warnings.
Proposed fix
Can somebody please confirm that this is the recommended syntax for the foreseeable future? Adapted from src/StarWars/StarWarsQuery.cs:
public class StarWarsQuery : ObjectGraphType<object>
{
public StarWarsQuery(StarWarsData data)
{
Name = "Query";
Field<CharacterInterface>("hero")
.ResolveAsync(async context => await data.GetDroidByIdAsync("3"));
Field<HumanType>("human")
.Description("id of the human")
.Argument<NonNullGraphType<StringGraphType>>("id")
.ResolveAsync(async context => await data.GetHumanByIdAsync(context.GetArgument<string>("id")));
Func<IResolveFieldContext, string, Task<Droid>> func = (context, id) => data.GetDroidByIdAsync(id);
Field<DroidType>("droid")
.Description("id of the droid")
.Argument<NonNullGraphType<StringGraphType>>("id")
.ResolveDelegate(func);
}
}If somebody approves, I am ready to invest some time and create a pull request with updated GraphQL NuGets and Field Syntax.
In case I have just missed any up-to-date examples or documentation, could you please point me to them or consider updating the README?
My environment:
- Windows 11
- Visual Studio 2022
- Target Framework: I tried with .NET 8.0 (latest LTS) and .NET 9.0 (latest)
- GraphQL Nuget Package 8.5.0
Thank you for your time :)