Skip to content

Commit 5d3c3f7

Browse files
committed
no longer filter out virtual attributes
1 parent 3592107 commit 5d3c3f7

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/generateIncludes.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ function inList(list, attribute) {
55
return ~list.indexOf(attribute);
66
}
77

8-
function notType(type, model, attribute) {
9-
return !(model.rawAttributes[attribute].type instanceof type);
10-
}
11-
128
export default function generateIncludes(simpleAST, type, root, options) {
139
var result = {include: [], attributes: [], order: []};
1410

@@ -23,8 +19,7 @@ export default function generateIncludes(simpleAST, type, root, options) {
2319
, args = simpleAST.fields[key].args
2420
, includeResolver = type._fields[name].resolve
2521
, nestedResult
26-
, allowedAttributes
27-
, Sequelize;
22+
, allowedAttributes;
2823

2924
if (!includeResolver) return;
3025

@@ -80,11 +75,9 @@ export default function generateIncludes(simpleAST, type, root, options) {
8075
delete includeOptions.order;
8176
}
8277

83-
Sequelize = association.target.sequelize.constructor;
8478
includeOptions.attributes = (includeOptions.attributes || [])
8579
.concat(Object.keys(simpleAST.fields[key].fields))
86-
.filter(inList.bind(null, allowedAttributes))
87-
.filter(notType.bind(null, Sequelize.VIRTUAL, association.target));
80+
.filter(inList.bind(null, allowedAttributes));
8881

8982
includeOptions.attributes.push(association.target.primaryKeyAttribute);
9083

src/resolver.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ function inList(list, attribute) {
88
return ~list.indexOf(attribute);
99
}
1010

11-
function notType(type, model, attribute) {
12-
return !(model.rawAttributes[attribute].type instanceof type);
13-
}
14-
1511
module.exports = function (target, options) {
1612
var resolver
1713
, targetAttributes
1814
, isModel = !!target.getTableName
1915
, isAssociation = !!target.associationType
2016
, association = isAssociation && target
21-
, model = isAssociation && target.target || isModel && target
22-
, Sequelize = model.sequelize.constructor;
17+
, model = isAssociation && target.target || isModel && target;
2318

2419
targetAttributes = Object.keys(model.rawAttributes);
2520

@@ -44,8 +39,7 @@ module.exports = function (target, options) {
4439
type = type.ofType || type;
4540

4641
findOptions.attributes = Object.keys(simpleAST.fields)
47-
.filter(inList.bind(null, targetAttributes))
48-
.filter(notType.bind(null, Sequelize.VIRTUAL, model));
42+
.filter(inList.bind(null, targetAttributes));
4943

5044
findOptions.attributes.push(model.primaryKeyAttribute);
5145

0 commit comments

Comments
 (0)