diff --git a/website/src/docs/fusion/v16/authentication-and-authorization.md b/website/src/docs/fusion/v16/authentication-and-authorization.md index ed03a45c3bb..e87f3f07d13 100644 --- a/website/src/docs/fusion/v16/authentication-and-authorization.md +++ b/website/src/docs/fusion/v16/authentication-and-authorization.md @@ -2,8 +2,6 @@ title: "Authentication and Authorization" --- -# Authentication and Authorization - The mental model for auth in Fusion is straightforward: **authentication terminates at the gateway, authorization is a subgraph concern.** The gateway validates tokens, extracts identity, and forwards the relevant information to subgraphs via HTTP headers. Each subgraph then enforces access control on its own fields using its own authorization framework. diff --git a/website/src/docs/fusion/v16/migration/migrating-from-schema-stitching.md b/website/src/docs/fusion/v16/migration/migrating-from-schema-stitching.md index 3fdc8338da1..1a31ad02b2d 100644 --- a/website/src/docs/fusion/v16/migration/migrating-from-schema-stitching.md +++ b/website/src/docs/fusion/v16/migration/migrating-from-schema-stitching.md @@ -80,8 +80,8 @@ In stitching, your remote schemas are HotChocolate servers that may or may not p // Products service - Program.cs var builder = WebApplication.CreateBuilder(args); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType(); var app = builder.Build(); @@ -146,7 +146,7 @@ public static partial class ProductQueries Key changes: -- **`builder.AddGraphQL("products-api")`** replaces `builder.Services.AddGraphQLServer()`. The string argument is the subgraph name used during composition. +- **`builder.AddGraphQL("products-api")`** replaces `builder.AddGraphQL()`. The string argument is the subgraph name used during composition. - **`.AddProductTypes()`** is generated by the `HotChocolate.Types.Analyzers` package. It registers all types marked with `[QueryType]`, `[ObjectType]`, etc. - **`.ExportSchemaOnStartup()`** exports the subgraph's schema as a `.graphqls` file when the server starts (used for composition). - **`app.RunWithGraphQLCommands(args)`** enables CLI commands like `dotnet run -- schema export`. @@ -286,8 +286,8 @@ builder.Services .AddHttpClient("inventory", c => c.BaseAddress = new Uri("http://localhost:5200/graphql")); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddRemoteSchema("products") .AddRemoteSchema("inventory") .AddTypeExtensionsFromFile("./Stitching.graphql"); diff --git a/website/src/docs/fusion/v16/request-limits.md b/website/src/docs/fusion/v16/request-limits.md index 33e1c906af3..b7da7bba105 100644 --- a/website/src/docs/fusion/v16/request-limits.md +++ b/website/src/docs/fusion/v16/request-limits.md @@ -163,7 +163,7 @@ builder The maximum HTTP request body size defaults to approximately 20 MB: ```csharp -services.AddGraphQLGatewayServer(maxAllowedRequestSize: 5 * 1000 * 1024); // 5 MB +builder.AddGraphQLGateway(maxAllowedRequestSize: 5 * 1000 * 1024); // 5 MB ``` ### Server Options diff --git a/website/src/docs/hotchocolate/v16/api-reference/apollo-federation.md b/website/src/docs/hotchocolate/v16/api-reference/apollo-federation.md index d810aedf9f8..ce10b420891 100644 --- a/website/src/docs/hotchocolate/v16/api-reference/apollo-federation.md +++ b/website/src/docs/hotchocolate/v16/api-reference/apollo-federation.md @@ -20,8 +20,8 @@ Install the `HotChocolate.ApolloFederation` package: Register the Apollo Federation services: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddApolloFederation(); ``` @@ -239,8 +239,8 @@ Register the type in the GraphQL schema: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddApolloFederation() .AddType(); ``` @@ -250,8 +250,8 @@ builder.Services ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddApolloFederation() .AddType(); ``` @@ -300,8 +300,8 @@ public class Product public string Id { get; set; } } -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddApolloFederation() .AddType(); ``` @@ -321,8 +321,8 @@ public class ProductType : ObjectType } } -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddApolloFederation() .AddType(); ``` diff --git a/website/src/docs/hotchocolate/v16/api-reference/extending-filtering.md b/website/src/docs/hotchocolate/v16/api-reference/extending-filtering.md index 3d06a2d6ff8..3d4caae8d9b 100644 --- a/website/src/docs/hotchocolate/v16/api-reference/extending-filtering.md +++ b/website/src/docs/hotchocolate/v16/api-reference/extending-filtering.md @@ -267,16 +267,16 @@ public class CustomFilteringConvention : FilterConvention } } -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddFiltering(); ``` You can also use convention and provider extensions instead of creating a custom `FilterConvention`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddFiltering() .AddConvention( new FilterConventionExtension( diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/directives.md b/website/src/docs/hotchocolate/v16/building-a-schema/directives.md index d3f464551c1..697e68571ec 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/directives.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/directives.md @@ -40,8 +40,8 @@ public class MyDirectiveType : DirectiveType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddDirectiveType(); ``` diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/documentation.md b/website/src/docs/hotchocolate/v16/building-a-schema/documentation.md index 161ea32d0a0..e9b06104c76 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/documentation.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/documentation.md @@ -155,8 +155,8 @@ If you do not want XML comments to appear in the schema: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(opt => opt.UseXmlDocumentation = false); ``` @@ -186,8 +186,8 @@ public class CustomNamingConventions : DefaultNamingConventions // Program.cs IReadOnlySchemaOptions capturedSchemaOptions; -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(opt => capturedSchemaOptions = opt) .AddConvention(sp => new CustomNamingConventions( diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/dynamic-schemas.md b/website/src/docs/hotchocolate/v16/building-a-schema/dynamic-schemas.md index 89e158b7cdf..cd29c69c66f 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/dynamic-schemas.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/dynamic-schemas.md @@ -15,8 +15,8 @@ When you fire the `TypesChanged` event, Hot Chocolate phases out the old schema ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeModule(); ``` @@ -211,8 +211,8 @@ mutationDef.Fields.Add(createProductField); var mutationType = ObjectType.CreateUnsafe(mutationDef); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMutationType(mutationType) .AddType(productInputType) diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/enums.md b/website/src/docs/hotchocolate/v16/building-a-schema/enums.md index 9d061fc87d4..fba6f63f1ea 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/enums.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/enums.md @@ -82,8 +82,8 @@ Code-first enum types are not automatically inferred because multiple `EnumType< ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(); ``` diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/extending-types.md b/website/src/docs/hotchocolate/v16/building-a-schema/extending-types.md index 82837c08061..e678a1bad3c 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/extending-types.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/extending-types.md @@ -35,8 +35,8 @@ public static partial class BookExtensions ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeExtension(); ``` @@ -65,8 +65,8 @@ public class BookTypeExtensions : ObjectTypeExtension ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeExtension(); ``` @@ -98,8 +98,8 @@ public class BookQueries ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeExtension(); ``` @@ -125,8 +125,8 @@ public class QueryBookResolvers : ObjectTypeExtension ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeExtension(); ``` @@ -151,8 +151,8 @@ public class BookExtensions ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeExtension(); ``` @@ -172,8 +172,8 @@ public class BookTypeExtensions : ObjectTypeExtension ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeExtension(); ``` diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/interfaces.md b/website/src/docs/hotchocolate/v16/building-a-schema/interfaces.md index af7a1599285..ffeca9724a9 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/interfaces.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/interfaces.md @@ -75,8 +75,8 @@ public static partial class MessageQueries ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(); ``` @@ -136,8 +136,8 @@ public class TextMessageType : ObjectType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddType(); ``` @@ -272,8 +272,8 @@ public class TextMessage : IDatedMessage ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType() .AddType(); ``` @@ -306,8 +306,8 @@ public class TextMessageType : ObjectType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddType() .AddType(); diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/mutations.md b/website/src/docs/hotchocolate/v16/building-a-schema/mutations.md index c580ad09fdd..5159f6972af 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/mutations.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/mutations.md @@ -85,8 +85,8 @@ public class BookMutationsType : ObjectType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMutationType(); ``` @@ -137,8 +137,8 @@ Hot Chocolate generates the input and payload types for you when mutation conven ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMutationConventions(applyToAllMutations: true); ``` @@ -231,8 +231,8 @@ Override the global naming patterns through `MutationConventionOptions`: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMutationConventions( new MutationConventionOptions { @@ -354,8 +354,8 @@ public interface IUserError ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddErrorInterfaceType(); ``` @@ -377,8 +377,8 @@ public class CustomErrorInterfaceType : InterfaceType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddErrorInterfaceType(); ``` @@ -393,16 +393,16 @@ When a request contains multiple mutations, Hot Chocolate can wrap them in a tra ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddDefaultTransactionScopeHandler(); ``` To customize the transaction behavior, implement `ITransactionScopeHandler` and register it: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTransactionScopeHandler(); ``` diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/object-types.md b/website/src/docs/hotchocolate/v16/building-a-schema/object-types.md index c9225d08c81..09c166ff4fd 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/object-types.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/object-types.md @@ -83,8 +83,8 @@ Since multiple classes could inherit from `ObjectType` with different co ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(); ``` @@ -399,8 +399,8 @@ You can also set this globally, which affects all types. ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(options => { options.DefaultBindingBehavior = BindingBehavior.Explicit; diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/queries.md b/website/src/docs/hotchocolate/v16/building-a-schema/queries.md index b8331e2ffc0..127a06b88ec 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/queries.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/queries.md @@ -72,8 +72,8 @@ public class BookQueriesType : ObjectType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType(); ``` diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/relay.md b/website/src/docs/hotchocolate/v16/building-a-schema/relay.md index a2a94932792..1db8298b0a0 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/relay.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/relay.md @@ -168,8 +168,8 @@ Global object identification extends global identifiers by enabling clients to r ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddGlobalObjectIdentification(); ``` @@ -189,8 +189,8 @@ type Query { You can configure options when enabling global object identification: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddGlobalObjectIdentification(opts => { opts.MaxAllowedNodeBatchSize = 50; @@ -344,8 +344,8 @@ Register type converters so Hot Chocolate can serialize and deserialize the comp ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeConverter(ProductId.Parse) .AddTypeConverter(x => x.ToString()) .AddGlobalObjectIdentification(); @@ -359,16 +359,16 @@ Mutation payloads can include a `query` field that gives clients access to the f ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryFieldToMutationPayloads(); ``` By default, a `query: Query` field is added to every mutation payload type whose name ends in `Payload`. You can customize this: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryFieldToMutationPayloads(options => { options.QueryFieldName = "rootQuery"; diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/scalars.md b/website/src/docs/hotchocolate/v16/building-a-schema/scalars.md index 5bac79fd370..da0df0aab36 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/scalars.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/scalars.md @@ -162,8 +162,8 @@ public sealed class Product ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddDocumentFromString( """ type Query { @@ -246,8 +246,8 @@ To customize the built-in scalars, register configured scalar instances explicit ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(new DateTimeType(new DateTimeOptions { OutputPrecision = 3 @@ -282,8 +282,8 @@ To change the default format: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(new UuidType('N')); ``` @@ -360,8 +360,8 @@ By default, `Any` expects a `JsonElement`. To return common .NET types such as ` ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddJsonTypeConverter(); ``` @@ -383,8 +383,8 @@ For custom reference types, register a dedicated converter to control serializat ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeConverter( value => JsonSerializer.SerializeToElement(value.Id)); ``` @@ -458,8 +458,8 @@ Register them with `AddNodaTime()`: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddNodaTime(); ``` @@ -471,8 +471,8 @@ If you prefer, you can still register individual scalar types explicitly. For ex // Program.cs using NodaTimeDurationType = HotChocolate.Types.NodaTime.DurationType; -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(); ``` @@ -494,8 +494,8 @@ using NodaTimeDateTimeType = HotChocolate.Types.NodaTime.DateTimeType; using NodaTimeLocalDateTimeType = HotChocolate.Types.NodaTime.LocalDateTimeType; using NodaTimeLocalTimeType = HotChocolate.Types.NodaTime.LocalTimeType; -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(new NodaTimeDateTimeType(new NodaTimeDateTimeOptions { OutputPrecision = 3 @@ -516,8 +516,8 @@ You can override the default .NET-to-scalar mappings by specifying type bindings ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .BindRuntimeType(); ``` @@ -525,8 +525,8 @@ You can also bind scalars to arrays or complex types: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .BindRuntimeType(); ``` @@ -547,8 +547,8 @@ public sealed class ScheduleQueries ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .BindRuntimeType() .AddTypeConverter( @@ -690,8 +690,8 @@ You can also instantiate `RegexType` directly when registering scalars: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(new RegexType( "PostalCode", @"^\d{5}(-\d{4})?$", diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/subscriptions.md b/website/src/docs/hotchocolate/v16/building-a-schema/subscriptions.md index 6d3ee667cd2..bdbca7793e0 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/subscriptions.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/subscriptions.md @@ -68,8 +68,8 @@ public class BookSubscriptions ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSubscriptionType(); ``` @@ -245,8 +245,8 @@ The in-memory provider works without any external infrastructure. It is suitable ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddInMemorySubscriptions(); ``` @@ -262,8 +262,8 @@ Install the package: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddRedisSubscriptions( _ => ConnectionMultiplexer.Connect("localhost:6379")); ``` @@ -293,8 +293,8 @@ builder.Services Url = "nats://localhost:4222" }))); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSubscriptionType() .AddNatsSubscriptions(); ``` @@ -305,8 +305,8 @@ If multiple GraphQL servers share the same NATS broker, set a `TopicPrefix` to i // Program.cs using HotChocolate.Subscriptions; -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSubscriptionType() .AddNatsSubscriptions( new SubscriptionOptions @@ -325,8 +325,8 @@ Install the package: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSubscriptionType() .AddPostgresSubscriptions(options => options.ConnectionFactory = ct => /* create your NpgsqlConnection */); diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/unions.md b/website/src/docs/hotchocolate/v16/building-a-schema/unions.md index 3fc459c04d5..19a7989d816 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/unions.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/unions.md @@ -74,8 +74,8 @@ public static partial class ContentQueries ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType() .AddType(); ``` diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/versioning.md b/website/src/docs/hotchocolate/v16/building-a-schema/versioning.md index 58742f51f73..dd0c7c57626 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/versioning.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/versioning.md @@ -83,8 +83,8 @@ Opt-in feature support is disabled by default. Enable it in your schema options: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(o => o.EnableOptInFeatures = true); ``` @@ -171,8 +171,8 @@ You can declare the stability level of each opt-in feature. This helps consumers ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(o => o.EnableOptInFeatures = true) .OptInFeatureStability("experimentalInstantApi", "experimental"); ``` @@ -182,8 +182,8 @@ builder.Services ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(o => o.EnableOptInFeatures = true) .SetSchema(s => s .OptInFeatureStability("experimentalInstantApi", "experimental")); diff --git a/website/src/docs/hotchocolate/v16/execution-engine/index.md b/website/src/docs/hotchocolate/v16/execution-engine/index.md index dffa959ac46..9bb99a6892c 100644 --- a/website/src/docs/hotchocolate/v16/execution-engine/index.md +++ b/website/src/docs/hotchocolate/v16/execution-engine/index.md @@ -68,8 +68,8 @@ Use the `UseRequest()` method on `IRequestExecutorBuilder` to add middleware. Th When you call `UseRequest()` without positioning parameters, the middleware is appended to the end of the pipeline: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .UseRequest(next => async context => { // Custom logic before the next middleware @@ -83,8 +83,8 @@ builder.Services Use the `before` parameter with a `WellKnownRequestMiddleware` constant to insert your middleware before a built-in one: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .UseRequest( middleware: next => async context => { @@ -100,8 +100,8 @@ builder.Services Use the `after` parameter to insert your middleware after a built-in one: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .UseRequest( middleware: next => async context => { @@ -117,8 +117,8 @@ builder.Services Set `allowMultiple` to `false` (the default) so that if a middleware with the same key already exists, the registration is skipped: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .UseRequest( middleware: next => async context => { @@ -159,8 +159,8 @@ public class MyRequestMiddleware Register it with precise positioning using the generic `UseRequest()` overload: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .UseRequest( key: "MyRequestMiddleware", after: WellKnownRequestMiddleware.DocumentValidationMiddleware); diff --git a/website/src/docs/hotchocolate/v16/guides/dynamic-schemas.md b/website/src/docs/hotchocolate/v16/guides/dynamic-schemas.md index 9edc23fc802..7cba89fb85b 100644 --- a/website/src/docs/hotchocolate/v16/guides/dynamic-schemas.md +++ b/website/src/docs/hotchocolate/v16/guides/dynamic-schemas.md @@ -15,8 +15,8 @@ When you fire the `TypesChanged` event, Hot Chocolate phases out the old schema ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeModule(); ``` @@ -211,8 +211,8 @@ mutationDef.Fields.Add(createProductField); var mutationType = ObjectType.CreateUnsafe(mutationDef); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMutationType(mutationType) .AddType(productInputType) diff --git a/website/src/docs/hotchocolate/v16/guides/error-handling.md b/website/src/docs/hotchocolate/v16/guides/error-handling.md index aee564e3d2b..2c27f26293d 100644 --- a/website/src/docs/hotchocolate/v16/guides/error-handling.md +++ b/website/src/docs/hotchocolate/v16/guides/error-handling.md @@ -31,8 +31,8 @@ During development, if a debugger is attached, Hot Chocolate includes the origin ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyRequestOptions(opt => opt.IncludeExceptionDetails = true); ``` @@ -46,8 +46,8 @@ Register an error filter with `AddErrorFilter`. The filter receives an `IError` ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddErrorFilter(error => { if (error.Exception is not null) @@ -96,8 +96,8 @@ public class LoggingErrorFilter : IErrorFilter ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddErrorFilter(); ``` @@ -385,8 +385,8 @@ public interface IUserError ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMutationConventions(applyToAllMutations: true) .AddErrorInterfaceType(); ``` @@ -409,8 +409,8 @@ public class CustomErrorInterfaceType : InterfaceType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMutationConventions(applyToAllMutations: true) .AddErrorInterfaceType(); ``` diff --git a/website/src/docs/hotchocolate/v16/guides/mcp-adapter.md b/website/src/docs/hotchocolate/v16/guides/mcp-adapter.md index 1840ac21ea8..dfef1c570e9 100644 --- a/website/src/docs/hotchocolate/v16/guides/mcp-adapter.md +++ b/website/src/docs/hotchocolate/v16/guides/mcp-adapter.md @@ -20,7 +20,7 @@ Register the MCP adapter on your GraphQL server and map the MCP endpoint: // Program.cs var builder = WebApplication.CreateBuilder(args); -builder.Services +builder .AddGraphQL() .AddQueryType() .AddMutationType() @@ -242,7 +242,7 @@ You can configure the underlying MCP server options and add custom (non-GraphQL) ```csharp // Program.cs -builder.Services +builder .AddGraphQL() .AddQueryType() .AddMcp( @@ -279,12 +279,12 @@ In stateless mode, only the Streamable HTTP POST endpoint is available. # Fusion Integration -The MCP adapter works with Fusion gateway servers. Instead of `AddGraphQL()`, use `AddGraphQLGatewayServer()` and the rest of the configuration remains the same: +The MCP adapter works with Fusion gateway servers. Instead of `AddGraphQL()`, use `AddGraphQLGateway()` and the rest of the configuration remains the same: ```csharp // Program.cs -builder.Services - .AddGraphQLGatewayServer() +builder + .AddGraphQLGateway() .AddInMemoryConfiguration(compositeSchema) .AddHttpClientConfiguration("Subgraph", subgraphUri) .AddMcp() diff --git a/website/src/docs/hotchocolate/v16/guides/openapi-adapter.md b/website/src/docs/hotchocolate/v16/guides/openapi-adapter.md index 047b3610a6e..d86ac30a00b 100644 --- a/website/src/docs/hotchocolate/v16/guides/openapi-adapter.md +++ b/website/src/docs/hotchocolate/v16/guides/openapi-adapter.md @@ -24,8 +24,8 @@ builder.Services .AddRouting() .AddOpenApi(options => options.AddGraphQLTransformer()); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMutationType() .AddOpenApiDefinitionStorage(myStorage); @@ -239,8 +239,8 @@ Register it with your GraphQL server: // Program.cs var storage = new MyOpenApiStorage(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddOpenApiDefinitionStorage(storage); ``` @@ -255,12 +255,12 @@ Each endpoint definition's description becomes the OpenAPI operation summary. Ro # Fusion Integration -The OpenAPI adapter works with Fusion gateway servers. Replace `AddGraphQLServer()` with `AddGraphQLGatewayServer()` and the rest of the configuration remains the same: +The OpenAPI adapter works with Fusion gateway servers. Replace `AddGraphQL()` with `AddGraphQLGateway()` and the rest of the configuration remains the same: ```csharp // Program.cs -builder.Services - .AddGraphQLGatewayServer() +builder + .AddGraphQLGateway() .AddInMemoryConfiguration(compositeSchema) .AddHttpClientConfiguration("Subgraph", subgraphUri) .AddOpenApiDefinitionStorage(myStorage); diff --git a/website/src/docs/hotchocolate/v16/guides/performance.md b/website/src/docs/hotchocolate/v16/guides/performance.md index 418b688d003..3d529028c7f 100644 --- a/website/src/docs/hotchocolate/v16/guides/performance.md +++ b/website/src/docs/hotchocolate/v16/guides/performance.md @@ -10,8 +10,8 @@ The schema is constructed eagerly at startup by default. You can go a step furth ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddWarmupTask(async (executor, cancellationToken) => { var request = OperationRequestBuilder.New() @@ -37,8 +37,8 @@ Hot Chocolate caches parsed and compiled operations so that repeated requests sk ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(options => { options.PreparedOperationCacheSize = 1024; @@ -128,8 +128,8 @@ Cost analysis calculates the cost of every operation before execution and reject ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyCostOptions(options => { options.MaxFieldCost = 5_000; @@ -154,8 +154,8 @@ Enable these directives in schema options: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(options => { options.EnableDefer = true; @@ -217,8 +217,8 @@ public class PerformanceEventListener : ExecutionDiagnosticEventListener ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddDiagnosticEventListener(); ``` diff --git a/website/src/docs/hotchocolate/v16/guides/private-api.md b/website/src/docs/hotchocolate/v16/guides/private-api.md index b7971eb2435..dea75387b56 100644 --- a/website/src/docs/hotchocolate/v16/guides/private-api.md +++ b/website/src/docs/hotchocolate/v16/guides/private-api.md @@ -38,8 +38,8 @@ Then configure the server: ```csharp var builder = WebApplication.CreateBuilder(args); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddNitro() .UsePersistedOperationPipeline() @@ -135,8 +135,8 @@ public class DevToolsInterceptor : DefaultHttpRequestInterceptor Register the interceptor: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddNitro() .AddHttpRequestInterceptor() @@ -169,8 +169,8 @@ builder.Services builder.Services.AddAuthorization(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMutationType() .AddAuthorization() diff --git a/website/src/docs/hotchocolate/v16/guides/public-api.md b/website/src/docs/hotchocolate/v16/guides/public-api.md index 79333170179..c7162c07a50 100644 --- a/website/src/docs/hotchocolate/v16/guides/public-api.md +++ b/website/src/docs/hotchocolate/v16/guides/public-api.md @@ -54,8 +54,8 @@ For public APIs, require clients to specify how many items they want by enabling ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyPagingOptions(opt => { opt.MaxPageSize = 100; @@ -74,8 +74,8 @@ Hot Chocolate enables cost analysis by default. The default limits (`MaxFieldCos ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyCostOptions(options => { options.MaxFieldCost = 5_000; @@ -145,8 +145,8 @@ Introspection lets anyone discover every type, field, and argument in your schem ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AllowIntrospection(builder.Environment.IsDevelopment()); ``` @@ -173,8 +173,8 @@ public class IntrospectionInterceptor : DefaultHttpRequestInterceptor ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AllowIntrospection(false) .AddHttpRequestInterceptor(); ``` @@ -257,8 +257,8 @@ Set a maximum query depth to reject pathologically nested queries before cost an ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMaxExecutionDepthRule(15); ``` @@ -299,8 +299,8 @@ In Hot Chocolate v16, request batching is disabled by default. If you have expli ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyRequestOptions(opt => opt.AllowedBatchOperations = AllowedBatchOperations.None); ``` @@ -335,8 +335,8 @@ builder.Services.AddRateLimiter(options => }); // GraphQL server -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddAuthorization() .AddMaxExecutionDepthRule(15) .ModifyPagingOptions(opt => diff --git a/website/src/docs/hotchocolate/v16/guides/schema-evolution.md b/website/src/docs/hotchocolate/v16/guides/schema-evolution.md index f659d8751b6..46564cbdb84 100644 --- a/website/src/docs/hotchocolate/v16/guides/schema-evolution.md +++ b/website/src/docs/hotchocolate/v16/guides/schema-evolution.md @@ -170,8 +170,8 @@ Opt-in support is disabled by default. Enable it in your schema options: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(o => o.EnableOptInFeatures = true); ``` @@ -234,8 +234,8 @@ You can declare the stability level of each opt-in feature so consumers understa ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(o => o.EnableOptInFeatures = true) .OptInFeatureStability("experimentalRecommendations", "experimental"); ``` @@ -245,8 +245,8 @@ builder.Services ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(o => o.EnableOptInFeatures = true) .SetSchema(s => s .OptInFeatureStability("experimentalRecommendations", "experimental")); diff --git a/website/src/docs/hotchocolate/v16/guides/testing.md b/website/src/docs/hotchocolate/v16/guides/testing.md index 187fd7daba2..1e804b14a46 100644 --- a/website/src/docs/hotchocolate/v16/guides/testing.md +++ b/website/src/docs/hotchocolate/v16/guides/testing.md @@ -17,7 +17,7 @@ public class ProductTests { // arrange var executor = await new ServiceCollection() - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .BuildRequestExecutorAsync(); @@ -30,13 +30,13 @@ public class ProductTests } ``` -You can register any services your resolvers depend on before calling `AddGraphQLServer()`. This lets you inject real or mock implementations. +You can register any services your resolvers depend on before calling `AddGraphQL()`. This lets you inject real or mock implementations. ```csharp // Tests/ProductTests.cs var executor = await new ServiceCollection() .AddSingleton(new FakeCatalogService()) - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .BuildRequestExecutorAsync(); ``` @@ -53,7 +53,7 @@ public async Task Get_Product_Returns_Expected_Data() // arrange var executor = await new ServiceCollection() .AddSingleton(new FakeCatalogService()) - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .BuildRequestExecutorAsync(); @@ -78,7 +78,7 @@ public async Task Get_Product_By_Id() // arrange var executor = await new ServiceCollection() .AddSingleton(new FakeCatalogService()) - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .BuildRequestExecutorAsync(); @@ -111,7 +111,7 @@ public async Task Get_Product_Snapshot() // arrange var executor = await new ServiceCollection() .AddSingleton(new FakeCatalogService()) - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .BuildRequestExecutorAsync(); @@ -137,7 +137,7 @@ public async Task Get_Product_Inline() // arrange var executor = await new ServiceCollection() .AddSingleton(new FakeCatalogService()) - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .BuildRequestExecutorAsync(); @@ -221,7 +221,7 @@ public class SchemaTests { // arrange var executor = await new ServiceCollection() - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .BuildRequestExecutorAsync(); @@ -241,7 +241,7 @@ You can also use `executor.Schema.ToString()` to get the SDL as a string if you public async Task Schema_Contains_Product_Type() { var executor = await new ServiceCollection() - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .BuildRequestExecutorAsync(); @@ -266,7 +266,7 @@ public async Task Logging_Middleware_Does_Not_Alter_Result() { // arrange var executor = await new ServiceCollection() - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .UseField() .BuildRequestExecutorAsync(); @@ -291,7 +291,7 @@ public async Task Error_Filter_Masks_Internal_Errors() { // arrange var executor = await new ServiceCollection() - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .AddErrorFilter(error => error.WithMessage("An unexpected error occurred.")) diff --git a/website/src/docs/hotchocolate/v16/integrations/entity-framework.md b/website/src/docs/hotchocolate/v16/integrations/entity-framework.md index fbcf5f139d7..4d8e254c7a3 100644 --- a/website/src/docs/hotchocolate/v16/integrations/entity-framework.md +++ b/website/src/docs/hotchocolate/v16/integrations/entity-framework.md @@ -43,8 +43,8 @@ builder.Services // ... or AddPooledDbContextFactory. -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .RegisterDbContextFactory() .AddTypes(); ``` @@ -150,8 +150,8 @@ builder.Services.AddDbContextFactory( builder.Services.AddScoped(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypes(); ``` diff --git a/website/src/docs/hotchocolate/v16/integrations/marten.md b/website/src/docs/hotchocolate/v16/integrations/marten.md index d296c1a7411..2cc74bdb798 100644 --- a/website/src/docs/hotchocolate/v16/integrations/marten.md +++ b/website/src/docs/hotchocolate/v16/integrations/marten.md @@ -18,8 +18,8 @@ Install the `HotChocolate.Data.Marten` package: Register the Marten filtering convention on the schema builder: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMartenFiltering(); ``` @@ -31,8 +31,8 @@ builder.Services Register the Marten sorting convention on the schema builder: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMartenSorting(); ``` diff --git a/website/src/docs/hotchocolate/v16/integrations/mongodb.md b/website/src/docs/hotchocolate/v16/integrations/mongodb.md index 1789de3ed98..e82ecdc9941 100644 --- a/website/src/docs/hotchocolate/v16/integrations/mongodb.md +++ b/website/src/docs/hotchocolate/v16/integrations/mongodb.md @@ -40,8 +40,8 @@ public IExecutable GetPersonById( Register the MongoDB filtering convention on the schema builder: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMongoDbFiltering(); ``` @@ -86,8 +86,8 @@ _Mongo Query:_ Register the MongoDB sorting convention on the schema builder: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMongoDbSorting(); ``` @@ -125,8 +125,8 @@ _Mongo Query:_ Register the MongoDB projection convention on the schema builder: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddMongoDbProjections(); ``` @@ -163,8 +163,8 @@ _Mongo Query:_ Register the MongoDB-specific pagination providers: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMongoDbPagingProviders(); ``` diff --git a/website/src/docs/hotchocolate/v16/integrations/spatial-data.md b/website/src/docs/hotchocolate/v16/integrations/spatial-data.md index d34ab05582a..79017948d5f 100644 --- a/website/src/docs/hotchocolate/v16/integrations/spatial-data.md +++ b/website/src/docs/hotchocolate/v16/integrations/spatial-data.md @@ -20,8 +20,8 @@ Install the `HotChocolate.Spatial` package: Register the spatial types on the schema builder: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSpatialTypes(); ``` @@ -32,8 +32,8 @@ If you use data extensions to project data from a database, also install `HotCho Register the data extensions: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSpatialTypes() .AddFiltering() .AddProjections() @@ -163,8 +163,8 @@ scalar Geometry Register the spatial projection handler with `.AddSpatialProjections()`: ```csharp -services - .AddGraphQLServer() +builder + .AddGraphQL() .AddProjections() .AddSpatialTypes() .AddSpatialProjections() @@ -185,8 +185,8 @@ public IQueryable GetPubs(SomeDbContext someDbContext) Entity Framework supports filtering on NetTopologySuite objects. `HotChocolate.Spatial` provides handlers for filtering spatial types on `IQueryable`. Register them with `.AddSpatialFiltering()`: ```csharp -services - .AddGraphQLServer() +builder + .AddGraphQL() .AddFiltering() .AddSpatialTypes() .AddSpatialFiltering() diff --git a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md index d0083340fbf..67aa21dced0 100644 --- a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md +++ b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md @@ -24,7 +24,7 @@ As a bonus, this tightens your development loop, since schema errors surface imm If you're currently using `InitializeOnStartup`, you can safely remove it. If you also provided the `warmup` argument to run a task during the initialization, you can migrate that task to the new `AddWarmupTask` API: ```diff -builder.Services.AddGraphQLServer() +builder.AddGraphQL() - .InitializeOnStartup(warmup: (executor, ct) => { /* ... */ }); + .AddWarmupTask((executor, ct) => { /* ... */ }); ``` @@ -34,7 +34,7 @@ Warmup tasks registered with `AddWarmupTask` run at startup **and** when the sch If you need to preserve lazy initialization for specific scenarios (though this is rarely recommended), you can opt out by setting the `LazyInitialization` option to `true`: ```csharp -builder.Services.AddGraphQLServer() +builder.AddGraphQL() .ModifyOptions(options => options.LazyInitialization = true); ``` @@ -48,7 +48,7 @@ Starting with v16, we're introducing a more explicit model where Hot Chocolate c ```diff builder.Services.AddSingleton(); -builder.Services.AddGraphQLServer() +builder.AddGraphQL() + .AddApplicationService() .AddDiagnosticEventListener() // or @@ -87,7 +87,7 @@ Previously, document and operation cache sizes were globally configured through -builder.Services.AddDocumentCache(200); -builder.Services.AddOperationCache(100); -builder.Services.AddGraphQLServer() +builder.AddGraphQL() + .ModifyOptions(options => + { + options.OperationDocumentCacheSize = 200; @@ -101,8 +101,8 @@ If you were previously accessing `IDocumentCache` or `IPreparedOperationCache` t For instance, to populate the document cache during startup, create a custom `IRequestExecutorWarmupTask` that injects `IDocumentCache`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddWarmupTask(); public class MyWarmupTask(IDocumentCache cache) : IRequestExecutorWarmupTask @@ -125,7 +125,7 @@ Previously, document hash providers were globally configured through the `IServi ```diff -builder.Services.AddSha256DocumentHashProvider(); -builder.Services.AddGraphQLServer() +builder.AddGraphQL() + .AddSha256DocumentHashProvider() ``` @@ -149,8 +149,8 @@ builder.Services + Url = "nats://localhost:4222" + }))); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSubscriptionType() .AddNatsSubscriptions(); ``` @@ -160,7 +160,7 @@ If your code directly references NATS client types, add the `NATS.Client.Core` p ## MaxAllowedNodeBatchSize & EnsureAllNodesCanBeResolved options moved ```diff -builder.Services.AddGraphQLServer() +builder.AddGraphQL() - .ModifyOptions(options => - { - options.MaxAllowedNodeBatchSize = 100; @@ -569,16 +569,16 @@ public JsonElement GetData() => ...; If you previously returned `Dictionary` or other .NET types from a field typed as `Json` or `Any`, you now need to register the JSON type converter explicitly. Without it, the type system has no way to convert arbitrary .NET types to `JsonElement`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddJsonTypeConverter(); ``` For custom reference types that need specific serialization, register a dedicated converter instead: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypeConverter( value => JsonSerializer.SerializeToElement(value.Id)); ``` @@ -729,7 +729,7 @@ The `DefaultHttpMethod` enum has been removed. Use the `UseGet` boolean property `GraphQLServerOptions` (GET requests, multipart, batching, schema requests, etc.) are now configured at the schema level using `ModifyServerOptions` instead of per-endpoint: ```diff -builder.Services.AddGraphQLServer() +builder.AddGraphQL() + .ModifyServerOptions(o => + { + o.EnableGetRequests = false; @@ -755,7 +755,7 @@ In v15, request batching was enabled by default (`EnableBatching = true`). In v1 If you were relying on the previous default, you need to explicitly enable batching: ```csharp -builder.Services.AddGraphQLServer() +builder.AddGraphQL() .ModifyServerOptions(o => o.Batching = AllowedBatching.All); ``` @@ -800,8 +800,8 @@ Accept: application/jsonl; incrementalSpec=v0.1 To restore v0.1 as the server-wide default (used when the client doesn't specify `incrementalSpec`): ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpResponseFormatter( incrementalDeliveryFormat: IncrementalDeliveryFormat.Version_0_1); ``` @@ -809,8 +809,8 @@ builder.Services Or with the options overload: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpResponseFormatter( new HttpResponseFormatterOptions { /* ... */ }, incrementalDeliveryFormat: IncrementalDeliveryFormat.Version_0_1); @@ -871,8 +871,8 @@ If you still need one of the removed scalars, add it back manually in your appli v16 adds a dedicated `AddNodaTime()` extension method that registers all five built-in NodaTime scalars and the related CLR bindings and converters: ```diff -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() - .AddType() - .AddType() - .AddType() @@ -1040,8 +1040,8 @@ var app = builder.Build(); The parser now enforces a maximum recursion depth of **200** by default. Deeply nested selection sets, list values, object values, or type references that exceed this depth are rejected with a `SyntaxException` instead of causing a stack overflow. If your queries legitimately exceed this depth, increase the limit: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyParserOptions(o => { o.MaxAllowedRecursionDepth = 500; @@ -1053,8 +1053,8 @@ builder.Services The parser now limits the number of directives per location (field, operation, fragment definition) to **4** by default. Documents with more directives on a single location are rejected at parse time. If you use more than 4 directives per location, increase the limit: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyParserOptions(o => { o.MaxAllowedDirectives = 8; @@ -1066,8 +1066,8 @@ builder.Services Validation now caps the total number of fragment visits per operation at **1,000** by default. Each time a fragment spread is entered during validation counts as one visit. Queries with deeply nested or heavily reused fragment spreads that exceed this budget will have remaining fragments skipped during validation. If you have complex queries with many fragment spreads, increase the limit: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyValidationOptions(o => { o.MaxAllowedFragmentVisits = 5_000; @@ -1079,7 +1079,7 @@ builder.Services The overlapping-fields-can-be-merged validation rule now caps comparison work at **100,000** by default. Queries that exceed this budget are rejected. If you have very complex queries that trigger this limit, increase it: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .SetMaxAllowedFieldMergeComparisons(200_000); ``` diff --git a/website/src/docs/hotchocolate/v16/performance/automatic-persisted-operations.md b/website/src/docs/hotchocolate/v16/performance/automatic-persisted-operations.md index a561446e922..2569ea571f3 100644 --- a/website/src/docs/hotchocolate/v16/performance/automatic-persisted-operations.md +++ b/website/src/docs/hotchocolate/v16/performance/automatic-persisted-operations.md @@ -49,8 +49,8 @@ Configure your GraphQL server to handle automatic persisted operation requests. 1. Configure the GraphQL server to use the automatic persisted operation pipeline. ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .UseAutomaticPersistedOperationPipeline(); ``` @@ -58,8 +58,8 @@ builder.Services 2. Register the in-memory operation document storage. ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .UseAutomaticPersistedOperationPipeline() .AddInMemoryOperationDocumentStorage(); @@ -68,12 +68,10 @@ builder.Services 3. Add the Microsoft Memory Cache, which the in-memory operation document storage uses as the key-value store. ```csharp -builder.Services - // Global Services - .AddMemoryCache() +builder.Services.AddMemoryCache(); - // GraphQL server configuration - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .UseAutomaticPersistedOperationPipeline() .AddInMemoryOperationDocumentStorage(); @@ -161,12 +159,10 @@ Hot Chocolate is configured to use the MD5 hashing algorithm by default, seriali 1. Add the SHA256 document hash provider to your GraphQL server configuration. ```csharp -builder.Services - // Global Services - .AddMemoryCache() +builder.Services.AddMemoryCache(); - // GraphQL server configuration - .AddGraphQLServer() +builder + .AddGraphQL() .AddSha256DocumentHashProvider(HashFormat.Hex) .AddQueryType() .UseAutomaticPersistedOperationPipeline() @@ -218,12 +214,10 @@ docker run --name redis-stitching -p 7000:6379 -d redis 3. Configure the server to use Redis as operation document storage. ```csharp -builder.Services - // Global Services - .AddMemoryCache() +builder.Services.AddMemoryCache(); - // GraphQL server configuration - .AddGraphQLServer() +builder + .AddGraphQL() .AddSha256DocumentHashProvider(HashFormat.Hex) .AddQueryType() .UseAutomaticPersistedOperationPipeline() diff --git a/website/src/docs/hotchocolate/v16/performance/trusted-documents.md b/website/src/docs/hotchocolate/v16/performance/trusted-documents.md index a0bf7204a13..08434ca845e 100644 --- a/website/src/docs/hotchocolate/v16/performance/trusted-documents.md +++ b/website/src/docs/hotchocolate/v16/performance/trusted-documents.md @@ -37,8 +37,8 @@ The server can be configured to [only execute persisted operations](#blocking-re Instruct your server to handle persisted operations by calling `UsePersistedOperationPipeline()` on the `IRequestExecutorBuilder`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .UsePersistedOperationPipeline(); ``` @@ -64,8 +64,8 @@ To load persisted operation documents from the filesystem, add the following pac Specify where the persisted operation documents are located. The argument to `AddFileSystemOperationDocumentStorage()` specifies the directory containing the operation documents. ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .UsePersistedOperationPipeline() .AddFileSystemOperationDocumentStorage("./persisted_operations"); @@ -88,8 +88,8 @@ To load persisted operation documents from Redis, add the following package: Specify where the persisted operation documents are located. Using `AddRedisOperationDocumentStorage()`, point to a specific Redis database containing the operation documents. ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .UsePersistedOperationPipeline() .AddRedisOperationDocumentStorage(services => @@ -109,8 +109,8 @@ Specify where the persisted operation documents are located. Using `AddAzureBlob > Important: The Azure Blob Storage container must already exist when Hot Chocolate uses it for the first time. ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .UsePersistedOperationPipeline() .AddAzureBlobStorageOperationDocumentStorage(services => @@ -149,8 +149,8 @@ Unlike Redis, a Blob Storage client has no built-in way to set the expiration of By default, Hot Chocolate uses the MD5 hashing algorithm. You can override this default by specifying a `DocumentHashProvider`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() // choose one of the following providers .AddMD5DocumentHashProvider() @@ -174,8 +174,8 @@ AddSha256DocumentHashProvider(HashFormat.Base64) If you want to disallow any dynamic operations, enable `OnlyAllowPersistedDocuments`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() // Omitted for brevity .ModifyRequestOptions( options => options @@ -188,8 +188,8 @@ This blocks any dynamic operations that do not contain the `id` of a persisted o You might still want to allow the execution of dynamic operations in certain circumstances. Override the `OnlyAllowPersistedDocuments` rule on a per-request basis using the `AllowNonPersistedOperation` method on the `OperationRequestBuilder`. Implement a custom [IHttpRequestInterceptor](/docs/hotchocolate/v16/server/interceptors#ihttprequestinterceptor) and call `AllowNonPersistedOperation` if a certain condition is met: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() // Omitted for brevity .AddHttpRequestInterceptor() .ModifyRequestOptions( diff --git a/website/src/docs/hotchocolate/v16/resolvers-and-data/dependency-injection.md b/website/src/docs/hotchocolate/v16/resolvers-and-data/dependency-injection.md index e3bd74cf113..8392900d337 100644 --- a/website/src/docs/hotchocolate/v16/resolvers-and-data/dependency-injection.md +++ b/website/src/docs/hotchocolate/v16/resolvers-and-data/dependency-injection.md @@ -89,8 +89,8 @@ By default, scoped services are scoped to the resolver for queries and DataLoade You can change these defaults globally: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(o => { o.DefaultQueryDependencyInjectionScope = @@ -150,8 +150,8 @@ Hot Chocolate maintains a separate internal service provider for schema services ```csharp builder.Services.AddSingleton(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddApplicationService() .AddDiagnosticEventListener(); ``` @@ -291,8 +291,8 @@ public sealed class SocketSessionInterceptor Register these interceptors for them to take effect: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpRequestInterceptor() .AddSocketSessionInterceptor(); ``` diff --git a/website/src/docs/hotchocolate/v16/resolvers-and-data/fetching-from-databases.md b/website/src/docs/hotchocolate/v16/resolvers-and-data/fetching-from-databases.md index 674ced25a5f..b4296117563 100644 --- a/website/src/docs/hotchocolate/v16/resolvers-and-data/fetching-from-databases.md +++ b/website/src/docs/hotchocolate/v16/resolvers-and-data/fetching-from-databases.md @@ -36,8 +36,8 @@ public static partial class BookQueries ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypes(); ``` @@ -77,8 +77,8 @@ public class BookQueriesType : ObjectType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType(); ``` diff --git a/website/src/docs/hotchocolate/v16/resolvers-and-data/fetching-from-rest.md b/website/src/docs/hotchocolate/v16/resolvers-and-data/fetching-from-rest.md index 6f99f87a351..46fe131d958 100644 --- a/website/src/docs/hotchocolate/v16/resolvers-and-data/fetching-from-rest.md +++ b/website/src/docs/hotchocolate/v16/resolvers-and-data/fetching-from-rest.md @@ -59,8 +59,8 @@ public static partial class TodoQueries // Program.cs builder.Services.AddHttpClient(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddTypes(); ``` @@ -103,8 +103,8 @@ public class TodoQueriesType : ObjectType // Program.cs builder.Services.AddHttpClient(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType(); ``` diff --git a/website/src/docs/hotchocolate/v16/resolvers-and-data/filtering.md b/website/src/docs/hotchocolate/v16/resolvers-and-data/filtering.md index ab5c0132ba1..f0e25d8d75a 100644 --- a/website/src/docs/hotchocolate/v16/resolvers-and-data/filtering.md +++ b/website/src/docs/hotchocolate/v16/resolvers-and-data/filtering.md @@ -16,8 +16,8 @@ Register filtering on the schema: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddFiltering(); ``` @@ -259,8 +259,8 @@ public class CustomFilterConvention : FilterConvention ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddConvention(); ``` @@ -299,8 +299,8 @@ public class EmailAddressOperationFilterInputType : FilterInputType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddFiltering(x => x .AddDefaults() .BindRuntimeType()); diff --git a/website/src/docs/hotchocolate/v16/resolvers-and-data/pagination.md b/website/src/docs/hotchocolate/v16/resolvers-and-data/pagination.md index af0c4c327b1..57522248f7f 100644 --- a/website/src/docs/hotchocolate/v16/resolvers-and-data/pagination.md +++ b/website/src/docs/hotchocolate/v16/resolvers-and-data/pagination.md @@ -202,8 +202,8 @@ Apply consistent pagination settings across your entire schema: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyPagingOptions(opt => { opt.MaxPageSize = 100; @@ -339,8 +339,8 @@ Set `NullOrdering` on `PagingOptions` to match your database: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyPagingOptions(opt => opt.NullOrdering = NullOrdering.NativeNullsLast); ``` @@ -352,16 +352,16 @@ The `UsePaging` middleware provides a unified API that adapts to different data ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMongoDbPagingProviders(); ``` Name a provider to reference it explicitly on specific fields: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMongoDbPagingProviders(providerName: "MongoDB"); ``` diff --git a/website/src/docs/hotchocolate/v16/resolvers-and-data/projections.md b/website/src/docs/hotchocolate/v16/resolvers-and-data/projections.md index 709f16d15bc..d23d8520636 100644 --- a/website/src/docs/hotchocolate/v16/resolvers-and-data/projections.md +++ b/website/src/docs/hotchocolate/v16/resolvers-and-data/projections.md @@ -35,8 +35,8 @@ Register projections on the schema: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddProjections(); ``` diff --git a/website/src/docs/hotchocolate/v16/resolvers-and-data/resolvers.md b/website/src/docs/hotchocolate/v16/resolvers-and-data/resolvers.md index 75ae32c38a2..610dc24c99d 100644 --- a/website/src/docs/hotchocolate/v16/resolvers-and-data/resolvers.md +++ b/website/src/docs/hotchocolate/v16/resolvers-and-data/resolvers.md @@ -64,8 +64,8 @@ public class BookQueriesType : ObjectType ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType(); ``` @@ -222,8 +222,8 @@ public static partial class BookQueries // Program.cs builder.Services.AddScoped(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType(); ``` diff --git a/website/src/docs/hotchocolate/v16/resolvers-and-data/sorting.md b/website/src/docs/hotchocolate/v16/resolvers-and-data/sorting.md index e549596bc3c..b210832d7de 100644 --- a/website/src/docs/hotchocolate/v16/resolvers-and-data/sorting.md +++ b/website/src/docs/hotchocolate/v16/resolvers-and-data/sorting.md @@ -14,8 +14,8 @@ Register sorting on the schema: ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSorting(); ``` @@ -108,8 +108,8 @@ In v16, the `NullOrdering` enum controls how `null` values sort relative to non- ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyPagingOptions(opt => opt.NullOrdering = NullOrdering.NativeNullsLast); ``` @@ -216,8 +216,8 @@ public class CustomSortConvention : SortConvention ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddConvention(); ``` diff --git a/website/src/docs/hotchocolate/v16/securing-your-api/authentication.md b/website/src/docs/hotchocolate/v16/securing-your-api/authentication.md index e1ec9f01e31..a866b53197d 100644 --- a/website/src/docs/hotchocolate/v16/securing-your-api/authentication.md +++ b/website/src/docs/hotchocolate/v16/securing-your-api/authentication.md @@ -62,8 +62,8 @@ app.UseEndpoints(endpoints => ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddAuthorization() .AddQueryType(); ``` @@ -160,8 +160,8 @@ public class HttpRequestInterceptor : DefaultHttpRequestInterceptor ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpRequestInterceptor(); ``` diff --git a/website/src/docs/hotchocolate/v16/securing-your-api/authorization.md b/website/src/docs/hotchocolate/v16/securing-your-api/authorization.md index 3bc5c54c758..3df9199e99a 100644 --- a/website/src/docs/hotchocolate/v16/securing-your-api/authorization.md +++ b/website/src/docs/hotchocolate/v16/securing-your-api/authorization.md @@ -24,8 +24,8 @@ Call `AddAuthorization()` on both `IServiceCollection` (for ASP.NET Core service // Program.cs builder.Services.AddAuthorization(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddAuthorization() .AddQueryType(); ``` diff --git a/website/src/docs/hotchocolate/v16/securing-your-api/cost-analysis.md b/website/src/docs/hotchocolate/v16/securing-your-api/cost-analysis.md index 6dabdb39cb5..3cd60632368 100644 --- a/website/src/docs/hotchocolate/v16/securing-your-api/cost-analysis.md +++ b/website/src/docs/hotchocolate/v16/securing-your-api/cost-analysis.md @@ -267,8 +267,8 @@ Increase the limits if legitimate queries are rejected. Decrease them if you wan ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyCostOptions(options => { options.MaxFieldCost = 5_000; @@ -290,8 +290,8 @@ public static async Task GetReportAsync(/* ... */) Force clients to specify `first` or `last` on paginated fields. Without this, the cost analyzer uses `MaxPageSize` as the assumed list size, which may overestimate the cost of well-behaved queries: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyPagingOptions(opt => opt.RequirePagingBoundaries = true); ``` @@ -344,8 +344,8 @@ Now the cost drops to a level within the default budget. ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyCostOptions(options => { options.MaxFieldCost = 5_000; @@ -389,8 +389,8 @@ If you protect your API through other means (such as trusted documents), you can ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyCostOptions(o => o.EnforceCostLimits = false); ``` diff --git a/website/src/docs/hotchocolate/v16/securing-your-api/index.md b/website/src/docs/hotchocolate/v16/securing-your-api/index.md index bf220c6b6f6..6637f4e6615 100644 --- a/website/src/docs/hotchocolate/v16/securing-your-api/index.md +++ b/website/src/docs/hotchocolate/v16/securing-your-api/index.md @@ -62,8 +62,8 @@ Hot Chocolate uses MD5 for document hashing by default. If you need FIPS complia ```csharp // Program.cs -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSha256DocumentHashProvider(); ``` diff --git a/website/src/docs/hotchocolate/v16/securing-your-api/introspection.md b/website/src/docs/hotchocolate/v16/securing-your-api/introspection.md index 1b81ef8e821..115ca2225c4 100644 --- a/website/src/docs/hotchocolate/v16/securing-your-api/introspection.md +++ b/website/src/docs/hotchocolate/v16/securing-your-api/introspection.md @@ -65,8 +65,8 @@ Note that disabling introspection is not about hiding your schema. When using `M Disable introspection by calling `AllowIntrospection()` with a `false` argument on the `IRequestExecutorBuilder`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AllowIntrospection(false); ``` @@ -75,8 +75,8 @@ While clients can still issue introspection queries, Hot Chocolate returns an er You most likely do not want to disable introspection while developing, so you can toggle it based on the current hosting environment: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AllowIntrospection(builder.Environment.IsDevelopment()); ``` @@ -103,8 +103,8 @@ public class IntrospectionInterceptor : DefaultHttpRequestInterceptor ``` ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() // Disable introspection by default .AllowIntrospection(false) .AddHttpRequestInterceptor(); diff --git a/website/src/docs/hotchocolate/v16/securing-your-api/request-limits.md b/website/src/docs/hotchocolate/v16/securing-your-api/request-limits.md index 09b88240a3c..27c31d9094a 100644 --- a/website/src/docs/hotchocolate/v16/securing-your-api/request-limits.md +++ b/website/src/docs/hotchocolate/v16/securing-your-api/request-limits.md @@ -11,8 +11,8 @@ Parser limits stop malicious payloads before the AST is fully constructed. Becau Configure parser limits with `ModifyParserOptions`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyParserOptions(o => { o.MaxAllowedFields = 1024; @@ -38,8 +38,8 @@ After parsing, the validation layer checks the document against your schema. Som Limits how deeply nested a query can be: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMaxExecutionDepthRule(10); ``` @@ -48,8 +48,8 @@ This prevents queries that traverse deep relationship chains (e.g., `user.friend You can skip introspection fields from the depth count and allow per-request overrides: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMaxExecutionDepthRule( maxAllowedExecutionDepth: 10, skipIntrospectionFields: true, @@ -61,8 +61,8 @@ builder.Services Each time a visitor enters a fragment spread counts as one visit. Queries with deeply nested or repeated fragment spreads can cause exponential visitor work. Hot Chocolate caps the total number of fragment visits per operation at **1,000** by default: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyValidationOptions(o => { o.MaxAllowedFragmentVisits = 1_000; @@ -76,8 +76,8 @@ The "overlapping fields can be merged" validation rule checks that fields with t Hot Chocolate caps the comparison budget at **100,000** by default. Queries exceeding this budget are rejected: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .SetMaxAllowedFieldMergeComparisons(50_000); ``` @@ -88,8 +88,8 @@ Some schemas contain self-referential relationships. For example, a `User` type The field cycle depth rule tracks how many times each schema coordinate (e.g., `User.friends`) appears on the query path: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMaxAllowedFieldCycleDepthRule(defaultCycleLimit: 3); ``` @@ -117,8 +117,8 @@ Adding a fourth level of `friends` would be rejected. You can override the limit for specific coordinates if some relationships are safe to traverse more deeply than others: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddMaxAllowedFieldCycleDepthRule( defaultCycleLimit: 3, coordinateCycleLimits: @@ -134,8 +134,8 @@ This rule is enabled by default in non-development environments as part of the d Documents designed to generate excessive validation errors can consume memory accumulating error objects. The default limit is **5**. When the limit is reached, validation stops early instead of continuing to accumulate errors. ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .SetMaxAllowedValidationErrors(5); ``` @@ -149,8 +149,8 @@ Recursive introspection queries are limited by default: - **List fields** (`fields`, `inputFields`, `interfaces`, `possibleTypes`): 1 level of recursion ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .SetIntrospectionAllowedDepth( maxAllowedOfTypeDepth: 8, maxAllowedListRecursiveDepth: 1); @@ -163,8 +163,8 @@ builder.Services Requests are aborted after 30 seconds by default. The timeout is not enforced when a debugger is attached. ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyRequestOptions(o => { o.ExecutionTimeout = TimeSpan.FromSeconds(10); @@ -176,8 +176,8 @@ builder.Services The `nodes(ids: [ID!]!)` field allows fetching multiple entities at once. The default batch limit is **50**: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddGlobalObjectIdentification(o => o.MaxAllowedNodeBatchSize = 25); ``` diff --git a/website/src/docs/hotchocolate/v16/server/batching.md b/website/src/docs/hotchocolate/v16/server/batching.md index 0b230c5c8d2..42893839ead 100644 --- a/website/src/docs/hotchocolate/v16/server/batching.md +++ b/website/src/docs/hotchocolate/v16/server/batching.md @@ -11,16 +11,16 @@ Variable batching is based on an [open proposal](https://github.com/graphql/grap Batching is disabled by default as a security measure. You enable the types of batching you want to allow through the `AllowedBatching` flags enum using `ModifyServerOptions`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyServerOptions(o => o.Batching = AllowedBatching.VariableBatching); ``` You can combine flags to enable multiple batching modes: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyServerOptions(o => o.Batching = AllowedBatching.VariableBatching | AllowedBatching.RequestBatching); ``` @@ -28,8 +28,8 @@ builder.Services To enable all batching modes at once: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyServerOptions(o => o.Batching = AllowedBatching.All); ``` @@ -40,8 +40,8 @@ builder.Services The maximum number of operations in a single batch defaults to **1024**. You can adjust this limit: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyServerOptions(o => o.MaxBatchSize = 2048); ``` diff --git a/website/src/docs/hotchocolate/v16/server/cache-control.md b/website/src/docs/hotchocolate/v16/server/cache-control.md index 9a006d23dce..735c48dae8e 100644 --- a/website/src/docs/hotchocolate/v16/server/cache-control.md +++ b/website/src/docs/hotchocolate/v16/server/cache-control.md @@ -128,8 +128,8 @@ Then configure the server to register the directive and write the final headers: ```csharp using HotChocolate.Caching; -builder.Services - .AddGraphQLServer()` +builder + .AddGraphQL() .AddQueryType() .UseQueryCache() .AddCacheControl() @@ -148,8 +148,8 @@ builder.Services ```csharp using HotChocolate.Caching; -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .UseQueryCache() .AddCacheControl() @@ -208,8 +208,8 @@ public sealed class NoCacheHeaderInterceptor : DefaultHttpRequestInterceptor Register the interceptor: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpRequestInterceptor(); ``` diff --git a/website/src/docs/hotchocolate/v16/server/command-line.md b/website/src/docs/hotchocolate/v16/server/command-line.md index e547876baab..ea924cffc21 100644 --- a/website/src/docs/hotchocolate/v16/server/command-line.md +++ b/website/src/docs/hotchocolate/v16/server/command-line.md @@ -11,7 +11,7 @@ Here is an example of using the `HotChocolate.AspNetCore.CommandLine` package wi ```csharp var builder = WebApplication.CreateBuilder(args); -builder.Services.AddGraphQLServer().AddQueryType(); +builder.AddGraphQL().AddQueryType(); var app = builder.Build(); diff --git a/website/src/docs/hotchocolate/v16/server/endpoints.md b/website/src/docs/hotchocolate/v16/server/endpoints.md index 728619ded87..662852ad659 100644 --- a/website/src/docs/hotchocolate/v16/server/endpoints.md +++ b/website/src/docs/hotchocolate/v16/server/endpoints.md @@ -294,8 +294,8 @@ Call `MapGraphQLPersistedOperations()` on the `IEndpointRouteBuilder` to expose ```csharp var builder = WebApplication.CreateBuilder(args); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddPersistedOperations(); // Register a persisted operation storage provider @@ -336,12 +336,12 @@ When enabled, requests to `/{operationId}` without an operation name return a `4 For details on storing and managing persisted operations, see [Trusted Documents](/docs/hotchocolate/v16/securing-your-api/trusted-documents). -# AddGraphQLServer Parameters +# AddGraphQL Parameters -The `AddGraphQLServer()` method on `IServiceCollection` accepts parameters that control request parsing and default security behavior. +The `AddGraphQL()` method on `WebApplicationBuilder` accepts parameters that control request parsing and default security behavior. ```csharp -builder.Services.AddGraphQLServer( +builder.AddGraphQL( maxAllowedRequestSize: 20 * 1000 * 1024, // ~20 MB (default) disableDefaultSecurity: false); // default ``` @@ -353,13 +353,13 @@ Controls the maximum allowed size (in bytes) of an incoming GraphQL request body Reduce this value if you expect only small queries and want to protect against excessively large payloads: ```csharp -builder.Services.AddGraphQLServer( +builder.AddGraphQL( maxAllowedRequestSize: 1 * 1000 * 1024); // ~1 MB ``` ## disableDefaultSecurity -When `false` (the default), `AddGraphQLServer()` automatically enables these security features: +When `false` (the default), `AddGraphQL()` automatically enables these security features: - **Cost analysis**: Protects against expensive queries by analyzing the computational cost of each operation. - **Introspection disabled in production**: Introspection is automatically turned off when `IHostEnvironment.IsDevelopment()` returns `false`. @@ -368,8 +368,8 @@ When `false` (the default), `AddGraphQLServer()` automatically enables these sec If you need full control over which security features are enabled, set `disableDefaultSecurity` to `true` and configure each feature individually: ```csharp -builder.Services - .AddGraphQLServer(disableDefaultSecurity: true) +builder + .AddGraphQL(disableDefaultSecurity: true) .AddCostAnalyzer(); // Opt in to specific features manually ``` @@ -442,8 +442,8 @@ app.MapGraphQLWebSocket("/graphql/ws").WithOptions(o => To set defaults that apply to all endpoints, use `ModifyServerOptions` on the request executor builder: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyServerOptions(o => { o.EnableGetRequests = false; diff --git a/website/src/docs/hotchocolate/v16/server/files.md b/website/src/docs/hotchocolate/v16/server/files.md index 8e9b2028c05..545c0845f0b 100644 --- a/website/src/docs/hotchocolate/v16/server/files.md +++ b/website/src/docs/hotchocolate/v16/server/files.md @@ -32,8 +32,8 @@ Hot Chocolate implements the [GraphQL multipart request specification](https://g Register the `Upload` scalar to use file upload streams in your input types or as an argument: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddType(); ``` diff --git a/website/src/docs/hotchocolate/v16/server/http-transport.md b/website/src/docs/hotchocolate/v16/server/http-transport.md index 7a1c1525aeb..e1168c478d7 100644 --- a/website/src/docs/hotchocolate/v16/server/http-transport.md +++ b/website/src/docs/hotchocolate/v16/server/http-transport.md @@ -259,8 +259,8 @@ When the client does not specify `incrementalSpec`, the server default is used. The default incremental delivery format is v0.2. To change it server-wide: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpResponseFormatter( incrementalDeliveryFormat: IncrementalDeliveryFormat.Version_0_1); ``` @@ -268,8 +268,8 @@ builder.Services Or with the options overload: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpResponseFormatter( new HttpResponseFormatterOptions { /* ... */ }, incrementalDeliveryFormat: IncrementalDeliveryFormat.Version_0_1); @@ -362,8 +362,8 @@ You must register the ASP.NET Core WebSocket middleware before calling `MapGraph // Program.cs var builder = WebApplication.CreateBuilder(args); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddSubscriptionType(); @@ -387,8 +387,8 @@ The `GraphQLSocketOptions` class controls WebSocket behavior: Configure these options through `ModifyServerOptions`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyServerOptions(o => { o.Sockets.ConnectionInitializationTimeout = TimeSpan.FromSeconds(30); @@ -467,8 +467,8 @@ Hot Chocolate provides two settings for enforcing preflight headers as a defense Configure these settings through `ModifyServerOptions` or per-endpoint via `WithOptions`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyServerOptions(o => { o.EnforceGetRequestsPreflightHeader = true; diff --git a/website/src/docs/hotchocolate/v16/server/instrumentation.md b/website/src/docs/hotchocolate/v16/server/instrumentation.md index 3814d6fd701..4d392aea915 100644 --- a/website/src/docs/hotchocolate/v16/server/instrumentation.md +++ b/website/src/docs/hotchocolate/v16/server/instrumentation.md @@ -15,8 +15,8 @@ You can implement diagnostic event listeners for the following event types: After creating a diagnostic event listener, register it by calling `AddDiagnosticEventListener` on the `IRequestExecutorBuilder`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddDiagnosticEventListener(); ``` @@ -227,8 +227,8 @@ Add the `HotChocolate.Diagnostics` package to your project: Add `AddInstrumentation` to your GraphQL configuration: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddInstrumentation(); ``` @@ -276,8 +276,8 @@ using OpenTelemetry.Trace; var builder = WebApplication.CreateBuilder(args); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddInstrumentation(); @@ -337,8 +337,8 @@ DataLoader spans: By default, Hot Chocolate does not instrument all execution events. You can increase the level of detail by enabling more instrumentation scopes: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddInstrumentation(o => { @@ -353,8 +353,8 @@ builder.Services You can also include the operation details in the root activity: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddInstrumentation(o => { @@ -393,8 +393,8 @@ Register the custom activity enricher as a singleton and make it available to th ```csharp builder.Services.AddSingleton(); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddApplicationService(); ``` diff --git a/website/src/docs/hotchocolate/v16/server/interceptors.md b/website/src/docs/hotchocolate/v16/server/interceptors.md index 47990a41c15..973e51d5c3d 100644 --- a/website/src/docs/hotchocolate/v16/server/interceptors.md +++ b/website/src/docs/hotchocolate/v16/server/interceptors.md @@ -26,8 +26,8 @@ public class HttpRequestInterceptor : DefaultHttpRequestInterceptor Register your custom `HttpRequestInterceptor`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpRequestInterceptor(); ``` @@ -38,8 +38,8 @@ If needed, you can inject services into your custom `HttpRequestInterceptor` usi For lightweight interception logic, you can register a delegate instead of creating a class. The delegate receives the `HttpContext`, the `IRequestExecutor`, the `OperationRequestBuilder`, and a `CancellationToken`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddHttpRequestInterceptor( async (context, executor, builder, ct) => { @@ -142,8 +142,8 @@ public class SocketSessionInterceptor : DefaultSocketSessionInterceptor Register your custom `SocketSessionInterceptor`: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddSocketSessionInterceptor(); ``` diff --git a/website/src/docs/hotchocolate/v16/server/warmup.md b/website/src/docs/hotchocolate/v16/server/warmup.md index 70599de4c38..6f9aa83da84 100644 --- a/website/src/docs/hotchocolate/v16/server/warmup.md +++ b/website/src/docs/hotchocolate/v16/server/warmup.md @@ -15,8 +15,8 @@ While eager initialization ensures your schema is ready at startup, you might wa Register warmup tasks using the `AddWarmupTask()` method to execute requests against the newly created schema during initialization: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddWarmupTask(async (executor, cancellationToken) => { await executor.ExecuteAsync("{ __typename }", cancellationToken); @@ -57,8 +57,8 @@ await executor.ExecuteAsync(request, cancellationToken); For more control over warmup behavior, implement the `IRequestExecutorWarmupTask` interface: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddWarmupTask(); public class MyWarmupTask : IRequestExecutorWarmupTask @@ -81,16 +81,16 @@ You can register your custom warmup task using either the delegate form or the g ```csharp // Delegate form -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddWarmupTask(async (executor, ct) => { await executor.ExecuteAsync("{ __typename }", ct); }); // Generic form with IRequestExecutorWarmupTask -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddWarmupTask(); ``` @@ -99,8 +99,8 @@ builder.Services If you need to export the schema as part of your startup process (for example, for CI/CD or schema registry integration), use the `ExportSchemaOnStartup()` method: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ExportSchemaOnStartup("./schema.graphql"); ``` @@ -147,8 +147,8 @@ public class MyExecutionEventListener : ExecutionDiagnosticEventListener If you need to defer schema construction until the first request (though this is rarely recommended), you can opt into lazy initialization: ```csharp -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .ModifyOptions(options => options.LazyInitialization = true) ``` diff --git a/website/src/docs/nitro/apis/client-registry.md b/website/src/docs/nitro/apis/client-registry.md index 22a82355324..28b90f54125 100644 --- a/website/src/docs/nitro/apis/client-registry.md +++ b/website/src/docs/nitro/apis/client-registry.md @@ -90,7 +90,7 @@ After installing the package, you need to configure the services in your startup public void ConfigureServices(IServiceCollection services) { services - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .AddNitro(x => // Connect to the client registry { @@ -114,7 +114,7 @@ public void ConfigureServices(IServiceCollection services) > public void ConfigureServices(IServiceCollection services) > { > services -> .AddGraphQLServer() +> .AddGraphQL() > .AddQueryType() > .AddNitro() // Connect to the client registry > .UsePersistedOperationPipeline(); // Enable the persisted operation pipeline @@ -132,7 +132,7 @@ This can be done by setting the `PersistedOperations.OnlyAllowPersistedDocuments public void ConfigureServices(IServiceCollection services) { services - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .AddNitro() // Connect to the client registry .ModifyRequestOptions(x => x.PersistedOperations.OnlyAllowPersistedDocuments = true) @@ -146,7 +146,7 @@ You can also customize the error message that is returned when an ad-hoc operati public void ConfigureServices(IServiceCollection services) { services - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .AddNitro() // Connect to the client registry .ModifyRequestOptions(x => diff --git a/website/src/docs/nitro/apis/fusion.md b/website/src/docs/nitro/apis/fusion.md index 1a102b1ac73..dfda9ed4b0e 100644 --- a/website/src/docs/nitro/apis/fusion.md +++ b/website/src/docs/nitro/apis/fusion.md @@ -47,8 +47,8 @@ dotnet add package ChilliCream.Nitro.Fusion After installing the package, you need to configure the services in your startup class. Below is a sample implementation in C#: ```csharp -builder.Services - .AddFusionGatewayServer() +builder + .AddGraphQLGateway() .ConfigureFromCloud(x => { x.ApiKey = "<>"; @@ -66,8 +66,8 @@ builder.Services > - `NITRO_STAGE` maps to `Stage` > > ```csharp -> builder.Services -> .AddFusionGatewayServer() +> builder +> .AddGraphQLGateway() > .ConfigureFromCloud(); > ``` > @@ -93,7 +93,7 @@ After installing the package, configure the Nitro Services on your schema. Here ```csharp services - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .AddNitro(x => { @@ -266,8 +266,8 @@ To enable telemetry for your gateway and subgraphs, all of them need to be confi To send telemetry data from the gateway you need to add the instrumentation and the exporter to your gateway. ```csharp -builder.Services - .AddFusionGatewayServer() +builder + .AddGraphQLGateway() .ConfigureFromCloud() .CoreBuilder .AddInstrumentation(); @@ -312,7 +312,7 @@ For GraphQL services: ```csharp services - .AddGraphQLServer() + .AddGraphQL() .AddAssetCache() ``` @@ -320,7 +320,7 @@ For fusion services: ```csharp services - .AddFusionGatewayServer() + .AddGraphQLGateway() .ConfigureFromCloud() .AddAssetCache() ``` @@ -331,7 +331,7 @@ This default cache stores data in the `assets` folder of your project. You can c ```csharp services - .AddGraphQLServer() + .AddGraphQL() .AddFileSystemAssetCache(x => { x.CacheDirectory = "cache"; // Your cache folder @@ -352,7 +352,7 @@ Set it up with: ```csharp services - .AddGraphQLServer() + .AddGraphQL() .AddBlobStorageAssetCache(x => { x.ContainerName = "your-container-name"; diff --git a/website/src/docs/nitro/apis/operation-reporting.md b/website/src/docs/nitro/apis/operation-reporting.md index 3736b19f662..79489ed5272 100644 --- a/website/src/docs/nitro/apis/operation-reporting.md +++ b/website/src/docs/nitro/apis/operation-reporting.md @@ -22,7 +22,7 @@ After installing the package, you need to configure the services in your startup public void ConfigureServices(IServiceCollection services) { services - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .AddNitro(x => { @@ -45,7 +45,7 @@ public void ConfigureServices(IServiceCollection services) > public void ConfigureServices(IServiceCollection services) > { > services -> .AddGraphQLServer() +> .AddGraphQL() > .AddQueryType() > .AddNitro() > } diff --git a/website/src/docs/nitro/nitro-services.md b/website/src/docs/nitro/nitro-services.md index eb6a22b8832..281c834fa94 100644 --- a/website/src/docs/nitro/nitro-services.md +++ b/website/src/docs/nitro/nitro-services.md @@ -21,8 +21,8 @@ dotnet add package ChilliCream.Nitro ```csharp var builder = WebApplication.CreateBuilder(args); -builder.Services - .AddGraphQLServer() +builder + .AddGraphQL() .AddQueryType() .AddInstrumentation() // if you want to use telemetry .AddNitro(x => diff --git a/website/src/docs/nitro/open-telemetry/logging.md b/website/src/docs/nitro/open-telemetry/logging.md index 774fe3eb940..6e398a43f28 100644 --- a/website/src/docs/nitro/open-telemetry/logging.md +++ b/website/src/docs/nitro/open-telemetry/logging.md @@ -52,7 +52,7 @@ Below is a sample implementation in C#: public void ConfigureServices(IServiceCollection services) { services - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .AddNitro(x => { @@ -85,7 +85,7 @@ public void ConfigureServices(IServiceCollection services) > public void ConfigureServices(IServiceCollection services) > { > services -> .AddGraphQLServer() +> .AddGraphQL() > .AddQueryType() > .AddNitro() > .AddInstrumentation(); // Enable the graphql telemetry diff --git a/website/src/docs/nitro/open-telemetry/operation-monitoring.md b/website/src/docs/nitro/open-telemetry/operation-monitoring.md index 437de076e6f..b6c993450b1 100644 --- a/website/src/docs/nitro/open-telemetry/operation-monitoring.md +++ b/website/src/docs/nitro/open-telemetry/operation-monitoring.md @@ -32,7 +32,7 @@ After installing the package, you need to configure the services in your startup public void ConfigureServices(IServiceCollection services) { services - .AddGraphQLServer() + .AddGraphQL() .AddQueryType() .AddNitro(x => { @@ -64,7 +64,7 @@ public void ConfigureServices(IServiceCollection services) > public void ConfigureServices(IServiceCollection services) > { > services -> .AddGraphQLServer() +> .AddGraphQL() > .AddQueryType() > .AddNitro() > .AddInstrumentation(); // Enable the graphql telemetry