Skip to content

Commit c9f0398

Browse files
Change createNode method to work for both int and object as arg
1 parent 5b7e9ef commit c9f0398

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

functions.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ var nodeType = (node) => {
3030
// Create a new node
3131
var createNode = (item, fieldDef) => {
3232
let id = item;
33-
let type = fieldDef.astNode.type.kind === 'ListType' ? fieldDef.type.ofType : fieldDef.type;
33+
let fieldTypes = fieldDef.astNode.type.kind === 'ListType' ? fieldDef.type.ofType._fields : fieldDef.type._fields;
34+
_.forOwn(fieldTypes, type => {
35+
if (type.type.name === 'ID') {
36+
id = item[type.name];
37+
}
38+
});
39+
let type = fieldDef.astNode.type.kind === 'ListType' ? fieldDef.type.ofType.name : fieldDef.type.name;
3440
return new Node(id, type);
3541
};
3642

0 commit comments

Comments
 (0)