0.1.7 • Published 6 years ago

fetch-fragment-matcher v0.1.7

Weekly downloads
303
License
MIT
Repository
github
Last release
6 years ago

(Information collected from here and here)

Problem

Using union (or interface) ObjectTypes, requires providing a custom fragmentMatcher property to the constructor options of apolloClient.

Solution

The solution is to provide a custom fragmentMatcher argument to the options for your apolloClient.

Right now, this is something you'll need to do by hand – i.e. if you revise your ObjectTypes on your server, you'll need to keep this in sync on your client.

How to use this?

1) Run fetch-fragment-matcher with the arguments:

[Input - one of the two options]

* `fetch --e` (--endpoint): The graphql server endpoint
* `get --d` (--directory): The folder directory that contains `.gql | .graphql` type definitions 

[Output]

* --o (--output): The output directory (or to set full path use --output-file)

2) Set the fragment matcher in apollo-client

import { ApolloClient } from 'apollo-client';
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';

const introspectionQueryResultData = require('./fragmentTypes.json');
const fragmentMatcher = new IntrospectionFragmentMatcher({
    introspectionQueryResultData
});

const client = new ApolloClient({
    cache: new InMemoryCache({ fragmentMatcher })
});
0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago