How to use @accounts/apollo-link - 3 common examples

To help you get started, we’ve selected a few @accounts/apollo-link examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github accounts-js / accounts / packages / apollo / src / index.ts View on Github external
options,
    new AccountsGraphQLClient({
      graphQLClient: apollo,
    })
  );

  let password;
  if (require.resolve('@accounts/client-password')) {
    const AccountsClientPassword = require('@accounts/client-password').AccountsClientPassword; // tslint:disable-line no-implicit-dependencies
    password = new AccountsClientPassword(client, options.password);
  }

  return {
    client,
    apollo,
    link: accountsLink(client),
    password,
  };
};
github accounts-js / accounts / examples / react-graphql-typescript / src / utils / accounts.ts View on Github external
import { AccountsClient } from '@accounts/client';
import { AccountsClientPassword } from '@accounts/client-password';
import GraphQLClient from '@accounts/graphql-client';
import { accountsLink } from '@accounts/apollo-link';
import { ApolloClient } from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { from } from 'apollo-link';
import { InMemoryCache } from 'apollo-cache-inmemory';

// This auth link will inject the token in the headers on every request you make using apollo client
const authLink = accountsLink(() => accountsClient);

const httpLink = new HttpLink({
  uri: 'http://localhost:4000/graphql',
});

const apolloClient = new ApolloClient({
  link: from([authLink, httpLink]),
  cache: new InMemoryCache(),
});

const accountsGraphQL = new GraphQLClient({ graphQLClient: apolloClient });
const accountsClient = new AccountsClient({}, accountsGraphQL);
const accountsPassword = new AccountsClientPassword(accountsClient);

export { accountsClient, accountsGraphQL, accountsPassword, apolloClient };

@accounts/apollo-link

Apollo link for account-js

MIT
Latest version published 3 years ago

Package Health Score

61 / 100
Full package analysis

Popular @accounts/apollo-link functions

Similar packages