MinJie
MinJie
I have also encountered, useState does not have this problem 😭
`useReducer` dispatch does not change the data will have additional render. And `useState` will not have this time render In react 17 there will be no such problem.
找了好久,终于看到这么清晰明了的配置了
刚刚看到 `graphql` 可以用指令的形式指定权限,不知道这种方式有什么弊端 ```graphql # I want posts to only be readable by logged-in users type Post @isLoggedIn { id: ID content: String author: User() notes: [String] @isAuthor # I...
在 `egg-graphql` 中 https://github.com/eggjs/egg-graphql/blob/master/lib/load_schema.js#L52 ```js this[SYMBOL_SCHEMA] = makeExecutableSchema({ typeDefs: schemas, resolvers: resolverMap, directiveResolvers: directiveMap, }); ``` 只传入了3个参数,要实现上述评论的权限指令根本不行。 在 `graphql-tools` 中 https://github.com/apollographql/graphql-tools/blob/48b4c12100b0d517f596a47d830afc77bfe471f9/src/schemaGenerator.ts#L117 `makeExecutableSchema` API 是有 `schemaDirectives` 这个参数的。 在这篇教程中, https://github.com/apollographql/graphql-tools/blob/42c7296943e3e6bd8cf2173ef74863a196cd2e14/docs/source/schema-directives.md 是介绍 `schemaDirectives`...
我参照 `egg-graphql` 重新搞了个:[egg-graphql-apollo](https://github.com/MinJieLiu/egg-graphql-apollo) 官方的库不太能接受,问题如下: 1. `app/graphql` 下的每个业务目录都包含相同名称的文件,在编辑器打开很容易混淆,稍微不注意就写错地方。 1. `graphql-tools` 推荐 `connector` 是直连数据库的。因为 `egg` 中有 `service`,所以 `resolver.js` 可以直接调用 `service`,`connector.js` 没必要存在。 1. 官方库目前没支持 `schemaDirectives`,不能很好做鉴权。
@foreleven `type Post @isLoggedIn` 是可以的。`directiveResolvers` 最后都是合并到 `schemaDirectives` 里,因此可以直接使用`schemaDirectives` API。 https://github.com/apollographql/graphql-tools/blob/42c7296943e3e6bd8cf2173ef74863a196cd2e14/docs/source/schema-directives.md#enforcing-access-permissions
我还以为是走了 graphql 后故意让后面的中间件不执行呢😊