You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On my v4 deployment I rely on the opertaions-hook plugin for several use-cases, one of them is the PgNoticeMessages.
My understanding is that this wasn't ported to v5 yet, so I figured I'd tackle at least the PgNoticeMessages part.
I followed https://github.com/graphile/operation-hooks/blob/main/src/PgNoticeMessagesPlugin.ts and here's what I have so far:
Apart for the type hackiness, it seems to work. But I wanted to double check before continuing down this path:
Am I on the right track?
Is there a better way to extract the type of withPgClient?
My next step would be to extract the data, and I assume I should add it to event.args.contextValue, sounds right? That'll let me access the data further down the line.
I'm assuming that this needs to be the very last plugin in my graphile.config to make sure any other plugin can read that context, correct?
My other next step would be to create a plugin to extract the data from the context to the mutations. The most appropriate one would be makeExtendSchemaPlugin, correct?
P.S. if this all goes well I'd be happy to open source it, let me know if that would be best done as a PR to this repo.
The text was updated successfully, but these errors were encountered:
We don't have official support for this. If you want to hack it, you need to override withPgClient because each time it's called it might be passed a different client.
constctx=event.args.contextValueasGraphile.Context;constprocessNotice=e=>voidconsole.log(e);constoldWithPgClient=ctx.withPgClient;ctx.withPgClient=(settings,cb)=>oldWithPgClient(settings,(client)=>{const{ rawClient }=client;if(!rawClient)thrownewerror("This postgres adaptor is not supported - sorry!");rawClient.on('notice',processNotice);try{returnawaitcb(client);}finally{rawClient.off('notice',processNotice);}});
Hi Benjie,
On my v4 deployment I rely on the
opertaions-hook
plugin for several use-cases, one of them is the PgNoticeMessages.My understanding is that this wasn't ported to v5 yet, so I figured I'd tackle at least the PgNoticeMessages part.
I followed https://github.com/graphile/operation-hooks/blob/main/src/PgNoticeMessagesPlugin.ts and here's what I have so far:
Apart for the type hackiness, it seems to work. But I wanted to double check before continuing down this path:
withPgClient
?event.args.contextValue
, sounds right? That'll let me access the data further down the line.graphile.config
to make sure any other plugin can read that context, correct?P.S. if this all goes well I'd be happy to open source it, let me know if that would be best done as a PR to this repo.
The text was updated successfully, but these errors were encountered: