目前正在遵循有关 C# Azure 函数和 GraphQL 的教程。GraphQL 类型的 Schema 有点麻烦。
这是我的模型用户类:
public class User : Base
{
private User()
{
}
public User(string name, string email, bool adminUser, DateTime birthday, string dietaryRequirements, Squad squad)
{
Name = name;
Email = email;
AdminUser = adminUser;
Birthday = birthday;
DietaryRequirements = dietaryRequirements;
InformationRequired = true;
Squad = squad;
}
public string Name { get; set; }
public string Email { get; set; }
public bool AdminUser { get; set; } = false;
public DateTime Birthday { get; set; }
public string DietaryRequirements { get; set; }
public bool InformationRequired { get; set; }
public Squad Squad { get; set; }
}
以及 GraphQL 中对应的 Schema:
public class Type
{
private ISchema _Schema { get; set; }
public Type()
{
this._Schema = Schema.For(@"
type User {
Id: GUID
Name: string
Email: string
AdminUser: bool
Birthday: Date
DietaryRequirements: List<string>
InformationRequired: boolean
Squad: squad
}
input User {
Id: GUID
Name: string
Email: string
AdminUser: bool
Birthday: Date
DietaryRequirements: List<string>
InformationRequired: boolean
Squad: squad
}
type Mutation {
createUser(input: User) : User
getUsers() : User
getUserById(id: Id) : User
updateUser(input: User) : User
deleteUser(id: Id) : string
}
type Query {
users: [User]
user(id: Id) : User
}
", _ =>
{
_.Types.Include<Query>();
_.Types.Include<Mutation>();
});
}
}
}
我正在关注本教程:https : //softchris.github.io/pages/dotnet-graphql-serverless.html#adding-a-graphql-schema 在“添加 GraphQL 模式部分”下。
我遇到的问题是我拥有的 Type 类的最后几行:
_.Types.Include<Query>
_.Types.Include<Mutation>();
IntelliSense 在这里抛出一个错误,因为它没有找到所需的命名空间。对于查询,它建议使用静态添加,Microsoft.EntityFrameworkCore.DbLoggerCategory;
但原作者没有使用这个包,所以我认为它是错误的。同样,对于 Mutation,它也有相同的错误,但不建议导入任何包。
谁能看到我在这里做错了什么,或者我没有找到任何错误?