clean up node interface

This commit is contained in:
Eric Hulburd
2016-01-31 19:09:52 -06:00
parent 8af7d33d08
commit bf43ca6e40
9 changed files with 20 additions and 89 deletions

View File

@@ -3,17 +3,16 @@ import {
nodeDefinitions,
} from 'graphql-relay';
import DB from './../database'
var {nodeInterface, nodeField} = nodeDefinitions(
(globalId) => {
var {type, id} = fromGlobalId(globalId);
return null;
var {graphql_type_name, id} = fromGlobalId(globalId),
model = DB[graphql_type_name];
return model.findOne({where: {id: id}});
},
(obj) => {
if (obj instanceof Array) {
return Array;
} else {
return null;
}
(instance) => {
return instance.Model().graphql_type;
}
);