【发布时间】:2018-10-16 08:15:01
【问题描述】:
我正在尝试使用 GraphQL/Apollo,而我的“文档资源管理器”无限加载并且不显示任何内容,而且我无法进行任何查询。
几分钟后,我收到了一个 typeError "Failed to fetch"。
这是我的graphql/index.js 文件:
const { graphqlExpress, graphiqlExpress } = require('apollo-server-express');
const { makeExecutableSchema } = require('graphql-tools');
const User = require('../models/user.model');
const typeDefs = `
type Query {
users: [User]
}
type User {
id: ID!
name: String
email: String
password: String
}
`;
const resolvers = {
Query: {
users() {
return User.find({});
}
}
}
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
module.exports = (app) => {
app.use('/graphql', () => { }, graphqlExpress({ schema }));
app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
};
Console 和 DevTools 都清楚。有人可以解释一下,怎么了?谢谢!
【问题讨论】:
标签: node.js graphql apollo graphiql