在早期prisma
版本中,它作为可以访问localhost:4466
的端点公开。graphql-playground
通过这个操场,我们可以直接对查询进行正确的操作来操作数据库中的数据。
我正在尝试使用 graphql-yoga 设置 prisma,但我遇到了问题。
Graphql Yoga 运行在localhost:4000
. 棱镜游乐场在哪里运行?我怎样才能访问它?
有prisma studio
用于操作数据库的 UI,但我需要 graphql 接口,因为它在节点绑定中是必需的。
棱镜.js
import { Prisma } from 'prisma-biding';
const prisma = new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint: 'localhost:5555' // here
})
index.js
import { GraphQLServer, PubSub } from 'graphql-yoga';
import db from './db';
import Query from './resolvers/Query';
import Mutation from './resolvers/Mutation';
import User from './resolvers/User';
import Post from './resolvers/Post';
import Comment from './resolvers/Comment';
import Subscription from './resolvers/Subscription';
const pubsub = new PubSub()
// Resolvers
const resolvers = {
Query,
Mutation,
User,
Post,
Comment,
Subscription
};
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
context: {
db,
pubsub
}
})
server.start(() => console.log(`Grapqhl server is running on ${process.env.port}`));