我是GraphQL的新手,正在寻求帮助。我正在尝试创建六个用户对象,并查询所有六个对象,但是在执行查询时我只会看到两个。谁能帮忙吗?
const { ApolloServer } = require("apollo-server");
const { importSchema } = require("graphql-import");
const { MockList } = require("graphql-tools");
const casual = require("casual");
// Construct a schema, using GraphQL schema language
const typeDefs = importSchema("./schema.graphql");
// Provide resolver functions for your schema fields
const resolvers = {
Query: {
hello: () => "Hello world!"
}
};
const mocks = {
Query: () => ({
Member: () => new MockList([0, 6])
}),
Member: () => ({
id: casual.integer(0),
name: casual.full_name,
username: casual.username,
sourceAddress: casual.numerify("+1##########"),
email: casual.email,
gender: casual.random_element(["Male", "Female"])
})
};
const server = new ApolloServer({
typeDefs,
resolvers,
mocks
});
server.listen().then(({ url }) => {
console.log(`Server ready at ${url}`);
});
我输入的查询是
query{
feed{
name
}
}
我得到这些结果
{
"data": {
"feed": [
{
"name": "Kenyon Reilly"
},
{
"name": "Allan Collier"
}
]
}
}
任何帮助表示赞赏!
沙箱: