Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions website/src/docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2480,10 +2480,6 @@
"path": "index",
"title": "Blazor"
},
{
"path": "xamarin",
"title": "Xamarin"
},
{
"path": "console",
"title": "Console"
Expand Down Expand Up @@ -2588,13 +2584,13 @@
"path": "index",
"title": "Blazor"
},
{
"path": "xamarin",
"title": "Xamarin"
},
{
"path": "console",
"title": "Console"
},
{
"path": "xamarin",
"title": "Xamarin"
Comment thread
glen-84 marked this conversation as resolved.
}
]
},
Expand Down Expand Up @@ -2696,13 +2692,13 @@
"path": "index",
"title": "Blazor"
},
{
"path": "xamarin",
"title": "Xamarin"
},
{
"path": "console",
"title": "Console"
},
{
"path": "xamarin",
"title": "Xamarin"
Comment thread
glen-84 marked this conversation as resolved.
}
]
},
Expand Down Expand Up @@ -2800,13 +2796,13 @@
"path": "index",
"title": "Blazor"
},
{
"path": "xamarin",
"title": "Xamarin"
},
{
"path": "console",
"title": "Console"
},
{
"path": "xamarin",
"title": "Xamarin"
Comment thread
glen-84 marked this conversation as resolved.
}
]
},
Expand Down Expand Up @@ -2900,13 +2896,13 @@
"path": "index",
"title": "Blazor"
},
{
"path": "xamarin",
"title": "Xamarin"
},
{
"path": "console",
"title": "Console"
},
{
"path": "xamarin",
"title": "Xamarin"
Comment thread
glen-84 marked this conversation as resolved.
}
]
},
Expand Down
Binary file removed website/src/docs/shared/berry_console_generated.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 38 additions & 43 deletions website/src/docs/strawberryshake/v16/get-started/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ 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 -n Demo
dotnet new sln --name Demo
```

2. Create a new console application.

```bash
dotnet new console -n Demo
dotnet new console --name Demo
```

3. Add the project to the solution `Demo.sln`.
Expand All @@ -65,7 +65,7 @@ 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}} -n {{ClientName}}`.
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.

Expand All @@ -74,10 +74,10 @@ In this tutorial we will use our GraphQL workshop to create a list of sessions t
1. Add the conference client to your console application.

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

2. Customize the namespace of the generated client to be `Demo.GraphQL`. For this head over to the `.graphqlrc.json` and insert a namespace property to the `StrawberryShake` section.
2. 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
{
Expand All @@ -88,7 +88,16 @@ dotnet graphql init https://workshop.chillicream.com/graphql/ -n ConferenceClien
"name": "ConferenceClient",
"namespace": "Demo.GraphQL",
"url": "https://workshop.chillicream.com/graphql/",
"dependencyInjection": true
"records": {
"inputs": false,
"entities": false
},
"transportProfiles": [
{
"default": "Http",
"subscription": "WebSocket"
}
]
Comment thread
glen-84 marked this conversation as resolved.
}
}
}
Expand Down Expand Up @@ -120,37 +129,30 @@ query GetSessions {
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 8, the path would be `./obj/Debug/net8.0/berry`.
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.](../../../shared/berry_console_generated.png)
![Visual Studio Code showing the generated directory.](../../../shared/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.

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

namespace Demo
{
class Program
{
static void Main(string[] args)
{
var serviceCollection = new ServiceCollection();
var serviceCollection = new ServiceCollection();

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

IServiceProvider services = serviceCollection.BuildServiceProvider();
var services = serviceCollection.BuildServiceProvider();

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

Comment thread
glen-84 marked this conversation as resolved.
## Step 5: Use the ConferenceClient to perform a simple fetch
Expand All @@ -159,31 +161,24 @@ In this section we will perform a simple fetch with our `ConferenceClient` and o

1. Head over to `Program.cs`.

2. Add the following code to your main method to execute the `GetSessions` query.
2. Add the following code to execute the `GetSessions` query.

```csharp
static async Task Main(string[] args)
{
var serviceCollection = new ServiceCollection();
var result = await client.GetSessions.ExecuteAsync();
result.EnsureNoErrors();

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

IServiceProvider services = serviceCollection.BuildServiceProvider();

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

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);
}
foreach (var session in result.Data.Sessions.Nodes)
{
Console.WriteLine(session.Title);
}
```

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

![Started console application that shows a list of sessions](../../../shared/berry_console_session_list.png)
![Started console application that shows a list of sessions](../../../shared/berry_console_session_list.webp)
16 changes: 8 additions & 8 deletions website/src/docs/strawberryshake/v16/get-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dotnet new tool-manifest
2. Install the Strawberry Shake tools.

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

# Step 2: Create a Blazor WebAssembly project
Expand All @@ -39,13 +39,13 @@ Next, we will create our Blazor project so that we have a little playground.
1. First, a new solution called `Demo.sln`.

```bash
dotnet new sln -n Demo
dotnet new sln --name Demo
```

2. Create a new Blazor for WebAssembly application.

```bash
dotnet new blazorwasm -n Demo
dotnet new blazorwasm --name Demo
```

3. Add the project to the solution `Demo.sln`.
Expand All @@ -66,19 +66,19 @@ dotnet add Demo package StrawberryShake.Blazor

# 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}} -n {{ClientName}}`.
To add a client to your project, you need to run `dotnet graphql init {{ServerUrl}} --clientName {{ClientName}}`.

In this tutorial we will use our ChilliCream demo project to create a list of crypto currencies that we will add to our Blazor application.
In this tutorial we will use our ChilliCream demo project to create a list of cryptocurrencies that we will add to our Blazor application.

> If you want to have a look at our demo GraphQL server head over [here](https://demo.chillicream.com/graphql).

1. Add the crypto client to your Blazor application.

```bash
dotnet graphql init https://demo.chillicream.com/graphql/ -n CryptoClient -p ./Demo
dotnet graphql init https://demo.chillicream.com/graphql/ --clientName CryptoClient --Path ./Demo
Comment thread
glen-84 marked this conversation as resolved.
```

2. Customize the namespace of the generated client to be `Demo.GraphQL`. For this head over to the `.graphqlrc.json` and insert a namespace property to the `StrawberryShake` section.
2. 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
{
Expand Down Expand Up @@ -137,7 +137,7 @@ dotnet build

With the project compiled the strawberry shake generator produced a client but also components that we can use in Blazor.

![Visual Studio code showing the generator output on the console.](../../../shared/berry_generated.png)
![Visual Studio Code showing the generator output on the console.](../../../shared/berry_generated.png)

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

Expand Down
Loading