我正在运行一个Absinthe查询,其中有三个参数字段,它们都是整数列表。
@desc "Fetches resolutions of Taiga ids"
field :taiga_ids, :taiga_entities do
arg :usIds, list_of(:integer)
arg :taskIds, list_of(:integer)
arg :issueIds, list_of(:integer)
resolve &Resolvers.Bridges.fetch_taiga_ids/3
end
object :taiga_entities do
field :uss, list_of(:taiga_us)
field :tasks, list_of(:taiga_task)
field :issues, list_of(:taiga_issue)
end我也在使用失眠症来发送查询和播放结果。据我所知,一切都是正确的,类型受到尊重,参数被正确地输入。
{
taigaIds(usIds: [1914], taskIds: [], issueIds: [7489]) {
uss {
id
ref
subject
}
issues {
id
ref
subject
}
}
}但我得到了以下错误,这是没有意义的。
{
"errors": [
{
"message": "Unknown argument \"usIds\" on field \"taigaIds\" of type \"RootQueryType\".",
"locations": [
{
"line": 2,
"column": 0
}
]
},
{
"message": "Unknown argument \"taskIds\" on field \"taigaIds\" of type \"RootQueryType\".",
"locations": [
{
"line": 2,
"column": 0
}
]
},
{
"message": "Unknown argument \"issueIds\" on field \"taigaIds\" of type \"RootQueryType\".",
"locations": [
{
"line": 2,
"column": 0
}
]
}
]
}知道为什么吗?
发布于 2019-04-30 20:55:43
按照约定,模式实体的名称(如字段和参数)是编写camelCase的,而elixer则使用snake_case。absinthe在这两种命名约定之间进行转换。根据文档
这定义了一个适配器,它支持传统( JS) camelcase表示法中的GraphQL查询文档,同时允许使用常规(在Elixir中)下划线(snakecase)表示法定义模式,并根据需要转换查找、结果和错误消息所需的名称。 ..。 注意,变量是面向客户的关注点(它们可以作为参数提供),因此变量名应该与查询文档的约定(例如,camelCase)相匹配。
换句话说,像这样定义您的args:
arg :task_ids, list_of(:integer)他们会为你转换成camelCase。
https://stackoverflow.com/questions/55927729
复制相似问题