I am trying to use GraphQL Subscriptions and Live Queries and so far everything seems quite exciting, however we have some slow background processes and we use inngest to trigger them. What I want to do is notify specific GQL subscribers, but how do I get the context?
In a mutation we get the context as the 2nd parameter of the function like in the example:
export const sendMessage = async (
{ input }: { input: SendMessageInput },
{ context }: { context: { pubSub: NewMessageChannelType } }
) => {
What I need is to be able to get this context from other functions (API integrations receiving notifications from other systems) as well as inngest functions
What I found is that I can import context from here:
import { context } from '@redwoodjs/graphql-server'
And it has liveQueryStore just like the context from the example:
export const bid = async (
{ input },
{ context }: { context: { liveQueryStore: LiveQueryStorageMechanism } }
) => {
but it’s missing the pubSub
. So my first question is - where does “pubSub” live and what should I import so I can call pubSub.publish('newMessage', roomId, { from, body })
This leads me to my second question: When I invalidate a live query, how is the key associated with the query?
So basically how does the server “know” what query to invalidate when I do this:
const key = `Auction:${auctionId}`
context.liveQueryStore.invalidate(key)
when the auction
query signature is like this:
export const auction = async ({ id }) => {
And how will the key look if I have multiple params? Can I specify which ones should be part of the key?