### Start GraphQL Server Source: https://chillicream.com/docs/hotchocolate/v15/performance/automatic-persisted-operations Starts the .NET GraphQL server. This command is used both for initial setup and after server restarts to verify persistence. ```bash dotnet run ``` -------------------------------- ### Complete Program.cs with OpenTelemetry Setup Source: https://chillicream.com/docs/hotchocolate/v15/server/instrumentation Integrate GraphQL server setup with OpenTelemetry logging and tracing configurations in Program.cs for a complete instrumentation pipeline. ```csharp using OpenTelemetry.Resources; using OpenTelemetry.Trace; var builder = WebApplication.CreateBuilder(args); builder.Services .AddGraphQLServer() .AddQueryType() .AddInstrumentation(); builder.Logging.AddOpenTelemetry( b => b.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Demo"))); builder.Services .AddOpenTelemetryTracing() .WithTracing( b => { b.AddHttpClientInstrumentation(); b.AddAspNetCoreInstrumentation(); b.AddHotChocolateInstrumentation(); b.AddJaegerExporter(); }); var app = builder.Build(); app.MapGraphQL(); app.Run(); ``` -------------------------------- ### Install PostgreSQL Subscription Package Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/subscriptions Install the `HotChocolate.Subscriptions.Postgres` NuGet package to integrate PostgreSQL subscriptions into your Hot Chocolate server. ```bash dotnet add package HotChocolate.Subscriptions.Postgres ``` -------------------------------- ### GraphQL Query Example Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/visitors This is an example of a GraphQL query that will be traversed by the SyntaxWalker. ```graphql query GetFoos { foo { bar } } ``` -------------------------------- ### Run the GraphQL Server Source: https://chillicream.com/docs/hotchocolate/v15/performance/automatic-persisted-operations Start the GraphQL server to enable automatic persisted operations. ```bash dotnet run ``` -------------------------------- ### GraphQL GET Request Example Source: https://chillicream.com/docs/hotchocolate/v15/server/http-transport Illustrates how to send a GraphQL query and variables via HTTP GET request parameters. This is useful for caching. ```http GET /graphql?query=query(%24id%3A%20ID!)%7Buser(id%3A%24id)%7Bname%7D%7D&variables=%7B%22id%22%3A%22QVBJcy5ndXJ1%22%7D` HOST: foo.example ``` -------------------------------- ### Install Entity Framework Core Package Source: https://chillicream.com/docs/hotchocolate/v15/integrations/entity-framework Install the necessary Hot Chocolate package to enable Entity Framework Core integration. ```bash dotnet add package HotChocolate.Data.EntityFramework ``` -------------------------------- ### GraphQL POST Request Example Source: https://chillicream.com/docs/hotchocolate/v15/server/http-transport Demonstrates a typical GraphQL POST request with query and variables. ```http POST /graphql HOST: foo.example Content-Type: application/json { "query": "query($id: ID!){user(id:$id){name}}", "variables": { "id": "QVBJcy5ndXJ1" } } ``` -------------------------------- ### GraphQL Query Example Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/language This is an example of a GraphQL query that can be parsed into an AST. ```graphql query Users { userName address { street nr } } ``` -------------------------------- ### GraphQL Query Example Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation Demonstrates example GraphQL queries to traverse relationships between products and reviews in a federated graph. It shows how to query from a review to its product and vice versa. ```graphql # Example root query fields - not implemented in the tutorial query { # From a review to a product (back to the reviews) review(id: "foo") { id content product { id name price reviews { id content } } } # From a product to a review product(id: "bar") { id name price reviews { id content } } } ``` -------------------------------- ### Setup Minimal API with Hot Chocolate CLI Source: https://chillicream.com/docs/hotchocolate/v15/server/command-line Configure a minimal API with Hot Chocolate's GraphQL server and enable command-line operations. This setup is required to use commands like schema export. ```csharp var builder = WebApplication.CreateBuilder(args); builder.Services.AddGraphQLServer().AddQueryType(); var app = builder.Build(); app.MapGraphQL(); app.RunWithGraphQLCommandsAsync(args); ``` -------------------------------- ### Install Redis Subscription Package Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/subscriptions Add the `HotChocolate.Subscriptions.Redis` NuGet package to your project to enable Redis-based subscriptions. ```bash dotnet add package HotChocolate.Subscriptions.Redis ``` -------------------------------- ### GraphQL Query Example Source: https://chillicream.com/docs/hotchocolate/v15/security/cost-analysis An example GraphQL query demonstrating the structure for querying book titles and author names. The comments indicate the cost associated with each part of the query. ```graphql query { # 1 Query book { # 1 Book title author { # 1 Author name } } } # Type cost: 3 ``` -------------------------------- ### Run the GraphQL Server Source: https://chillicream.com/docs/hotchocolate/v15/get-started-with-graphql-in-net-core Starts the ASP.NET Core application and runs the GraphQL server. This command is used to launch the project from the terminal. ```bash dotnet run --no-hot-reload ``` -------------------------------- ### Install Hot Chocolate Templates Source: https://chillicream.com/docs/hotchocolate/v15/get-started-with-graphql-in-net-core Installs the necessary Hot Chocolate templates for creating new projects. Run this command in your terminal. ```bash dotnet new install HotChocolate.Templates ``` -------------------------------- ### Install Filesystem Operation Package Source: https://chillicream.com/docs/hotchocolate/v15/performance/persisted-operations Installs the necessary NuGet package for enabling filesystem-based operation document storage. Ensure all `HotChocolate.*` packages share the same version. ```bash dotnet add package HotChocolate.PersistedOperations.FileSystem ``` -------------------------------- ### Install NSwag Tool Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/fetching-from-rest Installs the NSwag command-line tool for generating code from OpenAPI specifications. Ensure you are in your GraphQL project directory. ```bash dotnet new tool-manifest dotnet tool install NSwag.ConsoleCore --version 13.10.9 ``` -------------------------------- ### GraphQL Mutation Execution Example Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/mutations Demonstrates how a client can execute multiple mutations serially in a single request. ```graphql mutation { addBook(input: { title: "C# in depth" }) { book { id title } } publishBook(input: { id: 1 }) { book { publishDate } } } ``` -------------------------------- ### Install Marten Integration Package Source: https://chillicream.com/docs/hotchocolate/v15/integrations/marten Install the `HotChocolate.Data.Marten` NuGet package using the .NET CLI. Ensure all Hot Chocolate packages share the same version. ```bash dotnet add package HotChocolate.Data.Marten ``` -------------------------------- ### GraphQL Query Example Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/fetching-from-rest Example GraphQL query to fetch 'todos' and a specific 'todoById' from the integrated REST API. ```graphql { todoById(id: 1) { id isComplete name } todos { id isComplete name } } ``` -------------------------------- ### GraphQL Subscription Example Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/subscriptions This is an example of a GraphQL subscription query. The server-side resolver can check the 'isAuthenticated' field to verify user authentication based on the provided token. ```graphql subscription { onTimedEvent { count isAuthenticated } } ``` -------------------------------- ### Enum Response Example Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/enums Example JSON response for a query returning an enum, showing the enum value as a string. ```json { "data": { "role": "STANDARD" } } ``` -------------------------------- ### Install HotChocolate.ApolloFederation Package Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation Install the necessary package for Apollo Federation v1 support. Ensure all HotChocolate packages share the same version. ```bash dotnet add package HotChocolate.ApolloFederation ``` -------------------------------- ### GraphQL POST Response Example Source: https://chillicream.com/docs/hotchocolate/v15/server/http-transport Shows a successful HTTP 200 OK response for a GraphQL POST request. ```http HTTP/1.1 200 OK Content-Type: application/json { "data": { "user": { "name": "Jon Doe" } } } ``` -------------------------------- ### Install OpenTelemetry Packages Source: https://chillicream.com/docs/hotchocolate/v15/server/instrumentation Add the necessary OpenTelemetry packages for hosting, ASP.NET Core, HTTP client instrumentation, and a Jaeger exporter. Ensure versions are compatible. ```bash dotnet add package OpenTelemetry.Extensions.Hosting --version 1.0.0-rc8 dotnet add package OpenTelemetry.Instrumentation.AspNetCore --version 1.0.0-rc8 dotnet add package OpenTelemetry.Instrumentation.Http --version 1.0.0-rc8 dotnet add package OpenTelemetry.Exporter.Jaeger --version 1.1.0 ``` -------------------------------- ### Install MongoDB Integration Package Source: https://chillicream.com/docs/hotchocolate/v15/integrations/mongodb Install the `HotChocolate.Data.MongoDb` package using the .NET CLI. Ensure all Hot Chocolate packages share the same version. ```bash dotnet add package HotChocolate.Data.MongoDb ``` -------------------------------- ### Middleware Order Example Source: https://chillicream.com/docs/hotchocolate/v15/execution-engine/field-middleware Demonstrates the correct order for applying pagination and filtering middleware. The middleware is defined in the order of execution, but the result flows backward through the chain. ```csharp descriptor .UsePagination() .UseFiltering() .Resolve(context => { // Omitted code for brevity }); ``` -------------------------------- ### Install NodaTime Package Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/scalars Install the NodaTime package for Hot Chocolate to enable NodaTime scalar types. Ensure all HotChocolate.* packages share the same version. ```bash dotnet add package HotChocolate.Types.NodaTime ``` -------------------------------- ### GeoJSON Point Output Example Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example of the JSON output for a GeoJSON Point type, showing the typename, bounding box, coordinates, CRS, and type. ```json { "data": { "pubs": [ { "id": 1, "location": { "__typename": "GeoJSONPointType", "bbox": [12, 12, 12, 12], "coordinates": [[12, 12]], "crs": 4326, "type": "Point" }, "name": "The Winchester" }, { "id": 2, "location": { "__typename": "GeoJSONPointType", "bbox": [43, 534, 43, 534], "coordinates": [[43, 534]], "crs": 4326, "type": "Point" }, "name": "Fountains Head" } ] } } ``` -------------------------------- ### Create a New Hot Chocolate GraphQL Server Project Source: https://chillicream.com/docs/hotchocolate/v15/performance/automatic-persisted-operations Creates a new GraphQL server project using the installed Hot Chocolate templates. ```bash dotnet new graphql ``` -------------------------------- ### Cursor Pagination SQL Example (First Page) Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination SQL query to fetch the first page of results for cursor-based pagination. It uses LIMIT to fetch one extra item to determine the next cursor. ```sql SELECT * FROM Users ORDER BY Id LIMIT %limit ``` -------------------------------- ### GraphQL Query for Field Cost Calculation Example Source: https://chillicream.com/docs/hotchocolate/v15/security/cost-analysis An example GraphQL query demonstrating how field costs are calculated. It shows the individual costs of fields and their nested types, summing up to a total field cost. ```graphql query { book { # 10 (async resolver) title # 0 (scalar) author { # 1 (composite type) name # 0 (scalar) } } } # Field cost: 11 ``` -------------------------------- ### Add JWT Bearer Package Source: https://chillicream.com/docs/hotchocolate/v15/security/authentication Install the JWT Bearer authentication package using the .NET CLI. ```bash dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer ``` -------------------------------- ### Offset Pagination SQL Example Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination Illustrates a basic SQL query for offset-based pagination. This method uses LIMIT and OFFSET to retrieve a subset of data, but can be inefficient for large datasets. ```sql SELECT * FROM Users ORDER BY Id LIMIT %limit OFFSET %offset ``` -------------------------------- ### GraphQL Mutation Query Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/dynamic-schemas Example of a GraphQL mutation query to create a product, specifying the input and the fields to return. ```graphql mutation CreateProduct($input: ProductInput!) { createProduct(input: $input) { id name price } } ``` -------------------------------- ### Source-Generated DataLoader for Products Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/dataloader This example shows a source-generated DataLoader that batches product fetches by ID. It's used in a query resolver to load products efficiently. ```csharp // This is using the source-generated data loader. internal static class ProductDataLoader { [DataLoader] public static async Task> GetProductByIdAsync( IReadOnlyList productIds, CatalogContext context, CancellationToken cancellationToken) => await context.Products .Where(t => productIds.Contains(t.Id)) .ToDictionaryAsync(t => t.Id, cancellationToken); } public class Query { public async Task GetProductByIdAsync( string id, IProductByIdDataLoader productById, CancellationToken cancellationToken) => await productById.LoadAsync(id, cancellationToken); ``` -------------------------------- ### GraphQL Query for Review and Product Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation Example GraphQL query demonstrating how to traverse from a Review to its associated Product in a federated supergraph. ```graphql query { # Example - not explicitly defined in our tutorial review(id: "") { id content product { id name } } } ``` -------------------------------- ### Add Projections Package Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/projections Install the HotChocolate.Data package using the .NET CLI to enable projection capabilities. ```bash dotnet add package HotChocolate.Data ``` -------------------------------- ### Multiple Key Reference Resolvers Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation Example demonstrating how to define multiple reference resolvers for an entity with multiple keys. ```APIDOC ```csharp public class Product { [Key] public string Id { get; set; } [Key] public int Sku { get; set; } [ReferenceResolver] public static Product? ResolveReferenceById(string id) { // Locates the Product by its Id. } [ReferenceResolver] public static Product? ResolveReferenceBySku(int sku) { // Locates the product by SKU } } ``` ``` -------------------------------- ### Define Multiple Reference Resolvers for Product with Different Keys Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation This C# example shows a `Product` entity with two keys (`Id` and `Sku`) and corresponding reference resolvers for each. This allows the supergraph to resolve the entity using either key. ```csharp public class Product { [Key] public string Id { get; set; } [Key] public int Sku { get; set; } [ReferenceResolver] public static Product? ResolveReferenceById(string id) { // Locates the Product by its Id. } [ReferenceResolver] public static Product? ResolveReferenceBySku(int sku) { // Locates the product by SKU } } ``` -------------------------------- ### Add Authorization Package Source: https://chillicream.com/docs/hotchocolate/v15/security/authentication Install the Hot Chocolate Authorization package to enable GraphQL authorization features. ```bash dotnet add package HotChocolate.AspNetCore.Authorization ``` -------------------------------- ### Register DbContext (Before v13) Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-12-to-13 Example of registering a DbContext with the default DbContextKind.Synchronized in v12. ```csharp services.AddGraphQLServer() .RegisterDbContext() ``` -------------------------------- ### Applying ListSize Attribute in Implementation-First C# Source: https://chillicream.com/docs/hotchocolate/v15/security/cost-analysis Configures list size settings for a query resolver using the `ListSize` attribute. This example specifies assumed size, slicing arguments, and sized fields for the `GetBooks` query. ```csharp [QueryType] public static class Query { [ListSize( AssumedSize = 100, SlicingArguments = ["first", "last"], SizedFields = ["edges", "nodes"], RequireOneSlicingArgument = false)] public static IEnumerable GetBooks() => [new("C# in depth.", new Author("Jon Skeet"))]; } ``` -------------------------------- ### Install HotChocolate.Data Package Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/filtering Add the HotChocolate.Data package to your project using the .NET CLI. Ensure all Hot Chocolate packages share the same version. ```bash dotnet add package HotChocolate.Data ``` -------------------------------- ### Configure Max Page Size for Offset Pagination Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination Set options for the `UseOffsetPaging` middleware on a per-field basis using attributes. This example sets the `MaxPageSize` to 100. ```csharp [UseOffsetPaging(MaxPageSize = 100)] ``` -------------------------------- ### Executing Mutations Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/mutations Example of how clients can execute multiple mutations in a single GraphQL request. ```APIDOC ## Executing Mutations ### Description Clients can execute one or more mutations through the mutation type. These mutations are executed serially. ### GraphQL Request Example ```graphql mutation { addBook(input: { title: "C# in depth" }) { book { id title } } publishBook(input: { id: 1 }) { book { publishDate } } } ``` ``` -------------------------------- ### Basic Sorting Query Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/sorting Example of a GraphQL query to sort users by their name in ascending order. ```graphql query { users(order: [{ name: ASC }]) { name address { street } } } ``` -------------------------------- ### Initialize Schema on Startup Source: https://chillicream.com/docs/hotchocolate/v15/server/warmup Chain `InitializeOnStartup()` to `AddGraphQLServer()` to create the schema during server startup. This process is blocking and ensures Kestrel waits until schema construction is complete. ```csharp builder.Services .AddGraphQLServer() .InitializeOnStartup() ``` -------------------------------- ### Run Redis Docker Container Source: https://chillicream.com/docs/hotchocolate/v15/performance/automatic-persisted-operations Starts a Redis Docker container for storing persisted operation documents. Ensure Redis is accessible on localhost:7000. ```bash docker run --name redis-stitching -p 7000:6379 -d redis ``` -------------------------------- ### Enum Variables Example Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/enums Example JSON for variables when using an enum type, showing the enum value as a string. ```json { "role": "ADMINISTRATOR" } ``` -------------------------------- ### Warmup Executor with Callback Source: https://chillicream.com/docs/hotchocolate/v15/server/warmup Use the `warmup` argument in `InitializeOnStartup()` to provide a callback for executing requests against the schema during startup. This pre-initializes in-memory caches like the document and operation cache. The warmup process is blocking. ```csharp builder.Services .AddGraphQLServer() .InitializeOnStartup( warmup: async (executor, cancellationToken) => { await executor.ExecuteAsync("{ __typename }"); }); ``` -------------------------------- ### Add HotChocolate.Spatial Package Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Install the HotChocolate.Spatial package using the .NET CLI to enable spatial data support. ```bash dotnet add package HotChocolate.Spatial ``` -------------------------------- ### GraphQL Query Example Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/projections This GraphQL query specifies the exact data fields to be retrieved, demonstrating the principle of avoiding over-fetching. ```graphql { users { email address { street } } } ``` -------------------------------- ### GraphQL Query with Filtering, Sorting, and Paging Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/projections An example GraphQL query demonstrating filtering by name, ordering by name and email, and paginating results. ```graphql { users( where: { name: { eq: "ChilliCream" } } order: [{ name: DESC }, { email: DESC }] ) { nodes { email addresses(where: { street: { eq: "Sesame Street" } }) { street } } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ``` -------------------------------- ### SQL Query for Pubs Projection Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example SQL query corresponding to the projection of Pubs data, selecting Id, Location, and Name. ```sql SELECT p."Id", p."Location", p."Name" FROM "Pubs" AS p ``` -------------------------------- ### Example GraphQL Query Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/queries Demonstrates how a client can request specific data fields from the defined query type. Queries are executed side-effect free and can be parallelized. ```graphql query { books { title author } author(id: 1) { name } } ``` -------------------------------- ### Configure GraphQL Services (New) Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-10-to-11 Demonstrates the new configuration API using `AddGraphQLServer` for setting up GraphQL services in version 11. This replaces `SchemaBuilder` and consolidates configuration. ```csharp services .AddGraphQLServer() .AddQueryType() .AddMutationType() ... ``` -------------------------------- ### GraphQL GET Request Source: https://chillicream.com/docs/hotchocolate/v15/server/http-transport GraphQL GET request over HTTP. Query parameters are used for the query and variables, making it cacheable. ```APIDOC ## GET /graphql ### Description Executes a GraphQL query using an HTTP GET request. The query and variables are passed as URL query parameters, which can be beneficial for caching. ### Method GET ### Endpoint /graphql ### Parameters #### Query Parameters - **query** (string) - Required - The GraphQL query string, URL-encoded. - **variables** (string) - Optional - A JSON string representing the variables for the query, URL-encoded. - **operationName** (string) - Optional - The name of the operation to execute, if the query contains multiple operations. ### Request Example ```http GET /graphql?query=query(%24id%3A%20ID!)%7Buser(id%3A%24id)%7Bname%7D%7D&variables=%7B%22id%22%3A%22QVBJcy5ndXJ1%22%7D HOST: foo.example ``` ### Response #### Success Response (200) - **data** (object) - The result of the GraphQL query. #### Response Example ```json { "data": { "user": { "name": "Jon Doe" } } } ``` ``` -------------------------------- ### Cursor Pagination SQL Example (Subsequent Pages) Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination SQL query for fetching subsequent pages in cursor-based pagination. It uses a WHERE clause with the cursor to efficiently retrieve data, leveraging database indexes. ```sql SELECT * FROM Users WHERE Id >= %cursor ORDER BY Id LIMIT %limit ``` -------------------------------- ### Configure Batch Serialization (Before v13) Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-12-to-13 Example of configuring batch serialization to JsonArray using the now-removed IHttpResultSerializer in versions prior to v13. ```csharp services.AddHttpResultSerializer(batchSerialization: HttpResultSerialization.JsonArray) ``` -------------------------------- ### Add HotChocolate.Data.Spatial Package Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Install the HotChocolate.Data.Spatial package if you are using data extensions for spatial data projection from a database. ```bash dotnet add package HotChocolate.Data.Spatial ``` -------------------------------- ### Create a New Hot Chocolate GraphQL Project Source: https://chillicream.com/docs/hotchocolate/v15/get-started-with-graphql-in-net-core Bootsraps a new ASP.NET Core project with Hot Chocolate pre-configured. This command creates a project directory with the specified name. ```bash dotnet new graphql --name GettingStarted ``` -------------------------------- ### Basic Delegate Resolver Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/resolvers A minimal example of defining a field resolver using a delegate. This is a foundational pattern for inline resolver definitions. ```csharp descriptor.Field("foo").Resolve(context => ) ``` -------------------------------- ### Enable XML Documentation File Generation Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/documentation Configure your `.csproj` file to generate an XML documentation file by setting `` to `true`. Optionally, use `` to suppress warnings for missing documentation strings. ```xml true $(NoWarn);1591 ``` -------------------------------- ### GraphQL Query Example Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/resolvers A sample GraphQL query to fetch user information, including nested company details. This query structure dictates the resolver tree that Hot Chocolate will traverse. ```graphql query { me { name company { id name } } } ``` -------------------------------- ### Allow Only Queries via HTTP GET Source: https://chillicream.com/docs/hotchocolate/v15/server/endpoints Configures the GraphQL endpoint to allow only query operations via HTTP GET requests. Mutations are disallowed. ```csharp endpoints.MapGraphQL().WithOptions(new GraphQLServerOptions { AllowedGetOperations = AllowedGetOperations.Query }); ``` -------------------------------- ### C# Implementation with UsePaging Middleware Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination Demonstrates how to use the `[UsePaging]` attribute in a C# resolver to enable pagination for a collection of users. ```APIDOC ## C# Implementation ### Basic Usage ```csharp public class Query { [UsePaging] public IEnumerable GetUsers(IUserRepository repository) => repository.GetUsers(); } ``` **Note:** The resolver must return an `IEnumerable` or `IQueryable` for the `[UsePaging]` middleware to function correctly. ``` -------------------------------- ### Combine Paging, Projection, Filtering, and Sorting Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/projections Demonstrates the correct middleware order for combining paging, projection, filtering, and sorting on a queryable collection. ```csharp public class Query { [UsePaging] [UseProjection] [UseFiltering] [UseSorting] public IQueryable GetUsers([ScopedService] SomeDbContext someDbContext) { return someDbContext.Users; } } public class User { public int Id { get; set; } public string Name { get; set; } public string Email { get; set; } [UseFiltering] [UseSorting] public ICollection
Addresses { get; set; } } ``` -------------------------------- ### Disable HTTP GET Requests Source: https://chillicream.com/docs/hotchocolate/v15/server/endpoints Configures the GraphQL endpoint to disable handling GraphQL operations sent via HTTP GET requests. This means operations can only be sent via HTTP POST. ```csharp endpoints.MapGraphQL().WithOptions(new GraphQLServerOptions { EnableGetRequests = false }); ``` -------------------------------- ### Manual DataLoader Implementation Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/dataloader This is a manual implementation of a DataLoader for fetching products by ID. It demonstrates how to override `LoadBatchAsync` to handle batching logic. ```csharp public class ProductByIdDataLoader : BatchDataLoader { private readonly IServiceProvider _services; public ProductDataLoader1( IServiceProvider services, IBatchScheduler batchScheduler, DataLoaderOptions options) : base(batchScheduler, options) { _services = services; } protected override async Task> LoadBatchAsync( IReadOnlyList keys, CancellationToken cancellationToken) { await using var scope = _services.CreateAsyncScope(); await using var context = scope.ServiceProvider.GetRequiredService(); return await context.Products .Where(t => keys.Contains(t.Id)) .ToDictionaryAsync(t => t.Id, cancellationToken); } } ``` -------------------------------- ### Cursor Pagination SQL Example (Combined Fields) Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination SQL query for cursor-based pagination when sorting by multiple fields, including a non-unique one like Birthday. It uses a composite cursor (Birthday and Id) to ensure correct ordering and uniqueness. ```sql SELECT * FROM Users WHERE (Birthday >= %cursorBirthday OR (Birthday = %cursorBirthday AND Id >= %cursorId)) ORDER BY Birthday, Id LIMIT %limit ``` -------------------------------- ### Add Redis Subscription Provider Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/subscriptions Configure the Redis subscription provider for reliable event handling across multiple server instances. Ensure the `HotChocolate.Subscriptions.Redis` package is installed. ```csharp builder.Services .AddGraphQLServer() .AddRedisSubscriptions((sp) => ConnectionMultiplexer.Connect("host:port")); ``` -------------------------------- ### Configure GraphQL Services (Old) Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-10-to-11 Illustrates the previous method of configuring GraphQL services using `SchemaBuilder` in version 10. ```csharp services.AddGraphQL(sp => SchemaBuilder.New() .AddServices(sp) .AddQueryType() .AddMutationType() ... .Create()); ``` -------------------------------- ### Configuring Paging Options Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination Illustrates how to configure options for the `[UsePaging]` middleware, such as setting a maximum page size. ```APIDOC ## Paging Options ### C# Implementation ```csharp [UsePaging(MaxPageSize = 100)] ``` This sets the maximum allowed page size to 100. ``` -------------------------------- ### GraphQL Query for MongoDB Projections Source: https://chillicream.com/docs/hotchocolate/v15/integrations/mongodb Example GraphQL query requesting specific fields for persons and their addresses. ```graphql query GetPersons { persons { name addresses { city } } } ``` -------------------------------- ### Defining a Mutation Type (C#) Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/mutations Example of how to define a mutation type in C# using the implementation-first approach. ```APIDOC ## Defining a Mutation Type (C#) ### Description This example shows how to define a mutation type in C# using the implementation-first approach. ### C# Implementation ```csharp public class Mutation { public async Task AddBook(Book book) { // Omitted code for brevity } } ``` ### Registering the Mutation Type ```csharp builder.Services .AddGraphQLServer() .AddMutationType(); ``` **Note:** Only one mutation type can be registered using `AddMutationType()`. For splitting mutations into multiple classes, use type extensions. ``` -------------------------------- ### Configure GraphQL Middleware (New) Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-10-to-11 Demonstrates the updated approach to integrating the GraphQL middleware using ASP.NET Core's endpoint routing, including `app.UseRouting()` and `app.UseEndpoints()`. ```csharp app.UseRouting(); // routing area app.UseEndpoints(x => x.MapGraphQL()); ``` -------------------------------- ### Register DataLoaders using extension methods Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-14-to-15 DataLoaders should not be manually registered with dependency injection. Use the provided extension methods from GreenDonut. Source-generated DataLoaders are recommended to automate registration. ```csharp services.AddDataLoader(); services.AddDataLoader(); services.AddDataLoader(sp => ....); ``` -------------------------------- ### C# Implementation with XML Documentation Comments Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/documentation Explains how to leverage C# XML documentation comments to automatically generate schema descriptions, with configuration options. ```APIDOC ## C# Implementation with XML Documentation Comments ### Description This section shows how to use C# XML documentation comments to automatically generate descriptions for your GraphQL schema. This requires enabling `GenerateDocumentationFile` in your project settings. ### Code Example ```csharp /// /// An object type /// public class User { /// /// A field /// public string Username { get; set; } } /// /// An enum /// public enum UserRole { /// /// An enum value /// Administrator } public class Query { /// /// A query field /// /// An argument public User GetUser(string username) { // Omitted code for brevity } } ``` ### Project Configuration ```xml true $(NoWarn);1591 ``` ### Disabling XML Documentation ```csharp builder.Services .AddGraphQLServer() .ModifyOptions(opt => opt.UseXmlDocumentation = false); ``` ``` -------------------------------- ### Registering a Service for Dependency Injection Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/resolvers Register a service, such as UserService, as a singleton to make it available for injection into resolvers. ```csharp var builder = WebApplication.CreateBuilder(args); builder.Services.AddSingleton() builder.Services .AddGraphQLServer() .AddQueryType(); ``` -------------------------------- ### Direct Request Execution Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-10-to-11 Shows how to directly build and execute a request using `ExecuteRequestAsync`. ```csharp IExecutionResult result = await new ServiceCollection() .AddGraphQL() .AddQueryType() .ExecuteRequestAsync("{ __typename }"); result.ToJson().MatchSnapshot(); ``` -------------------------------- ### GraphQL Query with Visitor Action Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/visitors An example GraphQL query demonstrating the use of the `@onEnter` directive with the `CONTINUE` visitor action. This controls the visitation flow, allowing traversal into the 'baz' field's selection set. ```graphql query { foo { bar baz @onEnter(return: CONTINUE) { quux } qux } } ``` -------------------------------- ### Configure GraphQL Middleware (Old) Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-10-to-11 The previous method of applying the GraphQL middleware using `app.UseGraphQL()`. ```csharp app.UseGraphQL(); ``` -------------------------------- ### Register Apollo Federation Services Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation Register the Apollo Federation services with the GraphQL server after installing the package. ```csharp builder.Services .AddGraphQLServer() .AddApolloFederation(); ``` -------------------------------- ### Registering Entities with Apollo Federation Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation How to register an entity type with Apollo Federation in your GraphQL server setup. ```APIDOC ## Register the entity After our type has a key or keys and a reference resolver defined, you'll register the type in the GraphQL schema. ```csharp builder.Services .AddGraphQLServer() .AddApolloFederation() .AddType() // other registrations... ; ``` ``` -------------------------------- ### GraphQL Query for MongoDB Sorting Source: https://chillicream.com/docs/hotchocolate/v15/integrations/mongodb Example GraphQL query demonstrating sorting by name and nested address city. ```graphql query GetPersons { persons(order: [{ name: ASC }, { mainAddress: { city: DESC } }]) { name addresses { street city } } } ``` -------------------------------- ### GraphQL Query for MongoDB Filtering Source: https://chillicream.com/docs/hotchocolate/v15/integrations/mongodb Example GraphQL query demonstrating filtering by name and nested address properties. ```graphql query GetPersons { persons( where: { name: { eq: "Yorker Shorton" } addresses: { some: { street: { eq: "04 Leroy Trail" } } } } ) { name addresses { street city } } } ``` -------------------------------- ### Custom Pagination Logic with Connection Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination Demonstrates how to implement custom pagination logic by directly returning a `Connection` object. ```APIDOC ## Custom Pagination Logic ### C# Implementation ```csharp public class Query { [UsePaging] public Connection GetUsers(string? after, int? first, string sortBy) { // get users using the above arguments IEnumerable users = null; var edges = users.Select(user => new Edge(user, user.Id)) .ToList(); var pageInfo = new ConnectionPageInfo(false, false, null, null); var connection = new Connection(edges, pageInfo, ct => ValueTask.FromResult(0)); return connection; } } ``` ``` -------------------------------- ### Define a Reference Resolver for Product (Implementation-First) Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation This C# code defines a `[ReferenceResolver]` for the `Product` entity. It uses a `ProductBatchDataLoader` to fetch the product by its ID. Ensure the parameter name matches the `[Key]` field. ```csharp public class Product { [ID] [Key] public string Id { get; set; } public string Name { get; set; } public float Price { get; set; } [ReferenceResolver] public static async Task ResolveReference( // Represents the value that would be in the Id property of a Product string id, // Example of a service that can resolve the Products ProductBatchDataLoader dataLoader ) { return await dataloader.LoadAsync(id); } } ``` -------------------------------- ### GraphQL Query Using a Custom Directive Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/directives An example GraphQL query that utilizes a custom directive named '@my' on a field. ```graphql query foo { bar @my } ``` -------------------------------- ### Simplify Gateway Schema Configuration Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-10-to-11 Gateway schema configuration is now more straightforward. Use `AddGraphQLServer` and `AddType` for registering types. ```csharp services.AddStitchedSchema(x => x.AddSchemaConfiguration(y => y.RegisterType())); ``` ```csharp services .AddGraphQLServer() .AddType(); ``` -------------------------------- ### Upload List of Files Source: https://chillicream.com/docs/hotchocolate/v15/server/files To upload multiple files, use `List` or `ListType` as the argument type. ```csharp public async Task UploadFilesAsync(List files) { // Handle list of files return true; } ``` -------------------------------- ### Enable Mutation Conventions Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/mutations Enable mutation conventions in your GraphQL server setup. This is typically done during service configuration. ```csharp service .AddGraphQLServer() .AddMutationConventions() ... ``` -------------------------------- ### Implement Offset Pagination Middleware Source: https://chillicream.com/docs/hotchocolate/v15/fetching-data/pagination Apply the `UseOffsetPaging` middleware to your resolver. The middleware requires the resolver to return an `IEnumerable` or `IQueryable` and will apply pagination arguments. ```csharp public class Query { [UseOffsetPaging] public IEnumerable GetUsers(IUserRepository repository) => repository.GetUsers(); } ``` -------------------------------- ### Configure GraphQL HTTP Endpoint Options Source: https://chillicream.com/docs/hotchocolate/v15/server/endpoints Customizes the HTTP endpoint behavior using GraphQLHttpOptions, such as disabling GET requests. ```csharp endpoints.MapGraphQLHttp("/graphql/http").WithOptions(new GraphQLHttpOptions { EnableGetRequests = false }); ``` -------------------------------- ### Register Custom HTTP Response Formatter with Options Source: https://chillicream.com/docs/hotchocolate/v15/server/http-transport Demonstrates registering a custom HTTP response formatter that accepts `HttpResponseFormatterOptions`. ```csharp var options = new HttpResponseFormatterOptions(); builder.Services.AddHttpResponseFormatter(_ => new CustomHttpResponseFormatter(options)); public class CustomHttpResponseFormatter : DefaultHttpResponseFormatter { public CustomHttpResponseFormatter(HttpResponseFormatterOptions options) : base(options) { } } ``` -------------------------------- ### Map GraphQL HTTP Endpoint Source: https://chillicream.com/docs/hotchocolate/v15/server/endpoints Exposes a GraphQL server over HTTP at a specified endpoint, allowing GET and POST requests. ```csharp app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGraphQLHttp("/graphql/http"); }); ``` -------------------------------- ### GraphQLServerOptions - EnableGetRequests Source: https://chillicream.com/docs/hotchocolate/v15/server/endpoints Controls whether the GraphQL server can handle GraphQL operations sent via HTTP GET requests. ```APIDOC ## GraphQLServerOptions - EnableGetRequests ### Description Controls whether the GraphQL server accepts operations via HTTP GET requests. ### Method `IEndpointRouteBuilder.MapGraphQL().WithOptions(new GraphQLServerOptions { EnableGetRequests = false })` ### Parameters #### Options - **EnableGetRequests** (bool) - `true` to enable GET requests, `false` to disable. ``` -------------------------------- ### GraphQL Query for Overlaps Filter Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example GraphQL query to filter a county based on whether its area overlaps with a specified polygon. ```graphql { county( where: { area: { overlaps: { geometry: { type: Polygon, coordinates: [[1, 1], ....] } } } }){ id name area } } ``` -------------------------------- ### GraphQL Query for Intersects Filter Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example GraphQL query to filter roads based on whether they intersect with a specified line string. ```graphql { roads( where: { road: { intersects: { geometry: { type: LineString, coordinates: [[1, 1], ....] } } } }){ id name road } } ``` -------------------------------- ### Define User and IUserRepository Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/executable Defines a User class and an IUserRepository interface with a method to find all users as an IExecutable. ```csharp public class User { public string Name { get; } } public interface IUserRepository { public IExecutable FindAll(); } ``` -------------------------------- ### GraphQL Query for Touches Filter Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example GraphQL query to filter counties based on whether their area touches a specified polygon. ```graphql { counties( where: { area: { touches: { geometry: { type: Polygon, coordinates: [[1, 1], ....] } } } }){ id name area } } ``` -------------------------------- ### Enable GraphQL Server Instrumentation Source: https://chillicream.com/docs/hotchocolate/v15/server/instrumentation Configure the GraphQL server to use instrumentation by calling AddInstrumentation() during service registration in Program.cs. ```csharp builder.Services .AddGraphQLServer() .AddQueryType() .AddInstrumentation(); ``` -------------------------------- ### GraphQL Query for Contains Filter Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example GraphQL query to filter counties based on whether their area contains a specified point. ```graphql { counties( where: { area: { contains: { geometry: { type: Point, coordinates: [1, 1] } } } } ) { id name area } } ``` -------------------------------- ### SQL Query for ST_Within Operation Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example SQL query using the ST_Within function to filter data based on spatial geometry. ```sql SELECT c."Id", c."Name", c."Area" FROM "Counties" AS c WHERE ST_Within(c."Area", @__p_0) ``` -------------------------------- ### Add PostgreSQL Subscription Provider Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/subscriptions Set up the PostgreSQL subscription provider to leverage PostgreSQL's `LISTEN/NOTIFY` for real-time updates. This requires the `HotChocolate.Subscriptions.Postgres` package. ```csharp builder.Services .AddGraphQLServer() .AddQueryType() // every GraphQL server needs a query .AddSubscriptionType .AddPostgresSubscriptions((sp, options) => options.ConnectionFactory = ct => /*create your connection*/); ``` -------------------------------- ### Chain Descriptor Attributes Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/custom-attributes Attributes can be chained to apply multiple middleware configurations in order. This example chains paging, filtering, and sorting. ```csharp public class Query { [UsePaging] [UseFiltering] [UseSorting] public IQueryable GetFoos() { ... } } ``` ```csharp public class QueryType : ObjectType { protected override void Configure(IObjectTypeDescriptor descriptor) { descriptor.Field(t => t.Foos) .UsePaging>() .UseFiltering() .UseSorting(); } } ``` -------------------------------- ### Configure DbContextFactory Source: https://chillicream.com/docs/hotchocolate/v15/integrations/entity-framework Configure the `IDbContextFactory` for your application's DbContext. This is typically done during application startup. ```csharp var builder = WebApplication.CreateBuilder(args); builder.Services.AddDbContextFactory( options => options.UseSqlServer("YOUR_CONNECTION_STRING")); builder.Services.AddScoped() builder.Services .AddGraphQLServer() .AddTypes(); ``` -------------------------------- ### Apply UseSortingAttribute to a Method Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/custom-attributes Use the UseSortingAttribute to enable the sorting middleware for a queryable field. Ensure the HotChocolate.Types.Sorting NuGet package is installed. ```csharp public class Query { [UseSorting] public IQueryable GetFoos() { ... } } ``` -------------------------------- ### Visitor Method Call Sequence Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/visitors Illustrates the sequence of method calls made by the SyntaxWalker when visiting a GraphQL AST node. Includes OnBeforeEnter, Enter, OnAfterEnter, VisitChildren, OnBeforeLeave, Leave, and OnAfterLeave. ```csharp csharp±OnBeforeEnter(OperationDefinitionNode node, TContext context) ``` ```csharp csharp±Enter(OperationDefinitionNode node, TContext context) ``` ```csharp csharp±OnAfterEnter(OperationDefinitionNode node, TContext context) ``` ```csharp csharp±VisitChildren(OperationDefinitionNode node, TContext context) ``` ```csharp csharp±OnBeforeEnter(ObjectFieldNode node, TContext context) ``` ```csharp csharp±Enter(ObjectFieldNode node, TContext context) ``` ```csharp csharp±OnAfterEnter(ObjectFieldNode node, TContext context) ``` ```csharp csharp±VisitChildren(ObjectFieldNode node, TContext context) ``` ```csharp csharp±OnBeforeLeave(ObjectFieldNode node, TContext context) ``` ```csharp csharp±Leave(ObjectFieldNode node, TContext context) ``` ```csharp csharp±OnAfterLeave(ObjectFieldNode node, TContext context) ``` ```csharp csharp±OnBeforeLeave(OperationDefinitionNode node, TContext context) ``` ```csharp csharp±Leave(OperationDefinitionNode node, TContext context) ``` ```csharp csharp±OnAfterLeave(OperationDefinitionNode node, TContext context) ``` -------------------------------- ### Apply UseFilteringAttribute to a Method Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/custom-attributes Use the UseFilteringAttribute to enable the filtering middleware for a queryable field. Ensure the HotChocolate.Types.Filters NuGet package is installed. ```csharp public class Query { [UseFiltering] public IQueryable GetFoos() { ... } } ``` -------------------------------- ### Apply UsePagingAttribute to a Method Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/custom-attributes Use the UsePagingAttribute to enable the paging middleware for a queryable field. Ensure the HotChocolate.Types.Paging NuGet package is installed. ```csharp public class Query { [UsePaging] public IQueryable GetFoos() { ... } } ``` -------------------------------- ### GraphQLServerOptions - AllowedGetOperations Source: https://chillicream.com/docs/hotchocolate/v15/server/endpoints Configures which types of GraphQL operations (Query, Mutation) are allowed via HTTP GET requests when `EnableGetRequests` is true. ```APIDOC ## GraphQLServerOptions - AllowedGetOperations ### Description Configures allowed operations for HTTP GET requests when `EnableGetRequests` is true. ### Method `IEndpointRouteBuilder.MapGraphQL().WithOptions(new GraphQLServerOptions { AllowedGetOperations = AllowedGetOperations.QueryAndMutation })` ### Parameters #### Options - **AllowedGetOperations** (AllowedGetOperations) - Specifies allowed operations. Options include `AllowedGetOperations.Query` (default) and `AllowedGetOperations.QueryAndMutation`. ``` -------------------------------- ### Configure Paging Options with ModifyPagingOptions Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-13-to-14 This code shows the recommended way to configure pagination options using a delegate. This approach offers more flexibility. ```csharp builder.Services .AddGraphQLServer() .ModifyPagingOptions(opt => { opt.MaxPageSize = 100; opt.DefaultPageSize = 25; }); ``` -------------------------------- ### GraphQL Mutation Convention (SDL) Source: https://chillicream.com/docs/hotchocolate/v15/defining-a-schema/mutations Illustrates the convention of using a single 'input' argument and a payload object for mutations. ```graphql type Mutation { updateUserName(input: UpdateUserNameInput!): UpdateUserNamePayload! } input UpdateUserNameInput { userId: ID! username: String! } type UpdateUserNamePayload { user: User } ``` -------------------------------- ### Register Apollo Federation Services Source: https://chillicream.com/docs/hotchocolate/v15/api-reference/apollo-federation This C# code snippet demonstrates how to register Apollo Federation services and the `Product` type with the GraphQL server using `AddGraphQLServer()` and `AddApolloFederation()`. ```csharp builder.Services .AddGraphQLServer() .AddApolloFederation() .AddType() // other registrations... ; ``` -------------------------------- ### Implement ServerDiagnosticEventListener Source: https://chillicream.com/docs/hotchocolate/v15/server/instrumentation Inherit from `ServerDiagnosticEventListener` and override methods to instrument server events. This example shows overriding `ExecuteHttpRequest` for GraphQL over HTTP requests. ```csharp public class MyServerEventListener : ServerDiagnosticEventListener { public override IDisposable ExecuteHttpRequest(IRequestContext context) { // Omitted code for brevity } } ``` -------------------------------- ### SQL Query for NOT ST_Within Operation Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example SQL query using the negation of ST_Within to find data outside a specified spatial geometry. ```sql SELECT c."Id", c."Name", c."Area" FROM "Counties" AS c WHERE NOT ST_Within(c."Area", @__p_0) ``` -------------------------------- ### Schema Snapshot Test (Old) Source: https://chillicream.com/docs/hotchocolate/v15/migrating/migrate-from-10-to-11 Demonstrates the old way of performing schema snapshot tests using `SchemaBuilder` and `ToString()`. ```csharp SchemaBuilder.New() .AddQueryType() .Create() .ToString() .MatchSnapshot(); ``` -------------------------------- ### GraphQL Query with Within Distance Filter Source: https://chillicream.com/docs/hotchocolate/v15/integrations/spatial-data Example GraphQL query to find pubs whose location is within a specified geometry and distance. ```graphql { pubs( where: { location: { within: { geometry: { type: Point, coordinates: [1, 1] }, lt: 120 } } } ) { id name location } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.