Skip to content

Change SQL code before it's sent to the database server

Glenn Matthys edited this page May 17, 2022 · 1 revision

Add this as a plugin to Postgraphile:

module.exports = builder => {
  builder.hook('build', build => {
    const oldPAR = build.pgPrepareAndRun;
    build.pgPrepareAndRun = (pgClient, text, values, ...rest) => {
      return oldPAR(pgClient, `/* HELLO! */ ${text}`, values, ...rest);
    }
  });
};