title: How to set Apollo link URI per query - initial uri stays, should I use dynamic uri (angular 8)
body: <h2>Summary</h2>
  
  <p>I'm building a simple search application in Angular 8, using Apollo with a graphql server over elasticsearch; I'm passing the elastic query to the backend in the URI, then graphql queries run within the elastic returned data.  However, the URI is set in the first create of Apollo, then doesn't change for subsequent queries in that session.</p>
  
  <h2>Background</h2>
  
  <p>As a novice Angular/Apollo dev, I'm only trying to achieve the starting implementation for a future search tool; I've reviewed graphql-compose-elastic but it looks unwieldy, at least for the immediate prototype need.  I have tried moving the Apollo declarations to a sub-module, using the URI as a Global or via localStorage, but the client won't reset the URI after query 1.  I still get results (no errors) but they are always the same records returned from query 1. </p>
  
  <h2>Current code</h2>
  
  <p>I have a graphql.module.ts which creates the httpLink, and currently at runtime it fetches the uri string (including the elastic search) parameters from localStorage:</p>
  
  <p>in component for search results (using Form + ag-grid) it sets the localstorage uricombo variable:</p>
  
  <p><em>search.component.ts</em></p>
  
  <pre class="lang-js prettyprint-override"><code>uricombo = 'http://graqhql.server.internal:9000/graphql/esindex1/_search?q=title:beginners'
  </code></pre>
  
  <p><em>graphql.module.ts</em></p>
  
  <pre class="lang-js prettyprint-override"><code>httpLink.create({ uri: localStorage.getItem('uricombo') })
  </code></pre>
  
  <p><em>search.component.ts</em></p>
  
  <pre class="lang-js prettyprint-override"><code>this.querySubscription = this.apollo.watchQuery&lt;any&gt;({ query: AllBooksQuery, })
  </code></pre>
  
  <p>...which returns data rows to an ag-grid.</p>
  
  <p>This is fine, but when the user submits subsequent search(s), the original uri is used, and the same records return again.</p>
  
  <p>The stored <code>uricombo</code> value is definitely updated per search submit, while the Apollo link create method is only run once (the first time).</p>
  
  <p>Current assumption is that once the apollo client is created, it retains the URI, but I'm not sure how to refactor this to refresh the URI - I suspect Dynamic URI will help, but not quite clear on how to implement.</p>
  
  <p>As I said relatively new to both Angular and Apollo, (although long time Java jockey) - I may be doing something noobish. Any help / patterns / examples much appreciated</p>