Method not found: GraphQL.ExecutionOptions.set_NameConverter in netcoreapp2.2

564 views Asked by At

I need to integrate GraphQL in NetCoreApp 2.2 <TargetFramework>netcoreapp2.2</TargetFramework> (I can't upgrade to NetCore 3 for other reasons).

PS. We have another project in .Net Core 3.1 and we can use GraphQL.Server.Transports.AspNetCore.SystemTextJson and we don't have any problem. Everything works as expected in that project.

I am getting the following error at the moment:

System.MissingMethodException: Method not found: 'Void GraphQL.ExecutionOptions.set_NameConverter(GraphQL.Conversion.INameConverter)'.
   at GraphQL.Server.Internal.DefaultGraphQLExecuter`1.GetOptions(String operationName, String query, Inputs variables, IDictionary`2 context, IServiceProvider requestServices, CancellationToken cancellationToken)
   at GraphQL.Server.Internal.DefaultGraphQLExecuter`1.ExecuteAsync(String operationName, String query, Inputs variables, IDictionary`2 context, IServiceProvider requestServices, CancellationToken cancellationToken) in /_/src/Core/Internal/DefaultGraphQLExecuter.cs:line 45
   at GraphQL.Server.Transports.AspNetCore.GraphQLHttpMiddleware`1.InvokeAsync(HttpContext context) in /_/src/Transports.AspNetCore/GraphQLHttpMiddleware.cs:line 144
   at Microsoft.AspNetCore.Builder.Extensions.UsePathBaseMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

If I am not wrong, I am getting this error because I'm using the different combination of Nuget Packages and one of the assemblies is missing that required method.

This is my current setup in csproj and I tried to swap with other versions (Eg. GraphQL 4.0) and I still couldn't make it work.

<PackageReference Include="GraphQL" Version="4.2.0" />
    <PackageReference Include="GraphQL.MicrosoftDI" Version="4.2.0" />
    <PackageReference Include="GraphQL.Server.Transports.AspNetCore.NewtonsoftJson" Version="4.4.1" />
    <PackageReference Include="GraphQL.Server.Ui.Playground" Version="4.4.1" />

my Startup.cs - ConfigureServices method

services.AddSingleton<ISchema, MyDataSchema>(serviceProvider => new MyDataSchema(new SelfActivatingServiceProvider(serviceProvider)));
services.AddGraphQL(options =>
    {
        options.EnableMetrics = true;
    })                            
    .AddNewtonsoftJson()
    .AddErrorInfoProvider(opt => opt.ExposeExceptionStackTrace = true);

Configure method

app.UseGraphQL<ISchema>();
app.UseGraphQLPlayground();

Could you please suggest me how I can use GraphQL in .Net Core 2.2?

If you know the right combination of the assemblies / codes / documentations which I can reference to make it work in .Net Core 2.2, please help me. I couldn't find the old documentations and it's always for the latest version.

0

There are 0 answers