@apollo/client/core#HttpLink TypeScript Examples

The following examples show how to use @apollo/client/core#HttpLink. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: graphql-client.ts    From dt-mergebot with MIT License 5 votes vote down vote up
link = new HttpLink({ uri, headers, fetch })
Example #2
Source File: main.ts    From vueconf-london with MIT License 5 votes vote down vote up
httpLink = new HttpLink({
  uri: "http://" + GRAPHQL_ENDPOINT,
})
Example #3
Source File: api.service.ts    From etherspot-sdk with MIT License 5 votes vote down vote up
protected onInit(): void {
    const httpLink = new HttpLink({
      fetch,
      uri: buildApiUri(this.options, 'http'),
    });

    const wsLink = new WebSocketLink({
      webSocketImpl: WebSocket,
      uri: buildApiUri(this.options, 'ws', 'graphql'),
      options: {
        reconnect: true,
        lazy: true,
      },
    });

    const authLink = setContext(async () => {
      const {
        accountService, //
        sessionService,
        projectService,
      } = this.services;

      return {
        headers: {
          ...accountService.headers,
          ...sessionService.headers,
          ...projectService.headers,
        },
      };
    });

    const link = split(
      // split based on operation type
      ({ query }) => {
        const definition = getMainDefinition(query);
        return definition.kind === 'OperationDefinition' && definition.operation === 'subscription';
      },
      wsLink,
      authLink.concat(httpLink),
    );

    this.apolloClient = new ApolloClient({
      link,
      cache: this.cache,
    });
  }
Example #4
Source File: client.ts    From vvs-ui with GNU General Public License v3.0 5 votes vote down vote up
client = new ApolloClient({
  link: new HttpLink({
    fetch,
    uri: process.env.EXCHANGE_ENDPOINT,
  }),
  cache: new InMemoryCache(),
})
Example #5
Source File: client.ts    From vvs-ui with GNU General Public License v3.0 5 votes vote down vote up
blockClient = new ApolloClient({
  link: new HttpLink({
    fetch,
    uri: process.env.BLOCKS_ENDPOINT,
  }),
  cache: new InMemoryCache(),
})