Visitar URL original
Fix nullable refetchedFragmentRef in checkSameIDAfterRefetch by KrzysztofKarol · Pull Request #4945 · meta/relay · GitHub
Skip to content

Fix nullable refetchedFragmentRef in checkSameIDAfterRefetch - #4945

Closed
KrzysztofKarol wants to merge 3 commits into
meta:mainfrom
KrzysztofKarol:fix-nullable-refetchedFragmentRef-in-checkSameIDAfterRefetch
Closed

KrzysztofKarol wants to merge 3 commits into
meta:mainfrom
KrzysztofKarol:fix-nullable-refetchedFragmentRef-in-checkSameIDAfterRefetch

Conversation

@KrzysztofKarol

@KrzysztofKarol KrzysztofKarol commented Apr 4, 2025 •

Copy link
Copy Markdown
Contributor

I call useRefetchableFragment(), e.g. getSomethingById.
The backend may return null ("Something" no longer exists).
Then the queryData is {node: null}
fragmentRefPathInResponse is ['node']
so fragmentRef (refetchedFragementRef) is null
and the
var resultID = refetchedFragmentRef[ID_KEY] throws cannot read properties of null.

@captbaritone

Copy link
Copy Markdown
Contributor

Could you share more about what this fixes? Would it be possible to add tests demonstrating how this changes behavior?

@KrzysztofKarol

Copy link
Copy Markdown
Contributor Author

Hey @captbaritone, I updated the description. I hope it is understandable now. If not - let me know and I will try to rephrase it.

@tyao1

tyao1 commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

Could you add a test case in relay-hooks/tests/useRefetchableFragmentNode-test.js? That will be helpful to verify the fix and prevent future regressions.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@captbaritone

Copy link
Copy Markdown
Contributor

I'll import and see if I can write a test. Thanks for the PR!

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@captbaritone merged this pull request in 677c1e3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants