我正在关注本教程,
https://dev-blog.apollodata.com/tutorial-building-a-graphql-server-cddaa023c035
但我的问题不是关于阿波罗服务器,它只是使用 javascript 对象的一小部分;我想知道javascript的理论,这个块在对象内部定义了什么:
author(root, args){
return { id: 1, firstName: 'Hello', lastName: 'World' };
}
前一个块在这个对象中,但我不知道javascript中这个定义的理论,究竟是什么?
const resolvers = {
Query: {
author(root, args){
return { id: 1, firstName: 'Hello', lastName: 'World' };
},
},
Author: {
posts(author){
return [
{ id: 1, title: 'A post', text: 'Some text', views: 2},
{ id: 2, title: 'Another post', text: 'Some other text', views: 200}
];
},
},
Post: {
author(post){
return { id: 1, firstName: 'Hello', lastName: 'World' };
},
},
};
export default resolvers;