const typeDefs = `
type Query {
greeting: String!
}
`;
const typeDefs = `
type Mutation {
setGreetingMessage(message: String!): String
}
`;
let greetingMsg = "Hello, world!";
const resolvers = {
Query: {
greeting () => greetingMsg;
}
},
Mutation: {
setGreetingMessage
}
function setGreetingMessage(_, { message }) {
return greetingMsg = message;
}
function(obj, args, context, info)
const express = require('express');
const { ApolloServer } = require('apollo-server-express');
// import typeDefs and reslovers or define here...
const app = express();
const server = new ApolloServer({
typeDefs,
resolvers,
});
server.applyMiddleware({ app, path: '/graphql' });
app.listen(3000, function () {
console.log('App Started on port 3000);
});