MinsoftK

Merge branch 'master' of https://bitbucket.org/vel1024/capstone2

......@@ -14,12 +14,15 @@
"homepage": "https://bitbucket.org/vel1024/capstone2#readme",
"dependencies": {
"dotenv": "^8.2.0",
"graphql-yoga": "^1.18.3"
"graphql-tools": "^4.0.7",
"graphql-yoga": "^1.18.3",
"merge-graphql-schemas": "^1.7.7"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/node": "^7.8.7",
"@babel/preset-env": "^7.9.0",
"morgan": "^1.10.0",
"nodemon": "^2.0.2"
}
}
......
import path from "path";
import { makeExecutableSchema } from "graphql-tools";
import { fileLoader, mergeResolvers, mergeTypes } from "merge-graphql-schemas";
const allTypes = fileLoader(path.join(__dirname, "api/**/*.graphql"));
const allResolvers = fileLoader(path.join(__dirname, "api/**/*.js"));
const schema = makeExecutableSchema({
typeDefs: mergeTypes(allTypes),
resolvers: mergeResolvers(allResolvers),
});
export default schema;
import { GraphQLServer } from "graphql-yoga";
import dotenv from "dotenv";
dotenv.config();
import { GraphQLServer } from "graphql-yoga";
import morgan from "morgan";
import schema from "./schema";
const PORT = process.env.PORT || 4000;
const typeDefs = `
type Query {
hello(name: String): String
}
`;
const PORT = process.env.PORT;
const resolvers = {
Query: {
hello: () => "hello",
},
};
const server = new GraphQLServer({ schema });
const server = new GraphQLServer({ typeDefs, resolvers });
server.express.use(morgan("dev"));
server.start(() => console.log(`server is running : http://localhost:${PORT}`));
......