[英]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.