# Get started with Strawberry Shake in a Console application - Strawberry Shake

> Add a Strawberry Shake GraphQL client to a .NET console application: install the CLI tools, generate a typed client from a schema, and fetch your first data.

Canonical source: https://chillicream.com/docs/strawberryshake/get-started/console

In this tutorial we will walk you through the basics of adding a Strawberry Shake GraphQL client to a console project. For this example we will create a simple console application and fetch some simple data from our demo backend.

Strawberry Shake is not limited to console application and can be used with any .NET standard compliant library.

In this tutorial, we will teach you:

- How to add the Strawberry Shake CLI tools.
- How to generate source code from .graphql files, that contain operations.
- How to use the generated client in a classical or reactive way.
- How to disable state management for ASP.NET core use-cases.

## Step 1: Add the Strawberry Shake CLI tools

The Strawberry Shake tool will help you to set up your project to create a GraphQL client.

Open your preferred terminal and select a directory where you want to add the code of this tutorial.

1. Create a dotnet tool-manifest.

Bash

```
dotnet new tool-manifest
```

1. Install the Strawberry Shake tools.

Bash

```
dotnet tool install StrawberryShake.Tools --local
```

## Step 2: Create a console project

Next, we will create our console project so that we have a little playground.

1. First, a new solution called `Demo.sln`.

Bash

```
dotnet new sln --name Demo
```

1. Create a new console application.

Bash

```
dotnet new console --name Demo
```

1. Add the project to the solution `Demo.sln`.

Bash

```
dotnet sln add ./Demo
```

## Step 3: Install the required packages

Strawberry Shake supports multiple GraphQL transport protocols. In this example we will use the standard GraphQL over HTTP protocol to interact with our GraphQL server.

1. Add the `StrawberryShake.Server` package to your project in order to add our code generation.

Bash

```
dotnet add Demo package StrawberryShake.Server
```

## Step 4: Add a GraphQL client to your project using the CLI tools

To add a client to your project, you need to run `dotnet graphql init {{ServerUrl}} --clientName {{ClientName}}`.

In this tutorial we will use our GraphQL workshop to create a list of sessions that we will add to our console application.

> If you want to have a look at our GraphQL workshop head over [here](https://github.com/ChilliCream/graphql-workshop).

1. Add the conference client to your console application.

Bash

```
dotnet graphql init https://workshop.chillicream.com/graphql/ --clientName ConferenceClient --Path ./Demo
```

1. Customize the namespace of the generated client to be `Demo.GraphQL`. For this head over to the `.graphqlrc.json` and insert a namespace property in the `StrawberryShake` section.

JSON

```
{
  "schema": "schema.graphql",
  "documents": "**/*.graphql",
  "extensions": {
    "strawberryShake": {
      "name": "ConferenceClient",
      "namespace": "Demo.GraphQL",
      "url": "https://workshop.chillicream.com/graphql/",
      "records": {
        "inputs": false,
        "entities": false
      },
      "transportProfiles": [
        {
          "default": "Http",
          "subscription": "WebSocket"
        }
      ]
    }
  }
}
```

Now that everything is in place let us write our first query to ask for a list of session titles of the conference API.

1. Choose your favorite IDE and the solution. If your are using VSCode do the following:

Bash

```
code ./Demo
```

1. Create new query document `GetSessions.graphql` with the following content:

GraphQL

```
query GetSessions {
  sessions(order: { title: ASC }) {
    nodes {
      title
    }
  }
}
```

1. Compile your project.

Bash

```
dotnet build
```

With the project compiled, you should now see in the directory `./obj/<configuration>/<target-framework>/berry` the generated code that your applications can leverage. For example, if you've run a Debug build for .NET 10, the path would be `./obj/Debug/net10.0/berry`.

![Visual Studio Code showing the generated directory.](https://chillicream.com/images/strawberryshake-docs/berry_console_generated.webp)

1. Head over to the `Program.cs` and add the new `ConferenceClient` to the dependency injection.

> In some IDEs it is still necessary to reload the project after the code was generated to update the IntelliSense. So, if you have any issues in the next step with IntelliSense just reload the project and everything should be fine.

C#

```
using Microsoft.Extensions.DependencyInjection;
using Demo.GraphQL;

var serviceCollection = new ServiceCollection();

serviceCollection
    .AddConferenceClient()
    .ConfigureHttpClient(
        client =>
            client.BaseAddress =
                new Uri("https://workshop.chillicream.com/graphql"));

var services = serviceCollection.BuildServiceProvider();

var client = services.GetRequiredService<IConferenceClient>();
```

## Step 5: Use the ConferenceClient to perform a simple fetch

In this section we will perform a simple fetch with our `ConferenceClient` and output the result to the console.

1. Head over to `Program.cs`.
2. Add the following code to execute the `GetSessions` query.

C#

```
var result = await client.GetSessions.ExecuteAsync();
result.EnsureNoErrors();

if (result.Data?.Sessions?.Nodes is null)
{
    Console.WriteLine("No sessions found.");
    return;
}

foreach (var session in result.Data.Sessions.Nodes)
{
    Console.WriteLine(session.Title);
}
```

1. Start the console application with `dotnet run --project ./Demo` and see if your code works.

![Started console application that shows a list of sessions](https://chillicream.com/images/strawberryshake-docs/berry_console_session_list.webp)

[Edit this page on GitHub](https://github.com/ChilliCream/graphql-platform/edit/main/website/content/docs/strawberryshake/get-started/console.md)

Last updated on **June 30, 2026** by **Tobias Tengler**
