How to use the postgraphile-core.formatSQLForDebugging function in postgraphile-core

To help you get started, we’ve selected a few postgraphile-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphile / postgraphile / src / postgraphile / withPostGraphileContext.ts View on Github external
pgClient.query = function(...args: Array): any {
        const [a, b, c] = args;
        // If we understand it (and it uses the promises API)
        if (
          (typeof a === 'string' && !c && (!b || Array.isArray(b))) ||
          (typeof a === 'object' && !b && !c)
        ) {
          if (debugPg.enabled) {
            // Debug just the query text. We don’t want to debug variables because
            // there may be passwords in there.
            debugPg('%s', formatSQLForDebugging(a && a.text ? a.text : a));
          }

          if (pgClient._explainResults) {
            const query = a && a.text ? a.text : a;
            const values = a && a.text ? a.values : b;
            if (query.match(/^\s*(select|insert|update|delete|with)\s/i) && !query.includes(';')) {
              // Explain it
              const explain = `explain ${query}`;
              pgClient._explainResults.push({
                query,
                result: pgClient[$$pgClientOrigQuery]
                  .call(this, explain, values)
                  .then((data: any) => data.rows),
              });
            }
          }

postgraphile-core

<span class="badge-patreon"><a href="https://patreon.com/benjie" title="Support Graphile development on Patreon"><img src="https://img.shields.io/badge/sponsor-via%20Patreon-orange.svg" alt="Patreon sponsor button" /></a></span> [![Discord chat room](http

MIT
Latest version published 2 years ago

Package Health Score

66 / 100
Full package analysis

Similar packages