2

我有一个简单的查询(Apollo-Angular 客户端)从 GraphQL 服务器获取一些数据

  public getQuestionBank(courseCode: string): Observable<ApolloQueryResult<{}>> {
    const query = gql`
    query GetQuestionsQuery($courseCode: String!) {
      questions(courseCode: $courseCode) {
        questions
        status
      }
    }
  `;
  console.log(`GETTING QUESTIONS FOR: ${courseCode}`);
  return this.apollo.query({
    query: query,
    variables: {
      courseCode: courseCode
    },
    errorPolicy: 'all',
    context: {
      headers: new HttpHeaders().set('Authorization', this.user.Token)
    }
  });
}

触发了console.log,但服务器从未收到请求我使用类似类型的查询登录,这很有效

  public login(email: string, password: string): Observable<ApolloQueryResult<{}>> {
    const query = gql`
    query TeacherLoginQuery($email: String!, $password: String!) {
      teacherLogin(email: $email, password: $password) {
        id
        email
        admin
        token
        name
        status {
          code
        }
      }
    }
  `;

  return this.apollo.query({
    query: query,
    variables: {
      email: email,
      password: password
    },
    errorPolicy: 'all',
  });
}

我在服务器上有一个摩根记录器,但没有收到任何请求

4

1 回答 1

0

我有同样的问题,重置客户端商店对我有用。

await this.apollo.client.resetStore();

于 2022-01-10T20:03:49.253 回答