mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 02:01:40 -05:00
680 B
680 B
expressApollo
An Express Middleware for the Apollo Server
Example Usage
import * as express from "express";
import * as bodyParser from "body-parser";
import { expressApollo } from "apollo-server";
import schema from "./data/schema";
import * as graphql from 'graphql'
const port = 3000;
const app = express();
const schema = new graphql.GraphQLSchema({
query: new graphql.GraphQLObjectType({
name: 'Query',
fields: {
testString: { type: graphql.GraphQLString }
}
})
});
app.use(bodyParser.text());
app.use("/", expressApollo({schema}));
app.listen(port, () => {
console.log(`Server is listen on ${port}`);
});