问题标签 [express-graphql]
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.
node.js - NodeJs GraphQL 枚举类型值作为动态
https://launchpad.graphql.com/9qvqz3v5r
这是我的示例 graphQL Schema。我正在尝试使用枚举类型。我如何从后端获取枚举值并将其提供给架构?
我想将动态变量中的枚举角色值填充为
谁能帮我?
node.js - NodeJs GraphQL 动态查询变量
https://launchpad.graphql.com/9qvqz3v5r
这是我的graphQL示例
如果我将 userId:2 作为静态传递
我将得到如下输出
我需要使用动态查询变量的相同输出
但我是 getter 错误:变量 \"$userId\" 不能是非输入类型 \"User http://prntscr.com/h2ojor
谁能帮我?
graphql - Graphql 嵌套查询非常慢
当我们的项目基于 REST 时,响应时间为 200 ms ~ 当项目更改为 GraphQL 时。
由于每个节点都在尝试解析,并且在解析之后,它们的子实体也在解析。导致极高的延迟,响应时间为 - 11 秒!
我所做的是尝试提取所有需要的信息,包括所有子实体,并从查询解析器中解析这个巨大的对象。
响应时间减少到 800 毫秒。
但是,子实体的解析器仍在发生!(我不得不为这个测试关闭它们)。在某些情况下如何关闭它们?
有没有其他方法可以解决这个问题?
graphql - 使用 graphql 查询连接 3 个表
我想加入 3 个表,就像我们在 mysql 中基于主键和外键一样。
我可以使用graphql(http://graphql.org/)这样做吗?我的表结构和graphql查询如下。谢谢
javascript - graphql-JS Express 无法解析字段
当我在节点服务器中执行以下代码时。我看到 graphql-JS 无法解析字段“product.productTax”的错误。
使用 graphql-express,visual studio 代码,我试图完全模仿来自http://graphql.org/graphql-js/object-types/的以下代码
node.js - babel-node vs node:带有导入/导出的graphql文件
似乎 NodeJS 不理解 graphql 文件(扩展名 .gql)中的导入/导出命令,但 babel-node 可以。我能想出的唯一解决方法是将 .gql 文件重命名为 .js 文件,但我失去了语法突出显示。
是否有一个简单的修复方法可以在非 js 扩展文件中实现节点荣誉导入/导出?附上我的package.json; npm run dev
有效,但npm run build; npm run start
不:
}
javascript - 多对多 graphql 架构错误
我是 GrpahQL 的新手,我正在尝试模拟用户和组之间的多对多关系。我的架构中定义了以下类型:
这是另一个文件:
这个例子对我不起作用,因为由于某种原因我得到了这个错误:
错误:只能创建 GraphQLType 的列表,但得到:[object Object]。
此错误仅发生在 GroupType 而不是 UserType 当两者相似时。这里发生了什么?我究竟做错了什么?
node.js - 记录中对象的_id 在更新同一对象的数据时发生变化
我有一个对象数组。每个对象都保存活动类型。我需要更新数组的对象之一。我使用 _id 来更新或删除对象。因此,当我传递 id 来更新数据时,我实际上是在数组中找到该对象的索引,并将该索引上的数据替换为新数据。
这里的问题是我的 _id 也发生了变化,因为我没有使用 $set 或没有使用查询直接更新。我正在使用 map 函数更改数据并将其保存到 mongoDB 游标中,该游标稍后会在某个地方得到更新。
下面是代码和代码的输出。
上述代码的输出如下所示。 这是输出的图像。
所以,我更改了活动类型的名称。最初它的 id 是5a15438482900b2aa6dc7ab1然后它转换为5a15498cb024a02b4628e33f。 如何防止每次更新时数据库中 _id 的这种更改?
javascript - GraphQL resolver middleware for auth check
I have a GraphQL API with mixed public and private queries and mutation. I'm looking for a way to check whether an operation requires the user to be authenticated and also a permission checker, so that the user can only modify his own data.
I noticed that the resolver function has a fourth argument, info
that includes path.key
which returns the name of the operation (documented here).
My solution was to add a checker function inside every resolver, like so:
And in another file:
The function either returns true or throws an error if conditions are not met.
I was wondering if this was an ok solution or if there was a way that this could be done with a middleware somehow so that I wouldn't have to repeat the code in every resolver. The problem is that I wouldn't have access to the operation name if I'd use a middleware. Any suggestions?
node.js - Express中的graphql错误,节点js
我正在尝试以 express 运行 graphql 服务器。但它会引发以下错误。