【问题标题】:how to use apollo graphql query using GET method in angular 5如何在 Angular 5 中使用 GET 方法使用 apollo graphql 查询
【发布时间】:2018-11-01 07:55:09
【问题描述】:

Angular5 中使用 Apollo GraphQL 发送 GET 请求的查询格式是什么?

我用过

    this.querySubscription = this.apollo.watchQuery<any>({
         query: gql`
         query listSchemaAttributes($schemaDomain: String!) {
            query listSchemaAttributes(schemaDomain: $schemaDomain) {
                 type
                 uniqueName
                 isList
             }
         }
       `,
         variables: {
             schemaDomain: "abc",
         },
     })
         .valueChanges
        .subscribe(({data}) => {
            this.currentUser = data.currentUser;
        });

当我签入网络选项卡时,此请求以 POST 方法发送,但我需要以 GET 方法发送。请帮我解决这个问题。谢谢

【问题讨论】:

    标签: angular get graphql apollo-client


    【解决方案1】:

    您可以使用 apollo-angular-link-httpmethod 选项将其设置为 GET

    https://github.com/apollographql/apollo-angular/tree/master/packages/apollo-angular-link-http#options

    【讨论】:

      猜你喜欢
      • 2021-01-01
      • 2021-04-19
      • 1970-01-01
      • 2016-11-30
      • 2020-04-26
      • 2023-03-15
      • 2018-06-09
      • 2019-06-13
      • 2020-04-06
      相关资源
      最近更新 更多