How to generate C# scripts from GraphQL properly with Strawberry Shake in a Blazor Project

1.8k views Asked by At

I am using a .NET Core 5 & Blazor together. I have also created a nice simple GraphQL API. But to start I just followed the tutorial Getting Started With Strawberry Shake and Blazor. By the way, the version of Strawberry Shake is 12.7.0. I followed the tutorial perfectly but I can't get the scripts to generate properly.

1.  dotnet new tool-manifest
2.  dotnet tool install StrawberryShake.Tools --local
3.  dotnet new sln -n Demo
4.  dotnet new wasm -n Demo
5.  dotnet sln add ./Demo
6.  dotnet add Demo package StrawberryShake.Transport.Http
7.  dotnet add Demo package StrawberryShake.CodeGeneration.CSharp.Analyzers
8.  dotnet add Demo package Microsoft.Extensions.DependencyInjection
9.  dotnet add Demo package Microsoft.Extensions.Http
10. dotnet graphql init https://workshop.chillicream.com/graphql/ -n ConferenceClient -p ./Demo 
11. Added a namespace 

{
  "schema": "schema.graphql",
  "documents": "**/*.graphql",
  "extensions": {
    "strawberryShake": {
      "name": "ConferenceClient",
      "namespace": "Demo.GraphQL",
      "url": "https://workshop.chillicream.com/graphql/",
      "dependencyInjection": true
    }
  }
}

12. added a graphql file with query

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

13. dotnet build

Here is what the output generated files look like.

enter image description here

This is more of what I was expecting after watching this video

enter image description here

Obviously, it is a different API but I have tried generating on a couple APIs including my own and surely something is horribly wrong. What can I do to get the nicely formatted code. I am pretty sure my API is pretty standard. I followed a video about GraphQL and Hot Chocolate to create mine.

0

There are 0 answers