【发布时间】:2021-04-06 13:34:36
【问题描述】:
鉴于以下 GraphQL 请求和变量:
请求:
query accounts($filter:AccountFilter, $first_:String, $skip_:Int) {
accounts(filter: $filter, first: $first_, skip: $skip_) {
id
}
}
变量:
{
"filter": {},
"first_": "3",
"skip_": 0
}
注意:我在first_ 和skip_ 变量名称中添加了下划线,以帮助将它们与参数first 和skip 区分开来。
我收到以下错误:
"Type mismatch on variable $first_ and argument first (String / Int)"
"Type mismatch on variable $skip_ and argument skip (Int / Int)"
我故意创建的第一个错误是为了进行健全性检查。变量中的值应该是"first": 3, 而不是"first": "3",。第二个错误我不明白为什么我得到它。 Int 和 Int 类型如何不匹配?当我正确传递3 并将String 更改为Int 时,first 变量/参数错误会重新报告相同的错误(Int / Int)。
我做错了什么?
后端规格: Ruby on Rails
参数说明:
"""
Interface for the Account model
"""
type Account {
friendlyId: String!
id: ID!
locations: [Location!]!
name: String!
participants: [User!]!
primaryLocation: Location!
primarySiteContact: User!
siteContacts: [User!]!
}
input AccountFilter {
OR: [AccountFilter!]
}
type Query {
"""
Details for an Account
"""
accountDetails(id: ID): Account
"""
A list of Accounts
"""
accounts(filter: AccountFilter, first: Int, skip: Int): [Account!]
}
【问题讨论】:
-
在哪里?什么环境/语言? ... 此查询的 BE 规格/参数类型?
-
你能分享你的架构吗?
-
@xadm 抱歉,我没有后端会出现差异,我以为我推断出
first和skip应该是Ints。 -
@JosephHall,我添加了相关的架构部分(参见第二次编辑)。这是专有的,所以我只包括了我认为有必要知道的内容。如果你需要别的东西,请告诉我。感谢您的帮助!
-
它可能是语言/实现(解析器)特定的问题,因为 gql 类型/参数看起来不错
标签: graphql syntax-error type-mismatch