GraphQL预期使用mysql可迭代

时间:2018-10-01 22:41:01

标签: sql graphql

articles: {
            type: new GraphQLList(articleDataNode),
            args: {cursor: {type: GraphQLInt}, 
                    entries: {type: GraphQLInt}
                },
            resolve(parent, args){
            //The resolve function returns object for you to access query fields such as title, author etc
            //So dont forget to return
            console.log(args.cursor);
            console.log(args.entries);
            return connection.query('SELECT * FROM articles ORDER BY id', (err,results)=>{
                if(err){
                console.log(err)
                }
                console.log(results)
            })


            }
         }

我收到错误“预期可迭代但没有找到它” connection.query返回一个查询对象,这在我使用mongoose和mongoDB时很好

0 个答案:

没有答案