查询GitHub GraphQL API v4不会返回任何结果

时间:2019-03-22 20:33:57

标签: graphql angular7

这是我发送的查询:

issueQuery = gql`
    query IssueQuery {
      search(first: 10, type: ISSUE, query: "repo:angular/angular is:issue state:open error in:title") {
        issueCount
        edges {
          node {
            ... on Issue {
              createdAt
              title
              body
              url
              comments(first: 10) {
                nodes {
                  body
                }
              }
            }
          }
        }
      }
    }
  `;

当组件加载时,我通过它发送查询:

this.issues = this.apollo.watchQuery<Query>({
  query: this.issueQuery
})
.valueChanges
.pipe(map(data => {
  console.log('hello');
  console.log(data);
  return data;
}));

即使“ Hello”也没有打印。而且似乎没有任何连接错误。对于连接,我创建了一个单独的GraphQL模块,并将其导入到主应用程序模块中。在构造函数中,我包括以下内容:

this.apolloBoost.create({
      uri: 'https://api.github.com/graphql',
      request: async (operation) => {
        operation.setContext({
          headers: {
            authorization: `Bearer ${environment.GITHUB_BEARER_TOKEN}`
          }
        });
  }
});

在查询GitHub GraphQL之前,有人遇到过此问题。通过GitHub GraphQL的开发人员部分进行查询时,不会发生这种情况。

0 个答案:

没有答案