I simply create new dotnet web api core v7 and want to add dotnet graphql v7 too.
this is my program.cs
using GraphQL;
using Erapi.Graphql.Queries;
using GraphQL.Types;
using Erapi.Graphql.Notes;
using GraphQL.MicrosoftDI;
//using GraphQL.Server;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<ISchema, NotesSchema>(services => new NotesSchema(new SelfActivatingServiceProvider(services)));
builder.Services.AddGraphQL(options =>
options.ConfigureExecution((opt, next) =>
{
opt.EnableMetrics = true;
return next(opt);
}).AddSystemTextJson()
);
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(
builder =>
{
builder.WithOrigins("*")
.AllowAnyHeader();
});
});
builder.Services.AddControllers();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseCors();
//app.UseAuthorization();
app.MapControllers();
app.UseGraphQL(); <-- error here
await app.RunAsync();
the error
:
Severity Code Description Project File Line Suppression State Error CS1061 'WebApplication' does not contain a definition for 'UseGraphQL' and no accessible extension method 'UseGraphQL' accepting a first argument of type 'WebApplication' could be found (are you missing a using directive or an assembly reference?)
and this is my packages:
<ItemGroup>
<PackageReference Include="GraphQL" Version="7.1.1" />
<PackageReference Include="GraphQL.MemoryCache" Version="7.1.1" />
<PackageReference Include="GraphQL.MicrosoftDI" Version="7.1.1" />
<PackageReference Include="GraphQL.NewtonsoftJson" Version="7.1.1" />
<PackageReference Include="GraphQL.SystemTextJson" Version="7.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
</ItemGroup>
how to solve this? is this a bugs? or I miss something?