如何将 userThat(以及可能的其他几个相关字段)重构为其他不错的模块化文件,然后将它们包含到 root_query_type.js
这是一个普通的 node/express/graphql GraphQLObjectType 实现。
还是我注定要拥有一个巨大的 root_query_type.js ?
schema.js
module.exports = new GraphQLSchema({
query: RootQueryType
});
root_query_type.js
const RootQueryType = new GraphQLObjectType({
name: 'RootQueryType',
fields: {
userThis: {
type: UserType,
resolve(parentValue, args, request) {
return thisResult;
}
},
userThat: {
type: UserType,
args: {
thatArgs: { type: new GraphQLNonNull(GraphQLString) },
},
resolve: (parentValue, arg, request) => {
return thatResult;
},
},