diff --git a/README.md b/README.md index 74844fb..6c92a52 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ sample of the application builder code: ```csharp var app = builder.Build(); app.UseDeveloperExceptionPage(); +app.UseWebSockets(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGraphQL("graphql"); @@ -120,6 +121,28 @@ app.UseEndpoints(endpoints => { await app.RunAsync(); ``` +Using endpoint routing is particularly useful when you want to select a specific +CORS configuration for the GraphQL endpoint. See the CORS section below for a sample. + +Please note that when using endpoint routing, you cannot use WebSocket connections +while a UI package is also configured at the same URL. You will need to use a +different URL for the UI package, or use UI middleware prior to endpoint routing. +So long as different URLs are used, there are no issues. Below is a sample when +the UI and GraphQL reside at the same URL: + +```csharp +var app = builder.Build(); +app.UseDeveloperExceptionPage(); +app.UseWebSockets(); +app.UseRouting(); +app.UseGraphQLVoyager("/graphql"); +app.UseEndpoints(endpoints => +{ + endpoints.MapGraphQL("/graphql"); +}); +await app.RunAsync(); +``` + ### Configuration with a MVC controller Although not recommended, you may set up a controller action to execute GraphQL