Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from "react";
- import { Meteor } from "meteor/meteor";
- import { render } from "react-dom";
- import { ApolloProvider } from "react-apollo";
- import ApolloClient from "apollo-client";
- import { createHttpLink } from "apollo-link-http";
- import { ApolloLink, from } from "apollo-link";
- import { HttpLink } from "apollo-link-http";
- import { InMemoryCache } from "apollo-cache-inmemory";
- import { meteorClientConfig } from "meteor/apollo";
- import { Accounts } from "meteor/accounts-base";
- // import ApolloClient from "apollo-boost";
- import { MeteorAccountsLink } from "meteor/apollo";
- import { DDPLink } from "apollo-link-ddp";
- import App from "../../ui/App";
- // const httpLink = new HttpLink({
- // uri: Meteor.absoluteUrl("graphql"),
- // });
- const authLink = new ApolloLink((operation, forward) => {
- const token = Accounts._storedLoginToken();
- operation.setContext(() => ({
- headers: {
- "meteor-login-token": token,
- },
- }));
- return forward(operation);
- });
- new DDPLink({
- connection: Meteor.connection,
- });
- const httpLink = new HttpLink({
- uri: "/graphql",
- });
- const cache = new InMemoryCache();
- const client = new ApolloClient({
- link: from([
- httpLink,
- // new MeteorAccountsLink({ headerName: "meteor-login-token" }),
- authLink,
- ]),
- cache,
- });
- const ApolloApp = () => (
- <ApolloProvider client={client}>
- <App />
- </ApolloProvider>
- );
- Meteor.startup(() => {
- render(<ApolloApp />, document.getElementById("app"));
- });
Advertisement
Add Comment
Please, Sign In to add comment