Graphql 查询组件为数据返回null,但网络显示响应

Graphql 查询组件为数据返回null,但网络显示响应,graphql,react-apollo,Graphql,React Apollo,数据为null,但我在/grahpql和network中都看到了响应 查询内容:基本信息: query GetProductById($product_id: Int!) { getProductById(product_id: $product_id) { id product_id name product_type create_time update_time sizes click_url price

数据为null,但我在/grahpql和network中都看到了响应

查询内容:基本信息:

query GetProductById($product_id: Int!) {
  getProductById(product_id: $product_id) {
    id
    product_id
    name
    product_type
    create_time
    update_time
    sizes
    click_url
    price
    discount_price
    coupon_code
    sale_date
    sku
    colors
    in_stock

    regions {
       ...domestic
       ...international
    }
  }
}
编辑:更新:将其缩小为:

    regions {
     ...domestic
     ...international
    }
我认为这就是问题所在。。没有

import { IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData: {
    __schema: {
      types: [
        {
          kind: 'INTERFACE',
          name: 'Regions',
          possibleTypes: [
            {
              name: 'domestic'
            },
            {
              name: 'international'
            }
          ]
        }
      ]
    }
  }
});
 export default fragmentMatcher;




  import fragmentMatcher from './RegionFragmentMatcher';

  const cache = new InMemoryCache();
  const apolloClient = new ApolloClient({
    fragmentMatcher,
    cache,
    link: new HttpLink({
      uri: `${config.url}/graphql`,
      credentials: 'include'
    }),
     resolvers: Resolvers(cache),
     addTypename: true,
     dataIdFromObject,
     introspection: true
    });

    export default apolloClient;

FragmentMatcher应传递给InMemoryCache构造函数,而不是Apollo客户端构造函数:

const cache = new InMemoryCache({ fragmentMatcher });

const client = new ApolloClient({
  cache,
  link: new HttpLink(),
});

查询是什么?为了包含queryok,我开始配对一些查询键,在某个时候,它起了作用。所以,似乎有什么东西把事情搞砸了。但为什么一个有效,另一个无效。。。。?很奇怪。所以,我删除了大约一半的查询键。。。我会把它放回去,然后一个一个地走。请看我的最新评论,也许你可以帮我。你是否将
fragmentMatcher
变量导出为默认导出?我没有看到你粘贴的代码中显示的内容。宾果!!!谢谢兄弟!!就这样。。我不知道我怎么会错过。我只是认为这是更复杂的事情。。哈哈。再一次,谢谢!!!!!