graphql-dotnet / conventions

GraphQL Conventions Library for .NET
MIT License
233 stars 63 forks source link

Question about the place of this package in GraphQL.NET ecosystem #236

Closed sungam3r closed 1 year ago

sungam3r commented 1 year ago

Hi @tlil . Reading #235 I opened readme to see what this projct about. As it states

This library is a complementary layer on top that allows you to automatically wrap your .NET classes into GraphQL schema definitions using existing property getters and methods as field resolvers.

At the moment, the main package also provides such a feature. It was almost written by @Shane32 . I assume that some parts of this project may now be irrelevant. I must admin that I do not use your project and did not watch its source code.

sungam3r commented 1 year ago

If everything is really as I believe, now such a situation can confuse people when they do not understand what they should use.

Shane32 commented 1 year ago

I have never used this project either. However, after looking through it a bit, I have a few comments:

floge07 commented 1 year ago
  • The AutoRegisteringGraphTypes supports extensive modifications either via .NET attributes applied to classes/methods/arguments, global attributes, or via deriving from the auto-registering class and incorporating behaviors there. This allows to do things like override the name of a field/argument, have a method argument pull a service from DI, override the graph type, and so on. I am not sure if the Conventions project has similar features.

  • The AutoRegisteringGraphTypes fully support synchronous and asynchronous methods, either via Task<T> or ValueTask<T>. I'm not sure if the conventions project does or does not.

I think I can give an example to hopefully answer some of these questions:

[Name("getTestText")]
[Description("this will return an empty string")]
public async Task<NonNull<string>> Test(
    IUserContext userContext,
    [Inject] ServiceA a,
    [Inject] ServiceB b,
    [Name("arg1")] int argument1,
    [Name("arg2")] [Description("this is a description for this argument")] string text
) {
    return string.Empty;
}
sungam3r commented 1 year ago

From this example I see that GraphQL.NET can do the same. It has NameAttribute to set name as well but not for description. I can't find one. Did we write attribute for description, @Shane32 ? NonNull wrapper is not needed, you may use NRT instead. Use [FromUserContext] on IUserContext argument and [FromServices] instead of [Inject] . NameAttribute works for parameters as well.

sungam3r commented 1 year ago

Ah, DescriptionAttribute is one of those from System.ComponentModel namespace. GraphQL.NET supports those attributes for a long time.

tlil commented 1 year ago

From this example I see that GraphQL.NET can do the same. It has NameAttribute to set name as well but not for description. I can't find one. Did we write attribute for description, @Shane32 ? NonNull wrapper is not needed, you may use NRT instead. Use [FromUserContext] on IUserContext argument and [FromServices] instead of [Inject] . NameAttribute works for parameters as well.

CleanShot 2022-11-25 at 21 33 09

tlil commented 1 year ago

@sungam3r I'll close this issue now; I don't see anything constructive here to be honest, other than critique of differences in work that has been years in the making.

This project was started more than 6 years ago, has been used and running in production systems since its inception, and serves use cases for a bunch of users as-is.

I assume that some parts of this project may now be irrelevant.

I am not going to force anyone to migrate and refactor their code bases just because there are synergies and opportunities to consolidate some of the work with what's later been added to the parent project (e.g., AutoRegisteringGraphTypes, which is a much more recent addition). I'd rather give our users the option of choose what suits their use case and preference better.

Also, re comments above such as the "NotNull wrapper is not needed" – this stems from the fact that this project predates NRT language support. :-)

Shane32 commented 1 year ago

Well said