mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
30 lines
747 B
TypeScript
30 lines
747 B
TypeScript
/// <reference path="./express-graphql.d.ts" />
|
|
/// <reference path="../express/express.d.ts" />
|
|
/// <reference path="../express-session/express-session.d.ts" />
|
|
|
|
import * as express from "express";
|
|
import * as graphqlHTTP from "express-graphql";
|
|
|
|
const app = express();
|
|
const schema = {};
|
|
|
|
const graphqlOption: graphqlHTTP.OptionsObj = {
|
|
graphiql: true,
|
|
schema: schema,
|
|
formatError: (error:Error) => ({
|
|
message: error.message,
|
|
})
|
|
};
|
|
|
|
const graphqlOptionRequest = (request: express.Request): graphqlHTTP.OptionsObj => ({
|
|
graphiql: true,
|
|
schema: schema,
|
|
context: request.session,
|
|
});
|
|
|
|
app.use("/graphql1", graphqlHTTP(graphqlOption));
|
|
|
|
app.use("/graphql2", graphqlHTTP(graphqlOptionRequest));
|
|
|
|
app.listen(8080);
|