graphql/express-graphql

[Proposal] Split into multiple middlewares

Open

#113 建立於 2016年8月11日

在 GitHub 查看
 (14 留言) (21 反應) (0 負責人)JavaScript (482 fork)batch import
enhancementhelp wanted

倉庫指標

Star
 (5,319 star)
PR 合併指標
 (30 天內沒有已合併 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

貢獻者指南