Modifying queries/mutations before they are sent to an API #5237
Unanswered
LaurianeDPWaya
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all,
I am currently trying to integrate the RxDB library that is in the frontend of my application with a REST API, as I am using RxDB with its GraphQL replication tool I needed something to convert my queries and mutations to something a REST API could respond to, that's where GraphQL-Mesh comes in!
The way RxDB works is that it is either pulling or pushing data, pulling corresponds to a GET request and is easy enough to convert through Mesh to return the data I want, but pushing corresponds to everything else that modifies the database.
As such I would need to intercept all mutations sent by my frontend app and would like to add some logic to Mesh so that each "push" is converted to a GraphQL query that exists in my REST API's schema.
I have tried using resolvers to solve this:
I can currently modify what my REST API is sending back to the frontend in my rxDBPull method by modifying the response directly:
const response = next(root, newArgs, context, info);
But I am having a hard time similarly modifying the request, my modifications seem to be affecting the request, but not the response.
Here when I check the value of "info" it has been modified by my intervention, however the response still contains the field "isChecked".
TL;DR
In summary, is there a way for Mesh to affect queries and mutations before they are sent to an API, possibly with a resolver?
Thank you for sharing any insight you might have on this!
Beta Was this translation helpful? Give feedback.
All reactions