是否可以在生产中禁用游乐场功能?
在我的serverless.yml
中functions:
graphql:
# this is formatted as <FILENAME>.<HANDLER>
handler: handler.graphqlHandler
events:
- http:
path: api/v1
method: post
playground:
handler: handler.playgroundHandler
events:
- http:
path: playground
method: get
在我的handler.js中
import { ApolloServer, gql } from "apollo-server-lambda";
import lambdaPlayground from "graphql-playground-middleware-lambda";
// Construct a schema, using GraphQL schema language
const typeDefs = gql`
type Query {
hello: String
}
`;
// Provide resolver functions for your schema fields
const resolvers = {
Query: {
hello: () => "Hello world!"
}
};
const server = new ApolloServer({ typeDefs, resolvers });
export const graphqlHandler = server.createHandler({
cors: {
origin: "*",
credentials: true
}
});
export const playgroundHandler = lambdaPlayground({
endpoint: "/api/v1"
});