Files
old-spike/config/graphql/node.js

20 lines
417 B
JavaScript
Raw Normal View History

2016-01-27 20:15:09 -06:00
import {
2016-01-31 17:18:27 -06:00
fromGlobalId,
2016-01-27 20:15:09 -06:00
nodeDefinitions,
} from 'graphql-relay';
2016-01-31 19:09:52 -06:00
import DB from './../database'
2016-01-26 19:42:30 -06:00
var {nodeInterface, nodeField} = nodeDefinitions(
(globalId) => {
2016-01-31 19:09:52 -06:00
var {graphql_type_name, id} = fromGlobalId(globalId),
model = DB[graphql_type_name];
return model.findOne({where: {id: id}});
2016-01-26 19:42:30 -06:00
},
2016-01-31 19:09:52 -06:00
(instance) => {
return instance.Model().graphql_type;
2016-01-26 19:42:30 -06:00
}
);
2016-01-27 20:15:09 -06:00
export {nodeInterface, nodeField};