Apollo Angular未发送请求

时间:2019-01-17 19:00:52

标签: node.js angular graphql apollo-client apollo-angular

我有一个简单的查询(Apollo-Angular Client),可以从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',
  });
}

我的服务器上有一个摩根记录仪,没有收到请求

0 个答案:

没有答案