title: How to use Node.js in Postgraphile mutations?
body: <p>I am making an application that shows information about different users, which is taken from third party API. <strong>I save this information in my own format with multiple tables in PostgreSQL to keep track of any changes to the data and provide history of changes</strong> (<em>third party API only provides current data</em>).</p>
  <p>I want to use GraphQL, specifically <a href="https://www.graphile.org/postgraphile/" rel="nofollow noreferrer">Postgraphile</a> to simplify backend development. But there is one use case which I can't find a way to implement with Postgraphile. Here is what I want to implement:</p>
  <ol>
  <li>User wants to see an updated information</li>
  <li>GraphQL mutation query is sent to the server, something like this:</li>
  </ol>
  <pre><code>mutation UpdateUserData($userid: Int) {
      updateUser(id: $userid) {
          field1,
          field2,
          relatedObjects {
              field3,
              filed3
          }
      }
  }
  </code></pre>
  <ol start="3">
  <li>Server makes an API request to third party server, processes data, makes some calculations and updates the database</li>
  <li>Requested fields are returned to client</li>
  </ol>
  <p>I know that this type of <a href="https://www.graphile.org/postgraphile/custom-mutations/" rel="nofollow noreferrer">custom mutations can be implemented with database functions</a> like <a href="https://www.postgresql.org/docs/12/plpgsql.html" rel="nofollow noreferrer">PL/pgSQL</a> or <a href="https://plv8.github.io/" rel="nofollow noreferrer">PLV8</a>, but they can't make http requests and <strong>I already have most of the logic  for data processing in Typescript</strong>, so would like to use it.</p>
  <p><strong>Is there a way to create a custom mutation that will call JavaScript function</strong> which has access to Node.js modules, interfaces and classes that I already created?</p>
  <p>One solution that I think will work:</p>
  <ol>
  <li>Call REST endpoint on my server, like <code>/update_user?id=$userid</code></li>
  <li>User data is loaded from third party API and database is updated</li>
  <li>Client receives response, like <code>Update successful</code></li>
  <li>Normal GraphQL query is called to get the data</li>
  </ol>
  <p>Is there a better way of satisfying this use case?</p>