GraphQL Live Query implementation from Laurin Quast can be used in GraphQL Mesh with a few addition in the configuration.
Let's say you have a
Query root field that returns all
Todo entities from your data source like below;
And you want to update this operation result automatically without manual refresh when
Mutation.addTodo is called.
The only thing you need is to add the following configuration to your existing configuration;
Then you can send a live query with
This will start a real-time connection between server and your client, then the response of
todos will get updated whenever
addTodo is called.
Let's say you have the following query that returns specific
Todo entity based on
And you update this entity with
editTodo mutation field on your backend then you want to invalidate this entity specifically instead of validating all
In a case where the field resolver resolve null but might resolve to an object type later, e.g. because the visibility got updates the field that uses a specific id argument can be invalidated in the following way:
liveQueryStore is available in GraphQL Context so you can access it in resolvers composition functions that wrap existing resolvers or additional resolvers;
And in this code file;
You can learn more about GraphQL Live Query in its documentation.
You can check out our example that uses live queries