title: Apollo client & Absinthe - difficulty parsing errors
body: <p>I'm working with the @apollo/client and @absinthe/socket-apollo-link NPM packages in my React app, but I'm having some trouble parsing query and mutation errors received by <code>onError</code> in my implementation of the <code>useQuery</code> and <code>useMutation</code> hooks.</p>
  <p>For example, here is the way I've set up a query in my component:</p>
  <pre><code>    useQuery(OperationLib.agendaQuery, {
          fetchPolicy: &quot;network-only&quot;,
          onCompleted: ({ myData }) =&gt; {
              setData(myData)
              setLoading(false)
          },
          onError: (error) =&gt; {
              console.log(error)
          }
      })
  </code></pre>
  <p>When that <code>onError</code> handler is called, the error object that is returned is logged as:</p>
  <pre><code>Error: request: [object Object]
      at new ApolloError (app.js:36358)
      at app.js:146876
      at app.js:145790
      at new Promise (&lt;anonymous&gt;)
      at Object.error (app.js:145790)
      at notifySubscription (app.js:145130)
      at onNotify (app.js:145169)
      at SubscriptionObserver.error (app.js:145230)
      at app.js:58209
      at Array.forEach (&lt;anonymous&gt;)
  </code></pre>
  <p>I can break this response into its parts <code>&quot;graphQLErrors&quot;</code>, <code>&quot;networkError&quot;</code>, <code>&quot;message&quot;</code>, <code>&quot;extraInfo&quot;</code>, but I'm finding it difficult to get any useful info there. In particular, I'd like to be able to get something out of the <code>message</code> - but in this case, <code>error.message</code> is the string,</p>
  <pre><code>request: [object Object]
  </code></pre>
  <p><code>typeof error.message</code> logs <code>string</code> so yeah I can't really do anything with this.</p>
  <p>Maybe I could find something useful under one of the other attributes? Nope, <code>graphQLErrors</code> is an empty array, <code>networkError</code> yields the same output as I got when I logged the initial error above, and <code>extraInfo</code> is undefined.</p>
  <p>I dug into the source code and found the method <code>createRequestError</code> - when I added a debug log here to see what the <code>message</code> was, I good some good data - I could see the message that I would think would be available somewhere in the error response:</p>
  <pre><code>var createRequestError = function createRequestError(message) {
    return new Error(&quot;request: &quot;.concat(message));
  }.bind(undefined);
  </code></pre>
  <p>What could be causing this issue? Is there something I need to configure in my Apollo/Absinthe initialization? I've set those up like so:</p>
  <p><code>apollo-client.js</code></p>
  <pre><code>import { ApolloClient, InMemoryCache } from &quot;@apollo/client&quot;
  import absintheSocketLink from &quot;./absinthe-socket-apollo-link&quot;
  
  export default new ApolloClient({
      link: absintheSocketLink,
      cache: new InMemoryCache()
  })
  
  </code></pre>
  <p><code>absinthe-socket-apollo-link.js</code></p>
  <pre><code>import * as AbsintheSocket from &quot;@absinthe/socket&quot;
  import { createAbsintheSocketLink } from &quot;@absinthe/socket-apollo-link&quot;
  import { Socket as PhoenixSocket } from &quot;phoenix&quot;
  
  const protocol = window.location.protocol === &quot;https:&quot; ? &quot;wss&quot; : &quot;ws&quot;;
  const getToken = () =&gt; JSON.parse(window.localStorage.getItem(&quot;token&quot;))
  
  let token = getToken();
  
  const params = {
      get jwt() {
          if (!token) {
              token = getToken();
          }
  
          return token;
      },
  };
  
  export default createAbsintheSocketLink(
      AbsintheSocket.create(
          new PhoenixSocket(`${protocol}://${WS_API_URL}/graphql`, {
              reconnect: true,
              params: params
          })
      )
  );
  </code></pre>
  <p>Thanks much for any insight!</p>