Minh Giang
Minh Giang

Reputation: 727

GraphQL .NET Core Visual Studio 2019 wrong suggestions

I'm practicing with graphql-dotnet. I created a PropertyQuery as follows:

public class PropertyQuery : ObjectGraphType
{
    public PropertyQuery(IPropertyRepository propertyRepository)
    {
        Field<ListGraphType<PropertyType>>(
            "properties",
            resolve: context => propertyRepository.GetAll()
        );

        Field<PropertyType>(
            "property"
            , arguments: new QueryArguments(new QueryArgument<IntGraphType> { Name = "id" })
            , resolve: context => propertyRepository.GetById(context.GetArgument<int>("id"))
         );
    }
}

Problem occurred with intellisense of Visual Studio (2019). When I passed resolve parameter of Field method, the intellisense not suggests GetArgument or Source etc... of ResolveFieldContext<TSource>, instead, it suggests like:

enter image description here

I am confused whether this is a error of visual studio, or the graphql-dotnet library has a problem. I'm a newbie in graphql, and if intellisense suggestions is wrong, I can't continue to practice

Upvotes: 2

Views: 535

Answers (2)

David Poeschl
David Poeschl

Reputation: 864

Thank you for reporting this! This is a bug in the way the C# completion list infers the types of lambda parameters when the lambda is being passed as an argument. I've posted a minimal standalone repro here.

In your example, completion should work as expected if you include the description argument (thus aligning the resolve argument with the corresponding resolve parameter on the other side). Can you please give this a try?

Upvotes: 0

LoLance
LoLance

Reputation: 28126

I am confused whether this is a error of visual studio, or the graphql-dotnet library has a problem.

There's possibility that this is one issue with VS2019 since same project in VS2017 works well...

I can now reproduce same issue in my machine. Since this issue occurs only when we use VS2019 to develop the project with Graphql package, I think it could be one issue about VS2019 Intellisense. (Create and develop the project in VS2017, all works well. Open it in VS2019, the issue occurs)

So I've just reported this issue in DC forum as a workaround. Here is the link where you can track it. Please visit the link and vote on the issue so you can get notifications on progress. Hope it makes some help :)

Upvotes: 2

Related Questions