简体   繁体   English

2022年如何使用apollo server express打开graphql游乐场页面?

[英]How to open graphql playground page using apollo server express in 2022?

We have a API project using express with Apollo server express and graphql, I am new to graphql so I don't know how to land graphql playground page by default. We have a API project using express with Apollo server express and graphql, I am new to graphql so I don't know how to land graphql playground page by default. when I am trying to run it lands on "http://localhost:8080/graphql but it shows当我试图运行它时,它会出现在“http://localhost:8080/graphql 但它显示

The full landing page can not be loaded;无法加载完整的着陆页; it appears that you might be offline看来您可能处于离线状态

can any one help me how to land graphql playground page?谁能帮助我如何登陆 graphql 游乐场页面?

I have followed the below code我已经按照下面的代码

const express = require('express');
const { ApolloServer, gql } = require('apollo-server-express');


const typeDefs = gql`
  type Query {
    hello: String
  }
`;

const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};

const server = new ApolloServer({ typeDefs, resolvers });

const app = express();
server.applyMiddleware({ app });

const port = 8080;

app.listen({ port }, () =>
  console.log(`🚀 Server ready at http://localhost:${port}${server.graphqlPath}`),
);

Install apollo-server-core and add {ApolloServerPluginLandingPageGraphQLPlayground} it from the plugin section安装 apollo-server-core 并从插件部分添加 {ApolloServerPluginLandingPageGraphQLPlayground}

source https://www.apollographql.com/docs/apollo-server/api/plugin/landing-pages/来源https://www.apollographql.com/docs/apollo-server/api/plugin/landing-pages/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在GraphQL解析器中访问请求对象(使用Apollo-Server-Express) - How to access the request object inside a GraphQL resolver (using Apollo-Server-Express) graphql突变如何在apollo服务器表达式中接受参数数组? - How can a graphql mutation accept an array of arguments with apollo server express? 如何使用 Ember-Apollo 连接到 Graphql 服务器? - How to connect to Graphql server using Ember-Apollo? Graphql Playground 和 Apollo Client 之间的结果不一致 - Inconsistent results between Graphql playground and Apollo Client 使用 Apollo Graphql 服务器解析关系文档 - Resolving relational document using Apollo Graphql Server 在我的 apollo graphQL express 服务器中实现套接字连接 - Implement a socket connection in my apollo graphQL express server 使用 apollo-express 限制或过滤 graphql 查询 - Limiting or filtering a graphql query using apollo-express 错误:正文必须是字符串。 收到:{ resolvers: [[function HelloResolver]], validate: false } 使用 Type-graphql 和 apollo-server-express 时 - Error: Body must be a string. Received: { resolvers: [[function HelloResolver]], validate: false } when using Type-graphql and apollo-server-express 如何在Apollo / GraphQL中使用Styleguidist进行配置 - How to configure using Styleguidist with Apollo/GraphQL 如何使用react和react-apollo从graphql服务器获取数据? - how to get data from graphql server using react and react-apollo?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM