飞机什么时候停止登机| 梳子什么材质的好| 送朋友什么礼物好| 肺大泡是什么原因造成的| 私房菜是什么意思| 天麻不能和什么一起吃| 不什么为什么| 走路气喘是什么原因| 左眼皮一直跳是什么预兆| 突然的反义词是什么| 标准员是干什么的| hbc是什么意思| 汝等是什么意思| 梦见金项链是什么意思| 是什么符号| 承欢膝下是什么意思| 软组织挫伤是什么意思| 装腔作势什么意思| 皮肤黑穿什么颜色的衣服| 男生说gg是什么意思| 阴囊潮湿是什么原因| 西藏有什么大学| 晕车药叫什么名字| 委曲求全是什么生肖| 皮肤长斑是什么原因引起的| 银壶一般什么价位| 美国为什么支持以色列| 甲方是什么意思| 父亲b型血母亲o型血孩子什么血型| 什么的松树| 热泪盈眶的盈是什么意思| 什么店可以买到老鼠药| 口红是用什么做的| 蛐蛐吃什么食物| 洋葱与什么食物相克| 宝宝拉肚子能吃什么| 拉红尿是什么原因| 查验是什么意思| 胃寒吃什么食物好| 书生是什么生肖| 吃什么东西去湿气| mup是什么意思| 稻谷是什么| 无花果和什么不能一起吃| 什么是指标生| 办理社保卡需要什么资料| 沅字的寓意是什么| 为什么腋下会长小肉揪| 受精卵着床有什么反应| 出国用什么翻译软件好| 工口是什么意思| 站台是什么意思| 前白蛋白高是什么意思| 邮箱地址填什么| 疾苦的疾是什么意思| 化疗前吃什么补充营养| 甲亢不能吃什么| 唔该是什么意思| 巾失念什么| 一直咳嗽不好是什么原因| 李白被人们称为什么| 什么是横纹肌溶解| 居士是什么意思| 凌晨一点是什么时辰| 腿疼膝盖疼是什么原因| 君子菜是什么蔬菜| 八月十日是什么星座| 景深是什么意思| 口干口苦吃什么药最好| 喝茶叶水有什么好处和坏处| 血压和血糖有什么关系| 荧光色是什么颜色| 孵化基地是什么意思| 嗳气打嗝吃什么药| 化疗中的病人应该吃什么| 小腿肚酸胀是什么原因| 急性肠胃炎能吃什么水果| 人湿气重有什么症状| 乳清是什么| 晚上八点到九点是什么时辰| yy什么意思| 1973属什么生肖| 南瓜炒什么好吃| 吃了桃子不能吃什么| 多五行属性是什么| 1986年虎是什么命| 泥鳅吃什么| 指甲白色是什么原因| 梦见钱包丢了是什么意思| 绊倒是什么意思| 霉菌用什么药| 胃不好吃什么蔬菜| 发烧喝什么汤| 金牛座和什么座最配| 肾造瘘是什么意思| 狗不理是什么意思| 什么是抗原| 男人阳萎吃什么药最好| 耳朵有回音是什么原因| 陀飞轮是什么意思| 妈妈的爷爷叫什么| 农历五月二十八是什么日子| 阴唇长什么样| 血管痉挛吃什么药| 黑色的裤子配什么颜色的上衣| 什么是九宫格| 吃避孕药对身体有什么影响| 电压是什么意思| 斗志昂扬是什么意思| 中国最毒的蛇是什么蛇| 黑科技是什么| 室早三联律是什么意思| iu是什么单位| 目赤什么意思| 雷人是什么意思啊| 导管子是什么意思| 做肌电图挂什么科| 养胃吃什么水果| 什么是对食| 最近发胖过快什么原因| 今天属什么生肖日历| 什么面朝天| 入伏吃羊肉有什么好处| 什么治胃胀气| 愿君多采撷是什么意思| 脱口秀是什么意思| legrand是什么牌子| 什么是免疫治疗| 龙女是什么意思| 梦见自己丢钱了什么征兆| 藕什么季节成熟| 父亲节送爸爸什么礼物| 心窦过缓是什么原因| 家里有壁虎是什么征兆| 什么地看| d二聚体偏高说明什么| 什么动物三只爪| 急性阑尾炎什么症状| 为什么飞机起飞降落要打开遮光板| 京东京豆有什么用| 血压低吃什么能补上来| 脸上爱出油是什么原因| 灵柩是什么意思| 为什么夏天越来越热| 耳堵耳闷是什么原因| 什么的乌鸦| 姜薯是什么| 世界上最小的长度单位是什么| 卵巢囊肿是什么原因引起的| 角瓜念什么| 股票尾盘拉升说明什么| urea是什么意思| 西京医院什么科室最强| 嗓子发炎挂什么科| 未免是什么意思| 做流产手术需要准备什么东西| beyond什么意思| 小壁虎进家有什么预兆| le是什么元素| 杨琴是什么乐器| 在什么后面| 刮痧出痧说明什么| 蔓越莓有什么功效| 带状疱疹后遗神经痛挂什么科| 鸡婆什么意思| 孕妇吃什么是补铁的| 夹生是什么意思| 梦见杀蛇是什么意思| 脑死亡是什么原因引起的| 为什么一热就头疼| 适得其反什么意思| choker什么意思| 吃槟榔有什么好处| 眩晕看什么科| 蚂蚁喜欢吃什么食物| na是什么| 考试穿什么颜色的衣服| 96年五行属什么| 看头发挂什么科| 鸡飞狗跳是指什么生肖| 夏天有什么花| 费心是什么意思| 生理反应是什么意思| 胃不好不能吃什么| 97年五行属什么| 胰腺在人体什么部位| 风月什么意思| 和尚化缘的碗叫什么| 八段锦是什么| 陈宝莲为什么自杀| 胆红素高是什么意思| 鸡蛋白过敏指的是什么| 毛戈平属于什么档次| 糟老头是什么意思| 做完无痛人流需要注意什么| 番石榴什么时候成熟| 单独是什么意思| bra是什么| 什么目寸光成语| 肩膀痛应该挂什么科| 波尔多红是什么颜色| 胃寒湿气重吃什么药效果最好| 什么钱最不值钱| 小猫喜欢什么颜色| 云南雪燕有什么作用| dha每天什么时候吃最好| 阿托品是什么药| 硬不起来吃什么好| 核磁共振挂什么科| 什么的枣| 男人吃鸽子有什么好处| joyroom是什么牌子| 枸杞泡茶喝有什么功效| 角是什么生肖| 辰时是什么时候| 阴道口疼是什么原因| 为什么早上起来恶心想吐| 75b是什么罩杯| 室内传导阻滞什么意思| 囊肿是什么病严重吗| 农历今天什么日子| 外痔疮是什么样子图片| DNA是什么意思啊| 内分泌失调吃什么药好| 一个女一个以念什么| 唇珠是什么| 骨折恢复期吃什么好| 停诊是什么意思| 来月经为什么会拉肚子| 肺在什么位置图片| 望尘莫及的及是什么意思| 杭州有什么好玩的地方| 疱疹吃什么药见效快| 麦霸什么意思| 不以规矩下一句是什么| 指甲黑是什么原因| 牛肚是牛的什么部位| 站着说话不腰疼什么意思| 白血病有什么征兆| 关节痛挂号挂什么科| 食色性也什么意思| 9.25是什么星座| 胃幽门螺旋杆菌吃什么药| RH阳性什么意思| 小分子肽能治什么病| 阴道炎用什么药效果好| 今年65岁属什么生肖| 满身红点是什么病| 为什么明星都不戴黄金| 醪糟是什么东西| 梦见建房子是什么预兆| 血糖高吃什么水果好能降糖| 植物功能紊乱吃什么药| 睡觉憋气是什么原因引起的| 浠字五行属什么| 脾虚胃热吃什么中成药| 公主抱是什么意思| 女性气血不足吃什么调理| 人均gdp是什么意思| 冷冻和冷藏有什么区别| 忻字五行属什么| 参乌健脑胶囊适合什么人吃| 活死人是什么意思| 酱油是什么做的| 百度

