How to use the apollo-client/ApolloClient function in apollo-client

To help you get started, we’ve selected a few apollo-client 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 tadasant / where-in-the-world / app / src / App.js View on Github external
}),
  new HttpLink({
    uri: graphqlUri,
  })
]);

const link = split(
  ({query}) => {
    const {kind, operation} = getMainDefinition(query);
    return kind === 'OperationDefinition' && operation === 'subscription';
  },
  wsLink,
  httpLink,
);

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

// adding fontawesome icons we'll use
library.add(faMapMarker);
library.add(faMapPin);
library.add(faMapMarkerAlt);


class App extends Component {
  render() {
    return (
github akeating / pespa / src / client / vue / src / api / client.js View on Github external
export default function newClient(opts) {
  // eslint-disable-next-line new-cap
  const link = new ApolloLink.split(
    operation => hasSubscription(operation.query),
    absintheSocketLink(opts),
    createHttpLink({uri: '/api/graphql'})
  );

  const client = new ApolloClient({
    link,
    cache: new InMemoryCache()
  });
  return client;
}
github Webiks / GeoStrike / packages / client / src / app / core / configured-apollo / network / apollo.service.ts View on Github external
types: [
              {
                'kind': 'INTERFACE',
                'name': 'User',
                'possibleTypes': [
                  {'name': 'Player'},
                  {'name': 'Viewer'}
                ]
              },
            ],
          },
        }
      });


      this._apolloClient = new ApolloClient({
        networkInterface: this._subscriptionClient,
        fragmentMatcher: fragmentMatcher,
      });
    });
  }