如何在 Blazor 项目中使用 Strawberry Shake 从 GraphQL 正确生成 C# 脚本
我正在使用 .NET Core 5 &布拉泽在一起。我还创建了一个漂亮简单的 GraphQL API。但首先,我只是按照教程Strawberry Shake 和 Blazor 入门进行操作。对了,草莓奶昔的版本是12.7.0。我完美地遵循了教程,但无法正确生成脚本。
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
这是输出生成的文件的样子。
这更符合我观看后的预期此视频
显然,这是一个不同的 API,但我尝试在几个 API(包括我自己的 API)上生成,肯定出现了严重错误。我该怎么做才能获得格式良好的代码。我很确定我的 API 非常标准。我按照GraphQL 和 Hot Chocolate 的视频来创建我的视频。
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.
This is more of what I was expecting after watching this video
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论