Files
old-spike/lib/node.relay.js

27 lines
549 B
JavaScript
Raw Normal View History

2016-01-26 19:42:30 -06:00
/**
* We get the node interface and field from the Relay library.
*
* The first method defines the way we resolve an ID to its object.
* The second defines the way we resolve an object to its GraphQL type.
*/
2016-01-27 20:15:09 -06:00
import {
nodeDefinitions,
} from 'graphql-relay';
2016-01-26 19:42:30 -06:00
var {nodeInterface, nodeField} = nodeDefinitions(
(globalId) => {
var {type, id} = fromGlobalId(globalId);
2016-01-27 20:15:09 -06:00
return null;
2016-01-26 19:42:30 -06:00
},
(obj) => {
2016-01-27 20:15:09 -06:00
if (obj instanceof Array) {
return Array;
2016-01-26 19:42:30 -06:00
} else {
return null;
}
}
);
2016-01-27 20:15:09 -06:00
export {nodeInterface, nodeField};