// import ApolloClient from "apollo-boost";

// const client = new ApolloClient({});
import { ApolloClient } from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloLink, concat } from 'apollo-link';


const httpLink = new HttpLink({ uri: '/graphql' });

const authMiddleware = new ApolloLink((operation, forward) => {
  // add the authorization to the headers
  operation.setContext({
    headers: {
      'x-csrf-token': document.getElementsByName('csrf-token')[0] ? document.getElementsByName('csrf-token')[0].content : 0
    } 
  });

  return forward(operation);
})

const client = new ApolloClient({
  link: concat(authMiddleware, httpLink),
  cache: new InMemoryCache(),
});



export default client;
// import ApolloClient from "apollo-boost";

// const client = new ApolloClient({});
import { ApolloClient } from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloLink, concat } from 'apollo-link';


const httpLink = new HttpLink({ uri: '/graphql' });

const authMiddleware = new ApolloLink((operation, forward) => {
  // add the authorization to the headers
  operation.setContext({
    headers: {
      'x-csrf-token': document.getElementsByName('csrf-token')[0] ? document.getElementsByName('csrf-token')[0].getAttribute('content') : 0
    } 
  });

  return forward(operation);
})

const client = new ApolloClient({
  link: concat(authMiddleware, httpLink),
  cache: new InMemoryCache(),
});



export default client;
Fix property 'content' does not exist on type 'HTMLElement'
quill-lms: Fix property 'content' does not exist on type 'HTMLElement'

document.getElementsByName() returns a HTMLElement object, which does not have a property
'content'. [0]

TypeScript is typesafe, so where returned object HTMLElement does not have a property,
any attempted access to it will be invalid. Reported by tslint and typescript@2.9.2.

There are two potential solutions:

 - Utilize the generic .getAttribute('content'); or

 - Cast to the specific subtype (e.g. HTMLMetaElement) [1]  which does have
   a property 'content'.

tslint error:

  ERROR in [at-loader] ./app/modules/apollo.ts:16:113
    TS2339: Property 'content' does not exist on type 'HTMLElement'.

[0] https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
[1] https://developer.mozilla.org/en-US/docs/Web/API/HTMLMetaElement
