Skip to content

Commit

Permalink
Add notes regarding endpoint routing (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 authored Aug 19, 2024
1 parent c67df30 commit 5d4f0ee
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,36 @@ sample of the application builder code:
```csharp
var app = builder.Build();
app.UseDeveloperExceptionPage();
app.UseWebSockets();
app.UseRouting();
app.UseEndpoints(endpoints => {
endpoints.MapGraphQL("graphql");
});
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
Expand Down

0 comments on commit 5d4f0ee

Please sign in to comment.