javascript [basic graphql-yoga]连接到monoDB #graphql #mongoose #mongoDB
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript [basic graphql-yoga]连接到monoDB #graphql #mongoose #mongoDB相关的知识,希望对你有一定的参考价值。
import chalk from "chalk";
import { connectMongo, models } from "./DB/index";
import { GraphQLServer } from "graphql-yoga";
import resolvers from "./graphql/resolvers";
require("dotenv").config();
const { MONGOUSER, PASSWORD, URL, DB } = process.env;
let dbInfo = {
user: MONGOUSER,
pwd: PASSWORD,
url: URL,
db: DB
};
console.log("dbInfo", dbInfo);
const db = connectMongo(dbInfo);
const context = _ => {
return { models, db, auth: _.request.headers.authorization };
};
const typeDefs = `${__dirname}/graphql/schema.graphql`;
// const resolvers = {
// Query: {
// hello: (_, { name }) => `Hello ${name || "World"}`
// }
// };
const server = new GraphQLServer({ typeDefs, resolvers, context });
server.start(() => console.log("Server is running on localhost:4000"));
以上是关于javascript [basic graphql-yoga]连接到monoDB #graphql #mongoose #mongoDB的主要内容,如果未能解决你的问题,请参考以下文章
graphQL 多重突变交易
我收到以下错误:[GraphQL 错误]:消息:任务
基于 GraphQL 构建 Laravel API —— 基本使用篇
[GraphQL] Write a GraphQL Schema in JavaScript
javascript Gerando Exception javascript graphql
如何从 GraphQLSchema javascript 对象获取 .graphql 文件?