【发布时间】:2021-02-05 19:26:17
【问题描述】:
schema.js
const { buildSchema } = require('graphql');
module.exports = buildSchema(`
type Booking {
_id: ID!
event: Event!
user: User!
}
type Event {
_id: ID!
title: String!
description: String!
price: Float!
creator: User
}
type User {
_id: ID!
email: String!
password: String
createdEvents: [Event!]
}
type RootQuery {
events: [Event!]!
users: [User!]!
bookings: [Booking!]!
}
schema {
query: RootQuery
}
`);
index.js
app.use(
'/graphql',
graphqlHTTP({
schema: graphQlSchema,
rootValue: graphQlResolvers,
graphiql: true
})
);
我只是想学习 graphql,这是我的第一次,所以我有点困惑上面的查询工作正常,但我想要 3 个不同的文件用于预订、用户、事件并将它们合并到一个文件名索引中。 js,然后在主 index.js 中导入,它高于一个。这是我第一次学习graphql。任何帮助将不胜感激
【问题讨论】:
标签: node.js graphql apollo-server express-graphql