graphql/express-graphql

[Proposal] Split into multiple middlewares

开放

#113 创建于 2016年8月11日

 (14 条评论) (21 个反应) (0 位负责人)JavaScript (482 个派生)batch import
enhancementhelp wanted

仓库指标

星标
 (5,319 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Just a idea, but I think we should embrace express middleware system.

Maybe something like below:

import { parser, validate, execute, errorHandler, graphiql } from 'express-graphql';
import logger from 'graphql-third-party-query-param-logger';

const app = express();

app.use('/graphql', parser(...));
app.use('/graphql', logger(...));
app.use('/graphql', validate(...));
app.use('/graphql', execute(...));
app.use('/graphql', errorHander(...));
app.use('/graphql', graphiql(...));

app.listen(3000);

And then we can use middlewares at any points to log and measure performance, even have more control on input, output and errors.

Eventually, more reasonable, extendable middlewares will born and enrich the whole graphql ecosystem.

Relative issue: #101 #102 #107

贡献者指南