如何在 Angular 5 中使用 GET 方法使用 apollo graphql 查询

Posted

技术标签:

【中文标题】如何在 Angular 5 中使用 GET 方法使用 apollo graphql 查询【英文标题】:how to use apollo graphql query using GET method in angular 5 【发布时间】: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 方法发送。请帮我解决这个问题。谢谢

【问题讨论】:

【参考方案1】:

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

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

【讨论】:

以上是关于如何在 Angular 5 中使用 GET 方法使用 apollo graphql 查询的主要内容,如果未能解决你的问题,请参考以下文章