问题标签 [graphql-tools]

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 浏览

graphql-js - Problem when upgrading graphql-js from 14.1.1 to 14.3.0

i'm just upgrade graphql-js from version 14.1.1 to 14.3.0 and then my whole test fail

after checking my code i found that problem is at resolver on interface type that i expect third parameter was context as code below

__resolveType(obj, args, context, info) {...}

but on graphql-js version 14.3.0 i found that context is change to second position

i tried to find which commit is reference to this problem but found nothing can someone explain me how this problem happend or post a commit or changelog detail thanks

0 投票
1 回答
458 浏览

graphql - 连接 AWS Appsync Graphql Link 作为 Gatsbyjs 数据源

努力设置一个 GatsbyJS 插件,该插件使用 IAM 身份验证从 AWS AppSync 获取。我不断收到一个错误,我无法找出问题所在。

我在 graphql 链接方面没有大量经验,也找不到关于如何在这种情况下做好它的好的文档。

这是我的插件gatsby-node.js文件的样子:

这是我的错误信息:

TypeError:无法读取未定义的属性“存储”

  • client.js:147 [gatsby-source-appsync]/[aws-appsync]/lib/client.js:147:27

  • client.js:139 ApolloLink.request [gatsby-source-appsync]/[aws-appsync]/lib/client.js:139:23

  • bundle.umd.js:188 ApolloLink.request [gatsby-source-appsync]/[aws-appsync]/[apollo-link]/lib/bundle.umd.js:188:35

  • bundle.umd.js:188 ApolloLink.request [gatsby-source-appsync]/[aws-appsync]/[apollo-link]/lib/bundle.umd.js:188:35

  • bundle.umd.js:188 ApolloLink.request [gatsby-source-appsync]/[aws-appsync]/[apollo-link]/lib/bundle.umd.js:188:35

  • link.js:84 Object.execute [gatsby-source-appsync]/[apollo-link]/lib/link.js:84:18

  • linkToFetcher.js:7 [gatsby-source-appsync]/[graphql-tools]/dist/stitching/linkToFetcher.js:7:56

  • introspectSchema.js:50 [gatsby-source-appsync]/[graphql-tools]/dist/stitching/introspectSchema.js:50:42

  • introspectSchema.js:31 步骤 [gatsby-source-appsync]/[graphql-tools]/dist/stitching/introspectSchema.js:31:23

  • introspectSchema.js:12 Object.next [gatsby-source-appsync]/[graphql-tools]/dist/stitching/introspectSchema.js:12:53

  • introspectSchema.js:6 [gatsby-source-appsync]/[graphql-tools]/dist/stitching/introspectSchema.js:6:71

  • 新的承诺

  • introspectSchema.js:2 __awaiter [gatsby-source-appsync]/[graphql-tools]/dist/stitching/introspectSchema.js:2:12

  • introspectSchema.js:41 introspectSchema [gatsby-source-appsync]/[graphql-tools]/dist/stitching/introspectSchema.js:41:12

  • gatsby-node.js:60 Object.exports.sourceNodes /workspace/plugins/gatsby-source-appsync/gatsby-node.js:60:33

以前没有使用过graphql链接。有什么帮助吗?

0 投票
1 回答
6912 浏览

graphql - 合并模式后的“GraphQLError:类型中找不到字段:'query_root'”

我使用 graphql-tools 缝合了两个 graphql 端点。对于一个端点架构,它工作正常,但对于另一个架构,它会抛出此错误“GraphQLError:在类型中找不到字段:'query_root'”。即使我可以在内省时看到所有模式。

0 投票
0 回答
668 浏览

neo4j - 如何使 makeExecutableSchema 忽略指令?

有没有办法从 graphql-tools 告诉 makeExecutableSchema 忽略某些指令?

我想用 graphql 查询我的 neo4j 数据库。我还希望能够在 graphql 中指定子类型。有一个名为 graphql-s2s 的库,它向 graphql 添加了子类型。库 neo4j-graphql-js 使用自定义指令(@cyper 和 @relation)来构建增强模式。它需要 typeDefs 或来自 graphql-tools 的 executableSchema。qraphql-s2s 让我可以从包含子类型的模式中创建一个可执行模式。我希望我应该很容易像装饰器模式一样将不同的模式输出相互传递。

不幸的是,这显然不是它的工作原理,因为我收到了很多解析器错误消息,这些消息并不是真正的描述性。

不幸的是,我还没有找到任何 Grandstack 文档,其中显示了如何在其中包含关系和密码的可执行模式上使用 augmentSchema()。

有没有办法做到这一点?

下面是我天真的方法:

0 投票
1 回答
253 浏览

