Express GraphQLObjectType不是构造函数
我正试图遵循graphql教程,尽管我遵循了它并仔细检查了一遍,但我一直得到上面的错误,我不知道为什么 当机器人要求你输入更多的代码时,你真的不讨厌吗?这主要是因为我没有线索,我发布了我所有的代码Express GraphQLObjectType不是构造函数,express,graphql,express-graphql,Express,Graphql,Express Graphql,我正试图遵循graphql教程,尽管我遵循了它并仔细检查了一遍,但我一直得到上面的错误,我不知道为什么 当机器人要求你输入更多的代码时,你真的不讨厌吗?这主要是因为我没有线索,我发布了我所有的代码 const express = require("express"); const expressGraphQL = require("express-graphql"); const graphql = require("graphql")
const express = require("express");
const expressGraphQL = require("express-graphql");
const graphql = require("graphql");
const {
GraphQlSchema,
GraphQlObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLNonNull,
} = graphql;
const app = express();
const authors = [
{ id: 1, name: "J. K. Rowling" },
{ id: 2, name: "J. R. R. Tolkien" },
{ id: 3, name: "Brent Weeks" },
];
const books = [
{ id: 1, name: "Harry Potter and the Chamber of Secrets", authorId: 1 },
{ id: 2, name: "Harry Potter and the Prisoner of Azkaban", authorId: 1 },
{ id: 3, name: "Harry Potter and the Goblet of Fire", authorId: 1 },
{ id: 4, name: "The Fellowship of the Ring", authorId: 2 },
{ id: 5, name: "The Two Towers", authorId: 2 },
{ id: 6, name: "The Return of the King", authorId: 2 },
{ id: 7, name: "The Way of Shadows", authorId: 3 },
{ id: 8, name: "Beyond the Shadows", authorId: 3 },
];
const BookType = new GraphQlObjectType({
name: "Book",
description: "A Book written by an author",
fields: () => ({
id: { type: GraphQLNonNull(GraphQLInt) },
name: { type: GraphQLNonNull(GraphQLString) },
authorId: { type: GraphQLNonNull(GraphQLInt) },
}),
});
const RouteQueryType = new GraphQlObjectType({
name: "Query",
description: "Root Query",
fields: () => ({
books: new GraphQLList(BookType),
description: "List of Books",
resolve: () => books,
}),
});
const schema = new GraphQlSchema({
query: RouteQueryType,
});
app.use(
"/graphql",
expressGraphQL({
schema: schema,
graphiql: true,
})
);
app.listen(5000, () => console.log("server running"));
错误的大写字母
GraphQlObjectType
应为GraphQlObjectType