Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ApolloBoost was initialized with unsupported options:

I'm trying to disable cache on Apollo, therefore I'm following the documentation apollo-client , but I cannot success, I get all the time this warning ApolloBoost was initialized with unsupported options: defaultOptions

Does anyone have the same warning ?

import Vue from 'vue'
import ApolloClient from 'apollo-boost'

    const defaultOptions = {
      watchQuery: {
        fetchPolicy: 'network-only',
        errorPolicy: 'ignore'
      },
      query: {
        fetchPolicy: 'network-only',
        errorPolicy: 'all'
      }
    }

    const client = new ApolloClient({

    defaultOptions: defaultOptions,
    )};
like image 478
Kaiser91 Avatar asked Nov 26 '18 09:11

Kaiser91


1 Answers

It looks like it's because you are using Apollo Boost, a wrapper around Apollo Client with slightly different API.

Try changing your import from:

import ApolloClient from "apollo-boost";

to:

import ApolloClient from "apollo-client";

or in v3:

import { ApolloClient } from '@apollo/client';


The "apollo-client" is more low level and harder to use. That's probably why the team created "apollo-boost".

But looking at the source code "apollo-boost" is a good way to understand how to use the low-level "apollo-client". For example:

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

// in v3, the types moved:
// import { ApolloClient } from '@apollo/client';

const apolloClient = new ApolloClient({
  link: new HttpLink({
    uri: '/graphql',
    credentials: 'same-origin',
  }),
  cache: new InMemoryCache(),
  defaultOptions: {
    query: {
      errorPolicy: 'all',
    },
  },
});

See also the docs on migration from Apollo Boost to Apollo Client like Intellidroid said.

like image 133
Martin Konicek Avatar answered Sep 23 '22 15:09

Martin Konicek