'Must provide typeDefs when using makeAugmentedSchema
I'm new to Neo4j and GraphQL and more or less new to JavaScript. I want to build a GraphQL endpoint using ApolloServer and Neo4j.
The error I don't understand is in line 9 here in server.js
const typeDefs = require('./schema');
const {ApolloServer} = require('apollo-server-express');
const express = require('express');
const neo4j = require('neo4j-driver');
const {makeAugmentedSchema} = require('neo4j-graphql-js');
const app = express();
console.log(typeDefs);
const schema = makeAugmentedSchema(typeDefs); // here!
const driver = neo4j.driver("bolt://localhost:11004", neo4j.auth.basic("neo4j", "password"));
const server = new ApolloServer({
context: {driver},
schema,
introspection: true,
playground: true
});
const port = 4001;
const path = "/graphql";
server.applyMiddleware({app, path});
app.listen({port, path}, () => {
console.log(`GraphQL server ready at http://localhost:${port}${path}`);
});
The error is 'Must provide typeDefs')
The ./schema file looks like the following:
const {gql} = require('apollo-server');
const typeDefs = gql`
type Movie {
genres: String
movieId: Int!
title: String
}
type User {
userId: Int!
username: String
}
type Query {
movie(movieId: Int!): Movie,
user(userId: Int!): User
}
`;
module.exports = typeDefs;
If you could give me a tip what's going on that'd be great.
Solution 1:[1]
Found the answer, the gql
in schema.js
is not necessary. That fixes the problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |