convoyinc / apollo-cache-hermes

A cache implementation for Apollo Client, tuned for performance
Other
483 stars 30 forks source link

What is the equivalent of the apollo-cache-inmemory IntrospectionFragmentMatcher? #172

Open gajus opened 7 years ago

gajus commented 7 years ago

This is how I am currently using apollo-client v2:

// @flow

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

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData: {
    // eslint-disable-next-line id-match
    __schema: {
      types: [
        {
          kind: 'INTERFACE',
          name: 'Paragraph',
          possibleTypes: [
            {
              name: 'TextParagraph'
            },
            {
              name: 'ImageParagraph'
            }
          ]
        },
        {
          kind: 'INTERFACE',
          name: 'Markup',
          possibleTypes: [
            {
              name: 'DecorationMarkup'
            },
            {
              name: 'LinkMarkup'
            }
          ]
        }
      ]
    }
  }
});

const apolloClient = new ApolloClient({
  cache: new InMemoryCache({
    fragmentMatcher: fragmentMatcher.match
  }),
  link: new HttpLink({
    credentials: 'include',
    uri: '/api'
  })
});

export default apolloClient;

I have tried migrating to apollo-cache-hermes, but I could not find the equivalent of IntrospectionFragmentMatcher in the code base.

nevir commented 7 years ago

Currently there's no analogue for that in hermes - I'm assuming that you're just using it for union support? You can track that functionality via #153