How to use the apollo-client-preset.IntrospectionFragmentMatcher function in apollo-client-preset

To help you get started, we’ve selected a few apollo-client-preset 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 marmelab / react-admin / packages / ra-data-graphql / src / buildApolloClient.js View on Github external
export default options => {
    if (!options) {
        return new ApolloClient();
    }

    const { cache, link, uri, ...otherOptions } = options;
    let finalLink = link;
    let finalCache = cache;

    // Create an empty fragment matcher
    // See: https://github.com/apollographql/apollo-client/issues/3397#issuecomment-421433032
    const fragmentMatcher = new IntrospectionFragmentMatcher({
        introspectionQueryResultData: {
            __schema: {
                types: [],
            },
        },
    });

    if (!link && uri) {
        finalLink = new HttpLink({ uri });
    }

    if (!cache) {
        finalCache = new InMemoryCache({ fragmentMatcher }).restore({});
    }

    return new ApolloClient({
github devinit / datahub / src / apollo / index.tsx View on Github external
const cache = () => new InMemoryCache({
  dataIdFromObject: (obj: {uid?: string}) => obj.uid,
  fragmentMatcher: introspectionQueryResultData && new IntrospectionFragmentMatcher({
    introspectionQueryResultData
  })
});