从每一分钟内要高效 影视后期业对PC的特立刚需

百度 据悉,目前,北斗七星已经接入近30家银行,其中零售信贷平台模块已有江苏银行、南京银行、包商银行等机构入驻,上线以来平台交易规模保持195%的月复合增长率,为合作银行零售信贷用户量带来近300%的增长。

Unit, integration, end-to-end, composition, and component and operation testing


tip
If you're an enterprise customer looking for more material on this topic, try the Enterprise best practices: Testing course on Odyssey.Not an enterprise customer? Learn about GraphOS for Enterprise.

Testing in GraphQL may seem like it can involve more steps, but that is because your GraphQL architecture can involve many areas of your tech stack, from your frontend with Apollo Client to a backend with Apollo Server, or your infrastructure with your GraphOS Router to the individual subgraphs in your supergraph. In practice, all these areas should be properly tested the same way if you were using any other API technology, but often the testing across boundaries like teams or applications can involve some new steps. By the end of this guide you should have:

Unit testing

Apollo recommends creating unit tests for each of your subgraph server resolvers. Resolvers are the code that gets called for each type or field in your schema, which creates a natural boundary to test in isolation. When doing so, Apollo recommends mocking as much data as possible using a package like @faker-js/faker. This package generates realistic fake data for mocking inputs and outputs.

Using @faker-js/faker to mock a return value in jest looks something like the following:

JavaScript
1import {faker} from '@faker-js/faker';
2
3const testUser = {
4  userId: faker.datatype.uuid(),
5  username: faker.internet.userName(),
6  email: faker.internet.email(),
7  avatar: faker.image.avatar(),
8  password: faker.internet.password(),
9  birthdate: faker.date.birthdate(),
10  registeredAt: faker.date.past()
11};
12
13const mockedFunction = jest.fn().mockReturnValue(testUser);

Simplify unit testing with thin resolvers

To enable easier unit testing, Apollo recommends that you keep your resolvers as "thin" as possible, where the logic to retrieve data is separate from the resolver. This separation of concerns allows you to mock the data retrieval logic and more easily unit test the data retrieval process instead of the invocation of the resolver, as mocking a resolver requires a more complex setup.

