Я пытаюсь создать реализацию GraphQL в моем проекте узла. Я создал схему и преобразователь в отдельном js, и я вызываю их из файла index.js. Ниже приведены коды в файлах схемы, распознавателя и индекса js
схема
const schema = `
type Query {
testFunction(): String!
}
schema {
query: Query
}
`;
module.exports = schema;
распознаватель
const resolvers = ()=>({
Query:{
testFunction(){
return "returned from custom test function";
}
}
});
module.exports = resolvers;
Индекс
const graphqlSchema = require('./graphql/schema');
const createResolvers = require('./graphql/resolvers');
const executableSchema = makeExecutableSchema({
typeDefs: [graphqlSchema],
resolvers: createResolvers()
});
const server=hapi.server({
port: 4000,
host:'localhost'
});
server.register({
register: apolloHapi,
options: {
path: '/graphql',
apolloOptions: () => ({
pretty: true,
schema: executableSchema,
}),
},
});
server.register({
register: graphiqlHapi,
options: {
path: '/graphiql',
graphiqlOptions: {
endpointURL: '/graphql',
},
},
});
const init= async()=>{
routes(server);
await server.start();
console.log(`Server is running at: ${server.info.uri}`);
}
init();
Я получаю приведенную ниже ошибку при запуске сервера
node_modules \ graphql \ язык \ parser.js: 1463
throw (0, _error.syntaxError) (lexer.source, token.start, "Expected>". concat (kind, ", found") .concat ((0, _lexer.getTokenDesc) (token)));
Пожалуйста, помогите мне понять, где я иду не так и как решить эту проблему.