Use graphql playground

This commit is contained in:
Trevor Blades
2022-02-11 12:59:51 -08:00
parent ee4c0f0693
commit 2a26db1c48

View File

@@ -1,5 +1,5 @@
import {ApolloServer, gql} from 'apollo-server';
import {ApolloServerPluginLandingPageProductionDefault} from 'apollo-server-core';
import {ApolloServerPluginLandingPageGraphQLPlayground} from 'apollo-server-core';
import {buildSubgraphSchema} from '@apollo/subgraph';
import {readFileSync} from 'fs';
import {resolvers} from './resolvers.js';
@@ -7,20 +7,10 @@ import {resolvers} from './resolvers.js';
const typeDefs = gql(readFileSync('./schema.graphql', 'utf-8'));
const schema = buildSubgraphSchema({typeDefs, resolvers});
let plugins;
if (process.env.NODE_ENV === 'production') {
plugins = [
ApolloServerPluginLandingPageProductionDefault({
footer: false,
graphRef: process.env.APOLLO_GRAPH_REF
})
];
}
const server = new ApolloServer({
schema,
introspection: true,
plugins
plugins: [ApolloServerPluginLandingPageGraphQLPlayground()]
});
server.listen({port: process.env.PORT || 4000}).then(({url}) => {