graphql - 处理子查询中的 graphql 模式拼接错误

我是 graphql 的新手,想在这里理解这个概念。我有这个 graphql 模式(使用图形工具缝合)。并非所有汽车都有注册。因此,如果我查询 5 辆汽车,而一辆汽车没有注册(没有 id 来链接汽车和注册),我的整个查询都会失败。

我该如何处理这个问题并为那 1 辆车返回 null 并为其他 4 辆车返回注册详细信息?

0 投票
0 回答
898 浏览

javascript - 为查询字段 Y 返回的类型 X 的对象缺少选择集

我对 GraphQL 比较陌生。我有一个这样的查询:

其中,当通过 react-apollo<Query />组件执行时,会出现错误:

网络错误:为查询字段发送者返回的资产类型对象缺少选择集

我不知道为什么这会被视为“网络错误”。

根据这个答案,“缺少选择集”是指嵌套对象内请求的字段,这很有意义,除非我在上面的查询中明确包括“资产”类型的字段。

删除sender字段,使查询看起来像这样:

将错误更改为

网络错误:为查询字段对话返回的对话类型对象缺少选择集

并从中删除字段conversation,查询运行良好(尽管{}为所有sender/ conversations 返回)。

因为conversation当我有效地跳过错误时,我认为这与联合类型sender无关。sender

我正在针对makeExectuableSchema具有以下类型的可执行模式(通过)运行此查询:

我误解了一些明显的东西吗?在这种情况下,我似乎无法解释这个错误。

编辑:

我正在使用 apollo-boost 并像这样创建一个客户端:

因为union类型需要一个IntrospectionFragmentMatcher,所以我必须自省模式来获取类型。因此,我正在创建一个这样的缓存:

有趣的是,检查模式查询的结果,我发现一切__typename都有"__Type"

0 投票
0 回答
385 浏览

graphql - Apollo delegateToSchema - 如何从父解析器发送子解析器的子查询

我在 graphql 中有使用 apollo 库构建的父模式,apollo-server并将graphql-tools子查询委托给远程 graphql 模式。

例如,下面的查询将 User.booking 的子查询委托给远程模式,并且运行良好。

我的问题是如何将 User.books 的子查询从另一个解析器(在我的情况下是他的父母解析器之一 - 库)发送到远程模式。

从 apollo 的文档中,该函数使用 info 对象来提取想要的子查询:

信息:GraphQLResolveInfo

GraphQL 解析当前解析器的信息。提供对从当前解析器开始的子查询的访问。

0 投票
2 回答
216 浏览

graphql - GraphQL 查询和对象字段之间的编程区别是什么?

有谁知道我如何以编程方式区分 graphql 查询和字段?我说的是这个:

我试图从各个方面看它,但它们几乎相同,都是类型FieldDefinition并且具有完全相同的结构。那么有没有办法做到这一点?我正在尝试编写一个适用于两者并且非常相似的身份验证模式指令,但是如果将指令应用于查询,它应该做不同的事情。

如果一切都失败了,我可以创建两个单独的指令,但是如果可以重用相同的指令并且它的使用者不必担心它被应用到哪里,它就可以工作了。

0 投票
6 回答
3104 浏览

graphql - `Cannot use e "__Schema" from another module or realm.` 和 `使用 ApolloClient 复制 "graphql" 模块

我有一个带有 ApolloClient 和 Apollo-Link-Schema 的 React 应用程序。该应用程序在本地运行良好,但在我们的暂存环境(使用 GOCD)中,我们收到以下错误:

依赖项是用 yarn 安装的,我已将该resolutions字段添加到 package.json。

我检查了 yarn.lock 并且只能找到 graphql 包的一个参考。 npm ls graphql不显示任何重复项。

我认为这可能是 webpack 的构建问题 - 我有一个不同的构建脚本用于暂存,但是在本地运行它我仍然能够让 react 应用程序与该包一起运行。

任何人都可以提出其他建议来帮助我解决这个问题吗?

0 投票
1 回答
817 浏览

graphql - 如何在自定义指令上触发 visitInputObject 方法?

我正在构建一个自定义指令,希望在其中验证整个输入对象。我在扩展类上使用INPUT_OBJECT带有visitInputObject方法的类型。SchemaDirectiveVisitor

每次我使用输入类型运行突变时visitInputObject都不会运行。我已经使用了其他类型/方法,例如visitObjectandvisitFieldDefinition并且它们工作得很好。但是当尝试使用输入类型和方法时,它们不会触发。

我已经阅读了我能找到的所有可用文档。这还不支持吗?

一些上下文代码(不是实际的):

directive @validateThis on INPUT_OBJECT