GraphQL Expected Iterable, but did not find one for field xxx.yyy

那年仲夏 提交于 2019-11-30 03:27:02

I ran into this problem as well but it seems quite obvious why this happens. It appears that what you're returning from your resolver doesn't match the return type in your schema.

Specifically for the error message Expected Iterable, but did not find one for field library.user., your schema expects an array(Iterable) but you aren't returning an array in your resolver

I had this in my schema.js:

login(email: String, password: String): [SuccessfulLogin]

I changed that to:

login(email: String, password: String): SuccessfulLogin

Notice the square brackets around "SuccessfulLogin". It's upto you whether you want to update the resolver return type or update the schema's expectations

I guess your user is an instance of GraphQLList that is why the field user is expecting to resolve to an iterable object.

I had the same problem. I was using find instead filter.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!