问题标签 [graphql-shield]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
24 浏览

node.js - Nodejs:graphql-shield 单元测试规则

您如何看待 graphql-shield 规则的单元测试?下面是一个规则示例:

我目前在javascript中这样测试:

这种方法的问题在于 .func 是私有属性。所以对于使用打字稿的测试:

  1. 使用 //ts-忽略
  2. 从函数中的规则导出逻辑,例如authenticatedRuleLogic,但是我们最终导出函数只是为了测试,更不用说重复的函数了

也许还有另一种选择被忽略?

0 投票
2 回答
195 浏览

node.js - Apollo 服务器联盟与 graphql-shield

graphql-shield用来保护一个subgraph.

在我的构建过程中,我rover CLI用来更新supergraph schemaApollo Studio 中的:

更新失败,rover因为权限屏蔽引发Not Authorised!错误。

我如何保护subgraphgraphql-shield允许SubgraphIntrospectQuery操作?

我了解可以将承载令牌添加到流动站自省命令:

但是,我无法在构建过程中生成访问令牌。

0 投票
0 回答
33 浏览

graphql - Graphql-Shield 劫持错误

在解析器中,throw new createError.BadRequest("bad input")错误被劫持Graphql-shield并显示为

这是 Apollo 服务器设置

如何返回发生的实际错误?

0 投票
1 回答
32 浏览

node.js - Use Rover with graphql-shield

I'm using graphql-shield on a subgraph and rover-cli to generate the schema.

I've set the fallback rule to deny everything as I don't want anything to be accessible by default. But now rover-cli fails when introspecting the subgraph. I'm aware that you can pass a token to rover but I'm unable to do so during my build process.

I've already looked at this issue: Apollo Server Federation with graphql-shield and on both graphql-shield & rover GitHub repository but not luck so far.

I've also tried to explicitly add SubgraphIntrospectQuery like so:

Thanks for your help!