-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
context.nodeModel.runQuery should return [] instead of null #25857
Comments
Hi @aaronadamsCA ! Returning an empty array sounds correct to me too. But we explicitly test for gatsby/packages/gatsby/src/redux/__tests__/run-fast-filters.js Lines 189 to 190 in cab7155
The test was added long ago in #11448 and the implementation was there even longer. So, my main concern is that it is a breaking change. I think we should still change this behavior, but the question is if we should wait for the next major or can include it as a patch/minor. @pieh @pvdz any thoughts on this or maybe more context? Anyways, the PR is welcome if you're up to it! I think the change should be trivial somewhere here (just always return an empty array): gatsby/packages/gatsby/src/redux/run-fast-filters.ts Lines 419 to 424 in cab7155
|
Can I provide a patch with these changes above @vladar, after it's confirmed and if it's alright with @aaronadamsCA? |
@kartikcho Absolutely, I just didn't know where to start - though it looks like @vladar already found the spot. 👍 @vladar My guess is somebody just got the tests backwards? Because I'd probably expect |
(As mentioned in the PR, this is a subtle breaking change that I'd love to apply but will have to be done in a major bump because it's bound to break somebody's setup) |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Description
With a query that returns no results,
context.nodeModel.runQuery
returnsPromise<null>
, but the documentation specifies non-null typePromise<Node[]>
.I'd prefer to get back
[]
instead ofnull
, because dealing with one type is easier than dealing with two, and because it's consistent with how the rest of Gatsby GraphQL works. If I pass the same filter to a static query andrunQuery
, I think both should return the same result,[]
.Environment
The text was updated successfully, but these errors were encountered: