刚刚使用 node 和 c# 学习 GraphQL。我正在尝试将 C# 示例移植到 node 上,因为这将是一个很好的学习练习(因为我不太了解 node 或 graphql)
我有 2 种类型。Account and Owner(即帐户所有者)
一切正常(即拥有帐户(列表)和第一个帐户(单个对象)的字段)
module.exports = new GraphQLObjectType({
name: 'OwnerType',
fields: {
Id: { type: GraphQLID},
Name: {type: GraphQLString},
Address: {type: GraphQLString},
OwnedAccounts: {
type: new GraphQLList(AccountType),
name: "OwnedAccounts",
resolve(obj, args, { mssqlConfig }){
return mssql_account(mssqlConfig).getByOwnerId(obj.Id);
}
},
FirstAccount: {
type: AccountType,
name: "FirstAccount",
resolve(obj, args, {mssqlConfig}){
return mssql_account(mssqlConfig).getFirstByOwnerId(obj.Id);
}
}
}
}); Run Code Online (Sandbox Code Playgroud)
当我尝试将 AccountOwner 的字段添加到 AccountType 时,就会出现问题。我收到错误消息“提供的用于构建架构的类型之一缺少名称。”
我试过给我能看到的所有东西都起个名字,但没有任何帮助。
有问题的 AccountType 定义是:
module.exports = new …Run Code Online (Sandbox Code Playgroud)我有控制权继承自文本框
public class MyTextBox : TextBox
Run Code Online (Sandbox Code Playgroud)
这有一种风格
<Style TargetType="{x:Type Controls:MyTextBox}">
Run Code Online (Sandbox Code Playgroud)
塞特犬之一是
<Setter Property="Template">
Run Code Online (Sandbox Code Playgroud)
我希望能够Binding.ValidationRules在模板中设置内容,从而影响此类文本框的所有实例.因此,我可以制作文本框,例如Times,Dates,Numerics,post/zip code ..或者我想要的任何东西,
我不想每次创建文本框时都设置验证规则.我只想说我想要一个NumericTextBox并且以模板中设置的方式进行验证.
这可能吗?
到目前为止,我所看到的是在控件的每个实例上设置的ValidationRules,例如
<TextBox x:Name="txtEMail" Template={StaticResource TextBoxErrorTemplate}>
<TextBox.Text>
<Binding Path="EMail" UpdateSourceTrigger="PropertyChanged" >
<Binding.ValidationRules>
<local:RegexValidationRule Pattern="{StaticResource emailRegex}"/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
Run Code Online (Sandbox Code Playgroud)