title: Angular dependency injection into an export function
body: <p>I am using apollo graphql, and it has a module with a function inside of it. </p>
  
  <pre><code>export function createApollo(httpLink: HttpLink, connectToDevTools: true){
  </code></pre>
  
  <p>Inside this function you define the url for the graphql endpoint <code>const uri = http://127.0.0.1/graphql</code> for instance.</p>
  
  <p>I would like to import this url form a service (so that I only have to change the backend server url in one place), but I can not inject the service, for the property stays undefined.</p>
  
  <pre><code>export function createApollo(httpLink: HttpLink, connectToDevTools: true, urlservice: UrlsService) {
      const uri = urlservice.graphqlAddress;
  </code></pre>
  
  <p>Error: <code>Cannot read property 'graphqlAddress' of undefined</code></p>
  
  <p>I have also tried injecting the service into the modules constructor, but this is even lower down the chain, with the same results. </p>
  
  <p>How do I get an outside property into the function <code>createApollo</code>?</p>
  
  <p>My service basically looks like this:</p>
  
  <pre><code>export class UrlsService {
      ...
      graphqlAddress = 'http://192.168.2.24:8000/graphql/';
      ...
  }
  </code></pre>
  
  <p>GraphQLModule providers:</p>
  
  <pre><code>@NgModule({
      exports: [ApolloModule, HttpLinkModule],
      providers: [
          UrlsService,
          {
              provide: APOLLO_OPTIONS,
              useFactory: createApollo,
              deps: [HttpLink],
          },
      ],
  })
  export class GraphQLModule {
  }
  </code></pre>