这是我的架构:
type users {
id: ID
name: String
count: Int!
createdListings: [listings]
listings: [listings]
}
type listings {
id: ID
created_by: users
name: String
}
这是我的查询输入:
{
topUsers {
id
name
listings {
name
}
}
}
type Query {
topUsers(page: Int): [users!]!
}
这是我的解析器功能:
const usersResolve = {
users: {
listings: (parent, args) =>
},
};
我的Postgres DB Shems:
CREATE TABLE users
(
id integer PRIMARY KEY,
name character varying
(64)
);
CREATE TABLE listings
(
id integer PRIMARY KEY,
created_by integer references users
(id),
desc text
);
请帮助。我是GraphQL的新手。我该如何编写resolve函数?我一直在做试验错误,停留了好几个小时。