0
我有一個問題,我不能自己解決。
基本的查詢總之,突變等類型的我做了以下類型定義:
module Types
UserType = GraphQL::ObjectType.define do
name 'User'
description 'A user'
implements GraphQL::Relay::Node.interface
global_id_field :id
field :email, !types.String, 'Email address'
connection :docs, DocType.connection_type, 'Available docs'
end
end
然後我嘗試進行查詢:
query FileListQuery(
$after: String
$first: Int
) {
viewer {
currentUser {
docs(first: $first, after: $after) {
edges {
node {
id
name
__typename
}
cursor
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
id
}
id
}
}
而且我通過以下作爲查詢變量:
{
"first": 1,
"after": null
}
問題是它與以下內容保持一致:
{
"errors": [
{
"message": "Int isn't a defined input type (on $first)",
"locations": [
{
"line": 3,
"column": 3
}
],
"fields": [
"query FileListQuery"
]
}
]
}
老實說,我不知道爲什麼它抱怨Int類型...
如果我擺脫在請求中的問題$first
查詢變量,它工作正常。
此:
query FileListQuery(
$after: String
) {
viewer {
currentUser {
docs(first: 10, after: $after) {
edges {
node {
id
name
__typename
}
cursor
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
id
}
id
}
}
產生以下:
{
"data": {
"viewer": {
"currentUser": {
"docs": {
"edges": [
{
"node": {
"id": "1",
"name": "First Doc",
"__typename": "Doc"
},
"cursor": "MQ=="
}
],
"pageInfo": {
"endCursor": "MQ==",
"hasNextPage": false,
"hasPreviousPage": false,
"startCursor": "MQ=="
}
},
"id": "1"
},
"id": "VIEWER"
}
}
}
任何提示,就如何解決這個想法?我使用graphql gem v1.6.3。
你有沒有解決問題了嗎?我有同樣的錯誤消息,儘管類型是在架構中定義的... – nattfodd
嗨,@nattfodd,請查看下面接受的答案。 AFAIK,這個問題的解決方案已經合併,應該從那以後發佈。如果你仍然遇到同樣的問題,我認爲,重新開放這個問題可能是一種方法。 – eploko