function createClient(headers, token, initialState) { let accessToken = token; (async () => { // eslint-disable-next-line no-param-reassign accessToken = token || (await persist.willGetAccessToken()); })(); const authLink = new ApolloLink((operation, forward) => { operation.setContext({ headers: { authorization: accessToken } }); return forward(operation); }).concat(httpLink); return new ApolloClient({ headers, link: authLink, connectToDevTools: process.browser, ssrMode: !process.browser, cache: new InMemoryCache().restore(initialState || {}) }); }
operation.setContext( ( { headers = {} } ) => ( { headers: { "woocommerce-session": `Session ${ session }` } } ) );
function createClient({ headers }) { return new ApolloClient({ uri: process.env.NODE_ENV === 'development' ? endpoint : endpoint, request: operation => { operation.setContext({ fetchOptions: { credentials: 'include', }, headers, }); }, }); }
export function generateClient(token) { if (token.length !== TOKEN_LENGTH) { return null; } const client = new ApolloClient({ uri: "https://api.github.com/graphql", request: operation => { operation.setContext({ headers: { authorization: "Bearer " + token } }); } }); return client; }
const queryOrMutationLink = (config = {}) => new ApolloLink((operation, forward) => { operation.setContext({ credentials: 'same-origin', headers: { authorization: `Bearer ${localStorage.getItem('auth_token')}` } }); return forward(operation); }).concat( new HttpLink({ uri: 'http://localhost:5000/graphql', ...config, }) )
Promise.resolve(options.promptTwoFactorCode()) .then(code => { operation.setContext(({headers = {}}) => ({ headers: {
this.client = new ApolloClient({ uri: GraphQlUrl, request: gqloperation => gqloperation.setContext({ headers: { Authorization: `Bearer<${this.props.webToken}>`
function createClient({ headers }) { const cache = new InMemoryCache(); const authLink = new ApolloLink((operation, forward) => { operation.setContext({ fetchOptions: { credentials: "include"
operation.setContext(({ headers = {} }) => ({ headers: { ...headers, 'meteor-login-token': getUserToken() } }))
operation.setContext(({ headers = {} }) => ({ headers: { ...headers, 'accept-language': getLanguage() } }))
uri: process.env.NODE_ENV === 'development' ? endpoint : prodEndpoint, request: operation => { operation.setContext({ fetchOptions: { credentials: 'include',
function createClient({ headers }) { return new ApolloClient({ uri: process.env.NODE_ENV === 'development' ? endpoint : endpoint, request: operation => { operation.setContext({ fetchOptions: { credentials: 'include', }, headers, }); }, }); }
function createClient({ headers }) { return new ApolloClient({ uri: process.env.NODE_ENV === 'development' ? endpoint : endpoint, request: operation => { operation.setContext({ fetchOptions: { credentials: 'include', }, headers, }); }, }); }
function createClient({ headers }) { return new ApolloClient({ uri: process.env.NODE_ENV === 'development' ? endpoint : endpoint, request: operation => { operation.setContext({ fetchOptions: { credentials: 'include', }, headers, }); }, }); }
uri: process.env.NODE_ENV === 'development' ? endpoint : prodEndpoint, request: operation => { operation.setContext({ fetchOptions: { credentials: 'include',