React-apollo: FragmentMatcher.match() was called before FragmentMatcher.init()

Created on 5 Jun 2017  路  1Comment  路  Source: apollographql/react-apollo

I'm getting this error while using the fragmentMatcher: new IntrospectionFragmentMatcher({...}) option when creating the ApolloClient. I'm using the fragment matcher so that I can make graphql requests which include fragments which match when an interface type is one of the subtypes.

Most helpful comment

I figured out the problem.
I constructed the IntrospectionFragmentMatcher in the following way:

const fragmentMatcher = new IntrospectionFragmentMatcher({
    __schema: {
      types: [
        {
         "kind": "INTERFACE",
         "name": "User",
         "possibleTypes": [
           {"name": "Renter"},
           {"name": "PropertyManager"},
           {"name": "ServiceProfessional"}
         ]
       },
      ]
    }
});

when I'm actually supposed to construct it as

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData: {
    __schema: {
      types: [
        {
         "kind": "INTERFACE",
         "name": "User",
         "possibleTypes": [
           {"name": "Renter"},
           {"name": "PropertyManager"},
           {"name": "ServiceProfessional"}
         ]
       },
      ]
    }
  }
});

>All comments

I figured out the problem.
I constructed the IntrospectionFragmentMatcher in the following way:

const fragmentMatcher = new IntrospectionFragmentMatcher({
    __schema: {
      types: [
        {
         "kind": "INTERFACE",
         "name": "User",
         "possibleTypes": [
           {"name": "Renter"},
           {"name": "PropertyManager"},
           {"name": "ServiceProfessional"}
         ]
       },
      ]
    }
});

when I'm actually supposed to construct it as

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData: {
    __schema: {
      types: [
        {
         "kind": "INTERFACE",
         "name": "User",
         "possibleTypes": [
           {"name": "Renter"},
           {"name": "PropertyManager"},
           {"name": "ServiceProfessional"}
         ]
       },
      ]
    }
  }
});
Was this page helpful?
0 / 5 - 0 ratings