fix(datapath) must be equivalent for pull and push #6019
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains:
Describe the problem you have without this PR
If we define a custom
dataPath
for thegraphQL
replication, we end up setting a different datapath for the pull and push rep. Pull rep does not handle thedata.
prefix while push already handles it withresult.data
I changed this to make both (pull and push) use the same function helper to extract the proper datapath if defined or not by the user.
Based on the unit tests, I found some that were testing only the pull replication and needed
data
as a prefix so I made the helper function the same as the currentpull.dataPath
, so it will request the user to adddata.
as a prefix, if you prefer the other way around, let me know. However, it makes sense if for any reason the default selector['data', Object.keys(result.data)[0])]
doesn't work because there is nodata
key returned from the server (exceptional edge case, maybe they used thecustomFetch
property) and it breaks the default selector onObject.keys(result.data)
I also changed the typing of
dataPath
to acceptstring[]
sincegetProperty
also accepts it.