【发布时间】:2017-06-13 09:07:20
【问题描述】:
nodeInterface如何refetch和做对象识别,
type 代表什么,obj 代表什么,这里id 是什么
instanceof 是什么意思
const { nodeInterface, nodeField } = nodeDefinitions(
(globalId) => {
const { type, id } = fromGlobalId(globalId);
console.log('NodeDefinitions (globalId), id:', id);
console.log('NodeDefinitions (globalId), type:', type);
if (type === 'teacher') {
return teacher.findOne({ _id: id }).exec();
} else if (type === 'college') {
return college.findOne({ _id: id }).exec();
} else if (type === 'student') {
return student.findOne({ _id: id }).exec();
}
return null;
},
(obj) => {
if( obj instanceof Teacher) {
return teacherType
}
// other types too
return null;
});
【问题讨论】:
标签: node.js graphql relayjs graphql-js