Graphql很棒,我已经开始在我的应用程序中使用它了.我有一个显示摘要信息的页面,我需要graphql来返回聚合计数?可以这样做吗?
在性能,开发人员可用性,社区等方面,GraphQL和OData是否有很好的比较.我在互联网上找到的所有文章都非常偏向.
返回大型JSON或二进制数据的最佳方法是什么?
我正在这里进行基本的端到端测试,目前它失败了,但首先我无法摆脱打开的手柄。
\nRan all test suites.\n\nJest has detected the following 1 open handle potentially keeping Jest from exiting:\n\n \xe2\x97\x8f TCPSERVERWRAP\n\n 40 | }\n 41 | return request(app.getHttpServer())\n > 42 | .post('/graphql')\n | ^\n 43 | .send(mutation)\n 44 | .expect(HttpStatus.OK)\n 45 | .expect((response) => {\n\n at Test.Object.<anonymous>.Test.serverAddress (../node_modules/supertest/lib/test.js:61:33)\n at new Test (../node_modules/supertest/lib/test.js:38:12)\n at Object.obj.<computed> [as post] (../node_modules/supertest/index.js:27:14)\n at Object.<anonymous> (app.e2e-spec.ts:42:8)\n
Run Code Online (Sandbox Code Playgroud)\nimport { Test, TestingModule } from '@nestjs/testing'\nimport { HttpStatus, INestApplication } from "@nestjs/common";\nimport * as request from 'supertest'\nimport { AppModule …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从Redux Store迁移以使用Apollo Graphql 客户端附带的Apollo 客户端缓存。
将 Apollo Client 与其他数据管理解决方案区分开来的关键特性之一是其规范化缓存。只需设置 Apollo Client,您就可以获得开箱即用的智能缓存,无需额外配置。
使用 Redux,我们必须根据从副作用接收到的响应来编写动作、类型和分派动作,并使用 reducer 设置存储中的数据,这由 Apollo Client 自动完成。
问题:
1) 从 Redux 迁移到 Apollo Client Cache 有什么优势?
2) 在迁移到 Apollo Client Cache 之前,我应该担心什么吗?
我有一个客户端-服务器设置,其中客户端(create-react-app)在 localhost:3000 上运行,服务器是一个构建在节点上的快速服务器,我正在尝试构建 graphql 模式解析器设置。
我可以在服务器上导入 .graphql 文件,但是,在客户端,我通过graphql-tools使用此设置。
当我尝试在前端构建架构解析器时,我正在导入
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
import { addResolversToSchema } from '@graphql-tools/schema';
import { loadSchema } from '@graphql-tools/load';
Run Code Online (Sandbox Code Playgroud)
...这会导致此错误:
./node_modules/@graphql-tools/graphql-file-loader/index.mjs 无法从非 EcmaScript 模块导入命名导出“AggregateError”(仅提供默认导出)
经过研究,我发现这是与webpack相关的问题。
这个问题有解决办法吗?
我正在使用Jest测试我的GraphQL api.
我正在为每个查询/突变使用单独的测试套装
我有2次测试(每一个在一个单独的测试套),其中我嘲笑一个函数(即,流星的callMethod
),其在突变使用.
it('should throw error if email not found', async () => {
callMethod
.mockReturnValue(new Error('User not found [403]'))
.mockName('callMethod');
const query = FORGOT_PASSWORD_MUTATION;
const params = { email: 'user@example.com' };
const result = await simulateQuery({ query, params });
console.log(result);
// test logic
expect(callMethod).toBeCalledWith({}, 'forgotPassword', {
email: 'user@example.com',
});
// test resolvers
});
Run Code Online (Sandbox Code Playgroud)
当console.log(result)
我得到
{ data: { forgotPassword: true } }
Run Code Online (Sandbox Code Playgroud)
这种行为不是我想要的,因为在.mockReturnValue
我抛出一个错误,因此期望result
有一个错误对象
然而,在此测试之前,另一个是运行
it('should throw an error if wrong credentials …
Run Code Online (Sandbox Code Playgroud) 目前尚不清楚何时使用GraphQLID
而不是GraphQLInt
.
请考虑以下架构:
type User {
id: Int!
firstName: String!
lastName: String!
}
type Query {
user (id: ID!): User
}
Run Code Online (Sandbox Code Playgroud)
如果是Query.user
,使用GraphQLID
或似乎没有区别GraphQLInt
.
在这种情况下User.id
,使用GraphQLID
将输入转换为字符串.使用GraphQLInt
将确保输入是整数.
这使得查询和类型系统不一致.
该graphql-JS 规范只是说:
GraphQLScalarType
代表ID的A.
这是一个实现细节(例如,GraphQLID
当GraphQL客户端可以转换为整数时),还是期望它ID
始终是graphql中的字符串?
如何在类似于SQL like
运算符的庄园中使用GraphQL进行查询?
示例:哪些用户的名字以jason
?开头?
select * from users where first_name like "jason%"
是否可以使用GraphQL输入类型的继承?
类似的东西(当然,这不适用于输入类型):
interface UserInputInterface {
firstName: String
lastName: String
}
input UserInput implements UserInputInterface {
password: String!
}
input UserChangesInput implements UserInputInterface {
id: ID!
password: String
}
Run Code Online (Sandbox Code Playgroud) 我正在学习graphql
并prisma-binding
用于graphql操作。我在nodemon
启动节点服务器时遇到了此错误,它为我提供了模式文件的路径,该文件由a自动生成graphql-cli
。谁能告诉我这个错误是什么意思?
错误:
Internal watch failed: ENOSPC: System limit for number of file watchers reached, watch '/media/rehan-sattar/Development/All projects/GrpahQl/graph-ql-course/graphql-prisma/src/generated
Run Code Online (Sandbox Code Playgroud)
谢谢大家!!
graphql ×10
jestjs ×2
node.js ×2
reactjs ×2
express ×1
graphql-js ×1
javascript ×1
meteor ×1
nestjs ×1
nodemon ×1
odata ×1
redux ×1
supertest ×1
typescript ×1