From 4a5343b96035d24e84fc79281965d9fa69b66eab Mon Sep 17 00:00:00 2001 From: PascalSenn Date: Mon, 15 Jan 2024 23:46:38 +0100 Subject: [PATCH] Updated BCP Fusion Documentation (#6824) * Update bcp fusion documentation * Update fusion.md * Update fusion.md * Update api-key.md --------- Co-authored-by: Rafael Staib --- .../src/docs/bananacakepop/v2/apis/fusion.md | 70 +++++++++++++++++++ .../src/docs/barista/v1/commands/api-key.md | 2 + website/src/docs/barista/v1/index.md | 2 +- 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/website/src/docs/bananacakepop/v2/apis/fusion.md b/website/src/docs/bananacakepop/v2/apis/fusion.md index 1fc4f768f76..67b47594866 100644 --- a/website/src/docs/bananacakepop/v2/apis/fusion.md +++ b/website/src/docs/bananacakepop/v2/apis/fusion.md @@ -67,6 +67,76 @@ builder.Services Now your gateway will be notified whenever there is a new configuration available and will automatically pull it. +## Configure Your Subgraphs + +To set up your subgraphs to be linked with your gateway, you need to follow these steps: + +### Step 1: Install BananaCakePop.Services Package + +First, ensure that the `BananaCakePop.Services` package is installed in your subgraph projects. If not, you can install it by running the following command in the root directory of each subgraph project: + +```bash +dotnet add package BananaCakePop.Services +``` + +### Step 2: Configure Services in Startup + +After installing the package, configure the BananaCakePop Services on your schema. Here is an example of how you can do this: + +```csharp +services + .AddGraphQLServer() + .AddQueryType() + .AddBananaCakePopServices(x => + { + x.ApiKey = "<>"; + x.ApiId = "<>"; + x.Stage = "dev"; + }) + .AddInstrumentation(); // Enable GraphQL telemetry + +services + .AddOpenTelemetry() + .WithTracing(x => + { + x.AddHttpClientInstrumentation(); + x.AddAspNetCoreInstrumentation(); + x.AddBananaCakePopExporter(); + // Register more instrumentation providers such as Entity Framework Core, HttpClient, etc. + }); +``` + +> **Tip: Using Environment Variables** +> +> Alternatively, you can also set the required values using environment variables. + +This configuration enables your subgraph to interact with the BananaCakePop services, including telemetry and instrumentation. + +### Step 3: Create a Subgraph Configuration File + +Each subgraph requires a specific configuration file named `subgraph-config.json`. This file should be placed in the root directory of the subgraph project, next to the `.csproj` file. + +Here’s an example of what the `subgraph-config.json` file should look like: + +```json +{ + "subgraph": "Order", // Name of the subgraph + "http": { "baseAddress": "http://localhost:59093/graphql" }, // Default HTTP settings + "extensions": { + "bcp": { + "apiId": "<>" + } + } +} +``` + +This file is required for the topology to recognize and display your subgraph correctly. + +### Step 4: Pack your subgraph and compose your Gateway + +After configuring your subgraph you have to `pack` your subgraph and `compose` your gateway. +This process links your subgraph with the gateway, ensuring a cohesive GraphQL architecture. + ## Integration into your CI/CD pipeline The deployment of a subgraph is a multi step process. To integrate BananaCakePop into this process you need to install Barista, the BananaCakePop CLI. You can find more information about Barista in the [Barista Documentation](/docs/barista/v1). ```bash diff --git a/website/src/docs/barista/v1/commands/api-key.md b/website/src/docs/barista/v1/commands/api-key.md index da561a5eae1..757324ea307 100644 --- a/website/src/docs/barista/v1/commands/api-key.md +++ b/website/src/docs/barista/v1/commands/api-key.md @@ -8,6 +8,8 @@ The `barista api-key` command provides a set of subcommands that allow you to ma The `barista api-key create` command is used to create a new API key. +> **Important:** Use the value prefixed with `Secret:` as the api key value you pass to `BananaCakePop.Services` + ```shell barista api-key create --api-id abc123 ``` diff --git a/website/src/docs/barista/v1/index.md b/website/src/docs/barista/v1/index.md index 16bb99c075a..a6cd2f0e0b1 100644 --- a/website/src/docs/barista/v1/index.md +++ b/website/src/docs/barista/v1/index.md @@ -7,5 +7,5 @@ Barista is a powerful .NET command-line tool used for managing your GraphQL API' To install Barista, use the .NET Core CLI command: ``` -dotnet tool install --global barista --prerelease +dotnet tool install --global barista ```