我在学习GraphQL
在编写时,我对特定问题的不同实现感到有点困惑fields
of a GraphQLObjectType
.
这两种实现有什么区别?
1.
var schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: { // as object
echo: {
type: GraphQLString,
args: {
email: { type: EmailType }
},
resolve: (root, {email}) => {
return email;
}
}
}
})
});
-
var ComplicatedArgs = new GraphQLObjectType({
name: 'ComplicatedArgs',
fields: () => ({ // as function
complexArgField: {
type: GraphQLString,
args: {
complexArg: { type: ComplexInput }
},
}
}),
});
当你需要进行循环引用时。
在这里寻找我的类似答案
使用循环引用动态创建 graphql 模式 https://stackoverflow.com/questions/39256942/dynamically-creating-graphql-schema-with-circular-references/39290345#39290345
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)