-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
#2606: Allow 'dataPath' to be specified on the GraphQL replication pull object to specify where to fetch result documents from #3195
#2606: Allow 'dataPath' to be specified on the GraphQL replication pull object to specify where to fetch result documents from #3195
Conversation
…ion pull object to specify where to fetch result documents from
@@ -4,6 +4,7 @@ | |||
|
|||
Features: | |||
- Added `RxDatabase.migrationStates()` which returns an observable to observe the state of all ongoing migrations. | |||
- Added `dataPath` property to GraphQL replication pull options to allow the document JSON lookup path to configured instead of assuming the document data is always the first child of the response [#2606](https://github.com/pubkey/rxdb/issues/2606) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add this to the top "comming soon" section, not an already released version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yep, my master
was out of date. Just merged origin/master and resolved the conflict to place this in the correct version.
docs-src/replication-graphql.md
Outdated
@@ -161,6 +161,7 @@ const replicationState = myCollection.syncGraphQL({ | |||
pull: { | |||
queryBuilder: pullQueryBuilder, // the queryBuilder from above | |||
modifier: doc => doc // (optional) modifies all pulled documents before they are handeled by RxDB. Returning null will skip the document. | |||
dataPath: null // (optional) specifies the object path to access the document(s). Otherwise, the first result of the response data is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is optional, the default value must be undefined
not null
We should add at least one test to prevent accidentially breaking this on refactors. Atm if the whole functionallity would be removed, the CI would still be green. |
Happy to - I'll need to pull some stuff around in the GraphQL test server as I'll need to reuse the human collection resolver function. |
Yes this seems necessary, thank you very much. |
Just a quick note to say this is still on my todo list, I expect to get to it in 3 days. |
@pubkey I added a new query field to the GraphQL test schema that I'm using in a new test that checks the expected document is fetched. Let me know if you have any other feedback! |
Thank you josh, I merged it. |
This PR contains:
This PR contains a new feature to allow
dataPath
to be specified as a property of theGraphQLSyncPullOptions
to allow nested or alternative GraphQL data responses to be used.Describe the problem you have without this PR
Without this feature, it's not possible to support any GraphQL response other than one that returns the raw document data within the first key on the
data
property of the response JSON.An example of such a response is a paginated collection type, where the pagination info is returned to the client:
In this case, the data we want will be found at
data.humanCollection.collection
, notdata.humanCollection
.I've been using this patch in a project for a few weeks, and it's working nicely. The original implementation is in #2614 - I changed where the
dataPath
property is looked up to be on thepull
property (to avoid the double-namespacing), and added types, tests, etc.Todos