Bladeren bron

Docsify Auto Published

willin 7 jaren geleden
bovenliggende
commit
e6d85a2fc8
1 gewijzigde bestanden met toevoegingen van 2 en 6 verwijderingen
  1. 2 6
      basic/db/graphql.md

+ 2 - 6
basic/db/graphql.md

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