CSHARP_CI Telegram 1434
🍫 Hot Chocolate + GraphQL + .NET: Быстрый старт

Если ты хочешь использовать GraphQL в .NET‑проектах — обрати внимание на Hot Chocolate от ChilliCream. Это мощный, удобный и активно развиваемый GraphQL-сервер для .NET.

📎 Полный гайд: [antondevtips.com/blog/getting-started-with-hot-chocolate-graphql](https://antondevtips.com/blog/getting-started-with-hot-chocolate-graphql)

⚙️ Шаг 1: Установка

Создай новый ASP.NET Core проект:


dotnet new web -n Demo
cd Demo
dotnet add package HotChocolate.AspNetCore


🧱 Шаг 2: Настройка GraphQL
В файле Program.cs добавь следующее:


var builder = WebApplication.CreateBuilder(args);

builder.Services
.AddGraphQLServer()
.AddQueryType<Query>();

var app = builder.Build();

app.MapGraphQL();
app.Run();

Создай класс Query.cs:



public class Query
{
public Book GetBook() => new Book
{
Title = "C# in Depth",
Author = new Author { Name = "Jon Skeet" }
};
}


И добавь модели:


public class Book
{
public string Title { get; set; }
public Author Author { get; set; }
}

public class Author
{
public string Name { get; set; }
}


📬 Шаг 3: Запрос в браузере
Открой http://localhost:5000/graphql и выполни GraphQL-запрос:



{
book {
title
author {
name
}
}
}

🧠 Почему стоит выбирать Hot Chocolate?

- Поддержка annotation-based, code-first и schema-first подходов

- Отличная интеграция с EF Core

- Встроенная фильтрация, сортировка, пагинация, DataLoader

- Поддержка подписок (Subscriptions)

- Интерактивная IDE: Banana Cake Pop

📌 Полезные советы
Для продакшена отключи Banana Cake Pop, GET-запросы и интроспекцию

Используй .AddMutationType, .AddSubscriptionType, .AddFiltering, .AddSorting для расширения схемы

🚀 Полный гайд

Hot Chocolate — это простой способ внедрить GraphQL в .NET. Он удобен в настройке, гибкий в использовании и подходит для проектов любого масштаба.



tgoop.com/csharp_ci/1434
Create:
Last Update:

🍫 Hot Chocolate + GraphQL + .NET: Быстрый старт

Если ты хочешь использовать GraphQL в .NET‑проектах — обрати внимание на Hot Chocolate от ChilliCream. Это мощный, удобный и активно развиваемый GraphQL-сервер для .NET.

📎 Полный гайд: [antondevtips.com/blog/getting-started-with-hot-chocolate-graphql](https://antondevtips.com/blog/getting-started-with-hot-chocolate-graphql)

⚙️ Шаг 1: Установка

Создай новый ASP.NET Core проект:


dotnet new web -n Demo
cd Demo
dotnet add package HotChocolate.AspNetCore


🧱 Шаг 2: Настройка GraphQL
В файле Program.cs добавь следующее:


var builder = WebApplication.CreateBuilder(args);

builder.Services
.AddGraphQLServer()
.AddQueryType<Query>();

var app = builder.Build();

app.MapGraphQL();
app.Run();

Создай класс Query.cs:



public class Query
{
public Book GetBook() => new Book
{
Title = "C# in Depth",
Author = new Author { Name = "Jon Skeet" }
};
}


И добавь модели:


public class Book
{
public string Title { get; set; }
public Author Author { get; set; }
}

public class Author
{
public string Name { get; set; }
}


📬 Шаг 3: Запрос в браузере
Открой http://localhost:5000/graphql и выполни GraphQL-запрос:



{
book {
title
author {
name
}
}
}

🧠 Почему стоит выбирать Hot Chocolate?

- Поддержка annotation-based, code-first и schema-first подходов

- Отличная интеграция с EF Core

- Встроенная фильтрация, сортировка, пагинация, DataLoader

- Поддержка подписок (Subscriptions)

- Интерактивная IDE: Banana Cake Pop

📌 Полезные советы
Для продакшена отключи Banana Cake Pop, GET-запросы и интроспекцию

Используй .AddMutationType, .AddSubscriptionType, .AddFiltering, .AddSorting для расширения схемы

🚀 Полный гайд

Hot Chocolate — это простой способ внедрить GraphQL в .NET. Он удобен в настройке, гибкий в использовании и подходит для проектов любого масштаба.

BY C# (C Sharp) programming








Share with your friend now:
tgoop.com/csharp_ci/1434

View MORE
Open in Telegram


Telegram News

Date: |

Telegram Android app: Open the chats list, click the menu icon and select “New Channel.” How to Create a Private or Public Channel on Telegram? While the character limit is 255, try to fit into 200 characters. This way, users will be able to take in your text fast and efficiently. Reveal the essence of your channel and provide contact information. For example, you can add a bot name, link to your pricing plans, etc. Ng was convicted in April for conspiracy to incite a riot, public nuisance, arson, criminal damage, manufacturing of explosives, administering poison and wounding with intent to do grievous bodily harm between October 2019 and June 2020. The channel also called on people to turn out for illegal assemblies and listed the things that participants should bring along with them, showing prior planning was in the works for riots. The messages also incited people to hurl toxic gas bombs at police and MTR stations, he added.
from us


Telegram C# (C Sharp) programming
FROM American