gpt4 book ai didi

graphql - 在GraphQL中,我可以使用Content-Type : application/graphql?发送变量吗

转载 作者:行者123 更新时间:2023-12-04 17:07:23 25 4
gpt4 key购买 nike

我试过在graphql中使用变量,
但是用'application/graphql'发送变量似乎是不可能的。

我是否应该继续转到Content-Type:'application/json'?

最佳答案

http://graphql.org/learn/serving-over-http/#post-request

A standard GraphQL POST request should use the application/json content type, and include a JSON-encoded body of the following form:


{
"query": "...",
"operationName": "...",
"variables": { "myVariable": "someValue", ... }
}

operationName and variables are optional fields. operationName is only required if multiple operations are present in the query.

In addition to the above, we recommend supporting two additional cases:

... If the "application/graphql" Content-Type header is present, treat the HTTP POST body contents as the GraphQL query string.



以我的理解, Content-Type: "application/graphql"是无变量查询的简写。

所以我的答案是“是的,如果我要使用变量字段,则必须使用 Content-Type: "application/json" header

关于graphql - 在GraphQL中,我可以使用Content-Type : application/graphql?发送变量吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43675933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com