小编Jud*_*ihi的帖子

Apollo-server-express 返回“无法获取/”而不是 Graphql 游乐场

所以我按照阿波罗文档教程https://www.apollographql.com/docs/tutorial/introduction/为我的 server.js 和 schema.js 提供了这段代码

服务器.js

import apollo from "apollo-server-express";
const { ApolloServer } = apollo;
import express from "express";
import typeDefs from "./schema.js";

const app = express();
const server = new ApolloServer({
  typeDefs,
  playground: true,
});

server.applyMiddleware({ app });

const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
  console.log(`operating on port ${PORT}`);
})
Run Code Online (Sandbox Code Playgroud)

架构.js

import pkg from "apollo-server-express"
const { gql } = pkg

// defining schema
 const typeDefs = gql`
  type Launch {
    id: ID!
    site: …
Run Code Online (Sandbox Code Playgroud)

node.js express graphql apollo-server

3
推荐指数
1
解决办法
2413
查看次数

标签 统计

apollo-server ×1

express ×1

graphql ×1

node.js ×1