We are joined by two new leaders: Dr. Mario Lenz as our CPO and Edan Gottlib as our CRO

Headless CMS for .NET

Hygraph is the ideal Headless CMS for .NET websites and applications. Read further to learn how our API-first CMS allows you to add components to your .NET apps in minutes and enable your website's content to be managed from a powerful CMS.

Fetching the data from Hygraph's GraphQL API

In .NET, you can use the popular GraphQL.Client library to fetch data from a GraphQL API. First, you need to install the GraphQL.Client and GraphQL.Client.Serializer.Newtonsoft packages via NuGet.

The GraphQLHttpClient sends the query to the server and receives the response. You can then use the response.Data object to access your fetched data.

using System;
using System.Threading.Tasks;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
public class Program
{
public static async Task Main(string[] args)
{
// Initialize the GraphQL client
using var graphQLClient = new GraphQLHttpClient("https://api-<region>.hygraph.com/v2/<some hash>/master", new NewtonsoftJsonSerializer());
// Create the query
var query = new GraphQLHttpRequest
{
Query = @"
query {
products {
name
description
slug
availability
imageUrl
}
}"
};
// Send the query to fetch the data
var response = await graphQLClient.SendQueryAsync<dynamic>(query);
// Handle the response data as needed
Console.WriteLine(response.Data);
}
}

Working with mutations to store the data in headless CMS

In .NET, to execute a GraphQL mutation, we first set up a GraphQL client and compose a mutation query with necessary variables representing the new data. Using the SendMutationAsync method, we then dispatch this mutation to the server.

The server processes the request, creates or updates the resource accordingly, and returns a response. This response is captured and displayed, confirming the success of the operation. Handling exceptions within this process ensures robust error management.

using System;
using System.Threading.Tasks;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
public class Program
{
public static async Task Main(string[] args)
{
// Initialize the GraphQL client
using var graphQLClient = new GraphQLHttpClient("https://your-graphql-endpoint.com/graphql", new NewtonsoftJsonSerializer());
// Create the mutation
var mutation = new GraphQLHttpRequest
{
Query = @"
mutation($input: ProductInput!) {
createProduct(input: $input) {
product {
id
name
}
}
}",
Variables = new
{
input = new
{
name = "New Product",
description = "This is a new product",
slug = "new-product",
availability = true,
imageUrl = "https://example.com/new-product.jpg"
}
}
};
// Send the mutation to create the data
var response = await graphQLClient.SendMutationAsync<dynamic>(mutation);
// Handle the response data as needed
Console.WriteLine(response.Data);
}
}

Start building with .NET

We made it really easy to set up your project in Hygraph and use our GraphQL API within your .NET project.

Quickstart

Check out our docs to see how you can quickly set up your Hygraph project and enable the content API for your .NET website or app.

Learn GraphQL

Hygraph is GraphQL-native Headless CMS offers precise data retrieval, minimizing over-fetching and optimizing efficiency.

Examples

Look at some of the example projects to see Hygraph in action.

Why Hygraph

Choosing Hygraph for your .NET project

Leveraging a GraphQL-native headless CMS in a .NET environment empowers developers with streamlined data querying that meshes well with .NET’s type safety, while content editors enjoy a dynamic platform for real-time content updates.

The singular querying capabilities of GraphQL reduce unnecessary server requests, accelerating development and application performance. Concurrently, editors can independently manage content across all platforms, enhancing collaborative productivity and allowing developers to concentrate on refining application features without being bottlenecked by content adjustments.

net cms

Developer Experience

We try to be the most un-opinionated CMS on the market with a wide collection of open source example projects to get you started.

Headless CMS

As a headless CMS (i.e. API based content management), you can be as modular and flexible as you need. We even support multiplatform content management.

Management API

Hygraph boasts a flexible and powerful management API to manage your content and schema, as well as a blazing fast content API.

Get started for free, or request a demo to discuss larger projects