![](/img/trans.png)
[英]Graphql react-apollo IntrospectionFragmentMatcher issues
[英]Graphql react-apollo IntrospectionFragmentMatcher
我正在使用GitHub Graphql API,并使用react-apollo编写了以下代码,但是当我在许多请求后分页时,控制台上出现以下错误。
您正在使用简单的(启发式)片段匹配器,但是您的查询包含联合或接口类型。 Apollo Client将无法准确映射片段。 要消除此错误,请按照docs中所述使用
IntrospectionFragmentMatcher
: https : //www.apollographql.com/docs/react/recipes/fragment-matching.html
。
警告:启发式片段匹配正在进行中!
。
{“ __typename”:“ Organization”}中缺少字段名称
{“ __typename”:“ Organization”}中缺少字段avatarUrl
{“ __typename”:“ Organization”}中缺少字段存储库
我写了以下代码:
gql`
query($username: String!, $nextPage: String) {
search(query: $username, type: USER, first: 100, after: $nextPage) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
... on User {
name
avatarUrl
repositories {
totalCount
}
}
}
}
}
}
`;
handleSubmit = ({ username }) => {
const { client } = this.props;
this.setState({
loading: true,
searchTerm: username,
});
client
.query({
query: SEARCH_USER,
variables: {
username
}
})
.then(({ data }) => {
this.setState({
loading: false,
searchList: data.search.edges,
pagination: data.search.pageInfo,
});
})
.catch(err => {
console.warn(err);
});
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.