Skip to content
Apollo Link for lazy loading
JavaScript TypeScript
Branch: master
Clone or download
Latest commit 90e73b0 Jan 17, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__ initial commit Jan 6, 2020
dist
examples
src initial commit Jan 6, 2020
.eslintrc.json initial commit Jan 6, 2020
.gitignore initial commit Jan 6, 2020
.travis.yml
CHANGELOG.md
LICENSE
README.md update apidoc Jan 18, 2020
jest.config.js
package-lock.json update apidoc Jan 18, 2020
package.json update apidoc Jan 18, 2020
tsconfig.json initial commit Jan 6, 2020
webpack.config.js

README.md

apollo-link-lazy

Build Status npm version bundle size

Apollo Link for lazy loading

Introduction

This is a tiny library to lazy load Apollo Link. It can be useful for code splitting.

Install

npm install apollo-link-lazy

Usage

import ApolloClient from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { lazy } from 'apollo-link-lazy';

const client = new ApolloClient({
  cache: new InMemoryCache(),
  link: lazy(() => import('./link')),
});

API

lazy

Lazy load ApolloLink promise

Type: Lazy

Parameters

  • factory

Examples

import { lazy } from 'apollo-link-lazy';

const link = lazy(() => import('./link'));

Examples

The examples folder contains working examples. You can run one of them with

PORT=8080 npm run examples:01_minimal

and open http://localhost:8080 in your web browser.

You can also try them in codesandbox.io: 01 02

You can’t perform that action at this time.