server: AddDefaultEndpointSelectorPolicy did not work with the new MicrosoftDI.GraphQLBuilderExtensions

Hi, I am currently upgrading our solution to the latest Graphql Version and found a problem.

Ive upgraded the solution, started it and it works. But I got the AddGraphQl obsolete warnings (by the way, it would be helpful if they had a description what todo to get rid of the obsolete).

So ive changed:

  services.AddGraphQL((options, provider) =>
  {
      options.EnableMetrics = true;
      var logger = provider.GetRequiredService<ILogger<Startup>>();
      options.UnhandledExceptionDelegate = ctx => logger.LogError("{Error} occurred", ctx.OriginalException.Message);
  })
  .AddDefaultEndpointSelectorPolicy()
  .AddSystemTextJson(deserializerSettings => { }, serializerSettings => { })
  .AddWebSockets()
  .AddDataLoader()
  .AddGraphTypes(typeof(MySchema));

to

    GraphQL.MicrosoftDI.GraphQLBuilderExtensions.AddGraphQL(services)
    .AddServer(true,
        (options, provider) =>
        {
            options.EnableMetrics = true;
            var logger = provider.GetRequiredService<ILogger<Startup>>();
            options.UnhandledExceptionDelegate = ctx => logger.LogError("{Error} occurred", ctx.OriginalException.Message);
        })
    .AddDefaultEndpointSelectorPolicy()
    .AddSystemTextJson(deserializerSettings => { }, serializerSettings => { })
    .AddWebSockets()
    .AddGraphTypes(typeof(MySchema).Assembly);

And now Ive get:

Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:
GraphQL WebSockets
GraphQL

Using NET5 and Routing.

Ive played around with the various extensions, but did not find a working solution yet.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 43 (37 by maintainers)

Most upvoted comments

Fixed in #730.

👍🏻 I have to say thank you for you both efforts!

By the way. Did you noticed my inline comment 😄 ->

 (it would be helpful if they had a description what todo to get rid of the obsolete)