【发布时间】:2019-07-03 03:04:43
【问题描述】:
数据为空,但是,我在 /grahpql 和网络中都看到了响应。
查询是什么:准系统:
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变量导出为默认导出?我没有看到您粘贴的代码中显示的内容。
标签: graphql react-apollo