An example of a thin resolver might look like:

JavaScript
1const resolvers = {
2  Query: {
3    user: async (_, {id}, {dataSources}) => {
4      return dataSources.userAPI.getUserById(id);
5    }
6  }
7};

Reference resolvers in unit tests

The __resolveReference function (also known as a reference resolver) enables different subgraphs to resolve the fields of a federated entity. Reference resolvers are vital to the successful execution of federated operations, so they are important to validate.

Following the advice above, Apollo recommends making these resolvers as thin as possible, and to mock the data retrieval logic in your unit tests.

Integration testing

Integration tests for subgraphs should start up a single subgraph and send operations to the schema in a mocked or test environment. To test just the subgraph in isolation, validate all the fields giving special focus to the top-level fields in your queries and mutations, and use all permutations of your inputs to check your schema matches your resolvers.

For more information on integration testing with Apollo Server, see the Apollo Server testing guide.

Entity resolvers in integration tests

Depending on your schema and operations, the resulting query plan may fetch data from a subgraph using the entity resolvers. The integration tests in this situation involves mimicking the router. You can execute an _entities query during integration tests and your test cases should cover all the entity types that can be resolved by the individual subgraph (all the types marked with @key).

This looks like the following:

GraphQL
1query GetEntities($representations: [_Any!]!) {
2  _entities(representations: $representations) {
3    ... on User {
4      firstName
5    }
6  }
7}

with the following input:

JSON
1{
2  "representations": [
3    {
4      "__typename": "User",
5      "id": "5"
6    }
7  ]
8}

For types with multiple keys, or compound keys, ensure you test all permutations of the keys.

To see more examples on how to run these operations, see Query._entities, and if you would like to generate a list of _entities queries from known operations, see this tool from the Apollo Solutions organization to do so.

End-to-end testing

Follow these best practices when creating end-to-end tests for your supergraph:

  • Run all your subgraphs and router in a test environment with either mocked or test data

  • Use example operations that are actually executed against your supergraph.

    • You can view the details of recent operations in GraphOS Studio.

    • Avoid boilerplate or randomly generated operations, as these don't reflect actual traffic.

    • If you are not in production yet, Apollo suggests making these tests as close to what you think they will be as possible.

    • Make sure to include operation that span multiple subgraphs to validate entity resolvers

  • Use variables to ensure high operation cardinality.

    • If your test operations don't use any GraphQL variables (or if you use the same variable values across executions), your supergraph is likely to return cached data. This circumvents large portions of execution logic, limiting test effectiveness.

    • By using a variety of operations and variable values, you help make sure that your tests result in minimal cache hits.

Composition testing

Composition testing is specific to a federated architecture. It involves testing that your subgraph schemas successfully compose into a supergraph schema that can resolve the operations sent by clients. You perform these tests with the Rover CLI, via the rover subgraph check command. Apollo recommends performing this check in your CI pipeline as part of code-reviews and in your CD pipeline to confirm the changes you are about to deploy are still valid since the last time you ran the check.

Component and operation testing

Fortunately, clients are not actually aware of when they are using a Federated GraphQL API versus a non-Federated one so the testing best practices remain the same. Our schema can provide a convenient layer to mock our data fetching, or for individual components you can mock the specific client providers that inject or fetch your GraphQL data:

凌乱是什么意思 寄生树有什么功效作用 乙亥五行属什么 嘴角上方有痣代表什么 光是什么意思
口干舌燥吃什么药最好 车牌字体是什么字体 什么是鸡胸 女人右眼跳是什么意思 cl是什么元素
王姓为什么出不了皇帝 音乐制作人是干什么的 前庭是什么意思 高考450分能上什么学校 单核细胞偏高是什么意思
秋天喝什么粥好 肾结晶是什么意思 压车是什么意思 宗是什么意思 杰五行属性是什么
吃桃胶有什么作用520myf.com 高危hpv有什么症状hcv8jop9ns9r.cn 柜子是什么意思hcv8jop2ns0r.cn zgo手表是什么牌子hcv8jop6ns6r.cn 什么水果含维生素c最多hcv8jop1ns6r.cn
阴道流黄色分泌物是什么原因weuuu.com 玉米属于什么类96micro.com 芒种可以种什么菜hlguo.com 膝盖发软无力是什么原因hcv8jop3ns3r.cn rma是什么意思hcv9jop6ns1r.cn
什么人不能吃猪肝hcv9jop8ns1r.cn 羊猄皮是什么皮hcv9jop2ns7r.cn 周杰伦什么星座hcv9jop1ns1r.cn 爱是什么hcv9jop2ns6r.cn 阳性血是什么意思hcv9jop5ns9r.cn
狐臭什么味hcv9jop7ns1r.cn 什么水果泡酒最好喝hcv8jop8ns3r.cn 孩子肠胃炎吃什么药hanqikai.com 难舍难分是什么意思hcv8jop6ns8r.cn 美美哒什么意思hcv7jop5ns0r.cn
百度