|
@@ -91,17 +91,17 @@ const PORT = 3000;
|
|
|
// koaBody is needed just for POST.
|
|
|
app.use(koaBody());
|
|
|
|
|
|
-router.post('/graphql', graphqlKoa({ schema }));
|
|
|
-router.get('/graphql', graphqlKoa({ schema }));
|
|
|
-router.post('/graphiql', graphiqlKoa({ schema }));
|
|
|
-router.get('/graphiql', graphiqlKoa({ schema }));
|
|
|
+router.post('/graphql', graphqlKoa({ endpointURL: '/graphql', schema }));
|
|
|
+router.get('/graphql', graphqlKoa({ endpointURL: '/graphql', schema }));
|
|
|
+router.post('/graphiql', graphiqlKoa({ endpointURL: '/graphql', schema }));
|
|
|
+router.get('/graphiql', graphiqlKoa({ endpointURL: '/graphql', schema }));
|
|
|
|
|
|
app.use(router.routes());
|
|
|
app.use(router.allowedMethods());
|
|
|
app.listen(PORT);
|
|
|
```
|
|
|
|
|
|
-!> 注意: 本来是想用`koa`做的, 但在本文更新的时候, `graphql-server-koa` 有 Bug, 跑起来之后会报错 `NO SCHEMA AVAILABLE`, 所以又写了一个 `express` 的 Server, 可运行.
|
|
|
+!> <del>注意: 本来是想用`koa`做的, 但在本文更新的时候, `graphql-server-koa` 有 Bug, 跑起来之后会报错 `NO SCHEMA AVAILABLE`, 所以又写了一个 `express` 的 Server, 可运行.</del> Koa 需要在参数中添加 `endpointURL`.
|
|
|
|
|
|
# 连接 SQL 数据库
|
|
|
|