diff --git a/packages/gatsby/src/redux/__tests__/run-fast-filters.js b/packages/gatsby/src/redux/__tests__/run-fast-filters.js index 1581944bbab71..7cf0c2bbb5650 100644 --- a/packages/gatsby/src/redux/__tests__/run-fast-filters.js +++ b/packages/gatsby/src/redux/__tests__/run-fast-filters.js @@ -187,7 +187,7 @@ describe(`fast filter tests`, () => { // `id-1` node is not of queried type, so results should be empty expect(resultSingular).toEqual([]) - expect(resultMany).toEqual(null) + expect(resultMany).toEqual([]) }) it(`non-eq operator`, async () => { @@ -353,7 +353,7 @@ describe(`fast filter tests`, () => { filtersCache: new Map(), }) - expect(resultMany).toBe(null) + expect(resultMany).toEqual([]) }) it(`elemMatch on array of objects`, async () => { diff --git a/packages/gatsby/src/redux/run-fast-filters.ts b/packages/gatsby/src/redux/run-fast-filters.ts index f51df9c308d97..3676fed2c1a59 100644 --- a/packages/gatsby/src/redux/run-fast-filters.ts +++ b/packages/gatsby/src/redux/run-fast-filters.ts @@ -417,10 +417,7 @@ function convertAndApplyFastFilters( stats.totalSiftHits++ } - if (firstOnly) { - return [] - } - return null + return [] } function filterToStats( diff --git a/packages/gatsby/src/schema/__tests__/run-query.js b/packages/gatsby/src/schema/__tests__/run-query.js index c6ca11ee73b43..49b79f3d3e676 100644 --- a/packages/gatsby/src/schema/__tests__/run-query.js +++ b/packages/gatsby/src/schema/__tests__/run-query.js @@ -473,7 +473,7 @@ describe(`Filter fields`, () => { }) // Note: no coercion, so [8]=='8' is true but the comparison is strict - expect(result).toEqual(null) + expect(result).toEqual([]) }) }) @@ -769,7 +769,7 @@ describe(`Filter fields`, () => { // Nothing is lt null so zero nodes should match // (Note: this is different from `lte`, which does return nulls here!) - expect(result).toEqual(null) + expect(result).toEqual([]) expect( allNodes.filter(node => node.nil === needle).length ).toBeGreaterThan(0) // They should _exist_... @@ -972,7 +972,7 @@ describe(`Filter fields`, () => { // Nothing is gt null so zero nodes should match // (Note: this is different from `gte`, which does return nulls here!) expect(result?.length ?? 0).toEqual(new Set(result ?? []).size) // result should contain unique elements - expect(result).toEqual(null) + expect(result).toEqual([]) expect( allNodes.filter(node => node.nil === needle).length ).toBeGreaterThan(0) // They should _exist_... @@ -1188,7 +1188,7 @@ describe(`Filter fields`, () => { name: { regex: `/"/` }, }) - expect(result).toEqual(null) + expect(result).toEqual([]) expect(allNodes.filter(node => node.name === `"`).length).toEqual(0) }) }) @@ -1506,7 +1506,7 @@ describe(`Filter fields`, () => { }, }) - expect(result).toEqual(null) + expect(result).toEqual([]) }) it(`handles the elemMatch operator for array of objects (1)`, async () => {