mirror of
https://github.com/vale981/grapher
synced 2025-03-04 17:11:38 -05:00
Fixing tests
This commit is contained in:
parent
5dde24519f
commit
5377850c91
2 changed files with 21 additions and 4 deletions
|
@ -3,6 +3,10 @@ import cleanObjectForMetaFilters from './lib/cleanObjectForMetaFilters';
|
|||
import sift from 'sift';
|
||||
|
||||
export default (childCollectionNode, { limit, skip, metaFilters }) => {
|
||||
if (childCollectionNode.results.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parent = childCollectionNode.parent;
|
||||
const linker = childCollectionNode.linker;
|
||||
|
||||
|
@ -28,6 +32,10 @@ export default (childCollectionNode, { limit, skip, metaFilters }) => {
|
|||
|
||||
if (strategy === 'one') {
|
||||
parent.results.forEach(parentResult => {
|
||||
if (!parentResult[fieldStorage]) {
|
||||
return;
|
||||
}
|
||||
|
||||
parentResult[childCollectionNode.linkName] = filterAssembledData(
|
||||
resultsByKeyId[parentResult[fieldStorage]],
|
||||
{ limit, skip }
|
||||
|
@ -37,9 +45,13 @@ export default (childCollectionNode, { limit, skip, metaFilters }) => {
|
|||
|
||||
if (strategy === 'many') {
|
||||
parent.results.forEach(parentResult => {
|
||||
if (!parentResult[fieldStorage]) {
|
||||
return;
|
||||
}
|
||||
|
||||
let data = [];
|
||||
parentResult[fieldStorage].forEach(_id => {
|
||||
data.push(resultsByKeyId[_id]);
|
||||
data.push(_.first(resultsByKeyId[_id]));
|
||||
});
|
||||
|
||||
parentResult[childCollectionNode.linkName] = filterAssembledData(
|
||||
|
@ -51,6 +63,10 @@ export default (childCollectionNode, { limit, skip, metaFilters }) => {
|
|||
|
||||
if (strategy === 'one-meta') {
|
||||
parent.results.forEach(parentResult => {
|
||||
if (!parentResult[fieldStorage]) {
|
||||
return;
|
||||
}
|
||||
|
||||
const _id = parentResult[fieldStorage]._id;
|
||||
parentResult[childCollectionNode.linkName] = filterAssembledData(
|
||||
resultsByKeyId[_id],
|
||||
|
@ -64,7 +80,7 @@ export default (childCollectionNode, { limit, skip, metaFilters }) => {
|
|||
const _ids = _.pluck(parentResult[fieldStorage], '_id');
|
||||
let data = [];
|
||||
_ids.forEach(_id => {
|
||||
data.push(resultsByKeyId[_id]);
|
||||
data.push(_.first(resultsByKeyId[_id]));
|
||||
});
|
||||
|
||||
parentResult[childCollectionNode.linkName] = filterAssembledData(
|
||||
|
@ -76,7 +92,7 @@ export default (childCollectionNode, { limit, skip, metaFilters }) => {
|
|||
};
|
||||
|
||||
function filterAssembledData(data, { limit, skip }) {
|
||||
if (limit) {
|
||||
if (limit && Array.isArray(data)) {
|
||||
return data.slice(skip, limit);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,9 @@ import {
|
|||
} from './collections';
|
||||
|
||||
describe('Query Link Denormalization', function() {
|
||||
before(() => {
|
||||
before((done) => {
|
||||
createFixtures();
|
||||
done();
|
||||
});
|
||||
|
||||
it('Should not cache work with nested options', function() {
|
||||
|
|
Loading…
Add table
Reference in a new issue