Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 72 additions & 23 deletions website/src/docs/hotchocolate/v16/server/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,32 @@ You can influence the behavior of the middleware registered by `MapGraphQL` usin
### EnableSchemaRequests

```csharp
endpoints.MapGraphQL().WithOptions(o => o.EnableSchemaRequests = false);
endpoints.MapGraphQL().WithOptions((GraphQLServerOptions option) =>
{
option.EnableSchemaRequests = false;
});
```

This setting controls whether the schema of the GraphQL server can be downloaded by appending `?sdl` to the endpoint.

### EnableGetRequests

```csharp
endpoints.MapGraphQL().WithOptions(o => o.EnableGetRequests = false);
endpoints.MapGraphQL().WithOptions((GraphQLServerOptions option) =>
{
option.EnableGetRequests = false;
});
```

This setting controls whether the GraphQL server handles GraphQL operations sent via the query string in an HTTP GET request.

### AllowedGetOperations

```csharp
endpoints.MapGraphQL().WithOptions(o => o.AllowedGetOperations = AllowedGetOperations.Query);
endpoints.MapGraphQL().WithOptions((GraphQLServerOptions option) =>
{
option.AllowedGetOperations = AllowedGetOperations.Query;
});
```

If [EnableGetRequests](#enablegetrequests) is `true`, you can control the allowed operations for HTTP GET requests using the `AllowedGetOperations` setting.
Expand All @@ -89,7 +98,10 @@ By default, only queries are accepted via HTTP GET. You can also allow mutations
### EnableMultipartRequests

```csharp
endpoints.MapGraphQL().WithOptions(o => o.EnableMultipartRequests = false);
endpoints.MapGraphQL().WithOptions((GraphQLServerOptions option) =>
{
option.EnableMultipartRequests = false;
});
```

This setting controls whether the GraphQL server handles HTTP multipart forms (file uploads).
Expand All @@ -107,7 +119,10 @@ app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapGraphQL().WithOptions(o => o.Tool.Enable = env.IsDevelopment());
endpoints.MapGraphQL().WithOptions((NitroAppOptions option) =>
{
option.Enable = env.IsDevelopment();
});
});
```

Expand Down Expand Up @@ -135,23 +150,32 @@ You can configure Nitro using `NitroAppOptions`.
### Enable

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.Enable = false);
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.Enable = false;
});
```

This setting controls whether Nitro is served.

### GraphQLEndpoint

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.GraphQLEndpoint = "/my/graphql/endpoint");
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.GraphQLEndpoint = "/my/graphql/endpoint";
});
```

This setting sets the GraphQL endpoint to use when creating new documents within Nitro.

### UseBrowserUrlAsGraphQLEndpoint

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.UseBrowserUrlAsGraphQLEndpoint = true);
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.UseBrowserUrlAsGraphQLEndpoint = true;
});
```

If set to `true`, the current browser URL is treated as the GraphQL endpoint when creating new documents within Nitro.
Expand All @@ -161,25 +185,31 @@ If set to `true`, the current browser URL is treated as the GraphQL endpoint whe
### Document

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.Document = "{ __typename }");
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.Document = "{ __typename }";
});
```

This setting lets you set a default GraphQL document that serves as a placeholder for each new document created using Nitro.

### UseGet

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.UseGet = true);
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.UseGet = true;
});
```

This setting controls the default HTTP method used to execute GraphQL operations when creating new documents within Nitro. When set to `true`, HTTP GET is used instead of the default HTTP POST.

### HttpHeaders

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o =>
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
o.HttpHeaders = new HeaderDictionary
option.HttpHeaders = new HeaderDictionary
{
{ "Content-Type", "application/json" }
};
Expand All @@ -191,31 +221,43 @@ This setting lets you specify default HTTP headers that are added to each new do
### IncludeCookies

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.IncludeCookies = true);
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.IncludeCookies = true;
});
```

This setting specifies the default for including cookies in cross-origin requests when creating new documents within Nitro.

### Title

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.Title = "My GraphQL explorer");
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.Title = "My GraphQL explorer";
});
```

This setting controls the tab name when Nitro is opened inside a web browser.

### DisableTelemetry

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.DisableTelemetry = true);
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.DisableTelemetry = true;
});
```

This setting lets you disable telemetry events.

### GaTrackingId

```csharp
endpoints.MapNitroApp("/ui").WithOptions(o => o.GaTrackingId = "google-analytics-id");
endpoints.MapNitroApp("/ui").WithOptions((NitroAppOptions option) =>
{
option.GaTrackingId = "google-analytics-id";
});
```

This setting lets you set a custom Google Analytics ID, which allows you to gain insights into the usage of Nitro hosted as part of your GraphQL server.
Expand Down Expand Up @@ -250,7 +292,10 @@ With the above configuration, you can issue HTTP GET/POST requests against the `
The HTTP endpoint can also be configured with per-endpoint overrides using `WithOptions`:

```csharp
endpoints.MapGraphQLHttp("/graphql/http").WithOptions(o => o.EnableGetRequests = false);
endpoints.MapGraphQLHttp("/graphql/http").WithOptions(o =>
{
option.EnableGetRequests = false;
});
```

The same `GraphQLServerOptions` properties available on `MapGraphQL` can be overridden here, except for `Tool` and `EnableSchemaRequests` which are not applicable to standalone HTTP endpoints.
Expand Down Expand Up @@ -407,12 +452,16 @@ Hot Chocolate uses a delegate-based `WithOptions` pattern to configure options p
## MapGraphQL

```csharp
app.MapGraphQL().WithOptions(o =>
{
o.EnableGetRequests = false;
o.AllowedGetOperations = AllowedGetOperations.Query;
o.Tool.Enable = false;
});
app.MapGraphQL()
.WithOptions((GraphQLServerOptions option) =>
{
option.EnableGetRequests = false;
option.AllowedGetOperations = AllowedGetOperations.Query;
})
.WithOptions((NitroAppOptions option) =>
{
option.Enable = false;
});
```

## MapGraphQLHttp
Expand Down
Loading