![](/img/trans.png)
[英]GraphQL, React, Apollo - Expected Iterable, but did not find one for field "..."
[英]Expected Iterable but did not find one for field
使用GraphQL和SQLite,這是我的查詢:
{
book {
id
authors {
name
}
}
}
類型:
type Book {
id: ID!
title: String
actors: [Author!]!
}
type Author {
id: ID!
name: String
}
這是我的決心:
const resolvers = {
Query: {
book: async (_, __, { db }) => {
return await db.all('SELECT * FROM books');
},
}
};
錯誤是:
“ message”:“預期可迭代,但沒有為Book.authors字段找到一個。”,
在查詢解析器中,您僅從選擇的'SELECT * FROM books'
解析books
。
如果您希望能夠查詢books
和authors
,並且只有一個解析器,則必須返回兩個對象,即必須在解析器book
構建並返回完整的對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.