что я хотел сделать, это отделить мою схему от файла index.js.так вот файл index.js и файл schema.js после разделения.
// schema.js
import { gql, makeExecutableSchema } from 'apollo-server-express';
const typeDefs = gql`
type Query {
hello : String
}
`;
const resolvers = {
Query:{
hello: () => 'HelloWorld!'
}
};
export default makeExecutableSchema({
typeDefs,
resolvers,
});
// index.js
import { ApolloServer } from 'apollo-server-express';
import express from 'express';
const schema = require('./schema');
const app = express();
const server = new ApolloServer({schema});
server.applyMiddleware({app});
app.listen(4000, ()=> {
console.log(`app is working on port 4000 ${server.graphqlPath}`);
});
я все еще могу открыть площадку graphql на localhost: 4000 / graphql, но после разделения я получаю следующую ошибку.
![enter image description here](https://i.stack.imgur.com/d6ZPG.png)