Commit 5db8c5a
authored
feat: allow empty arguments for field resolvers (#1350)
# Introduction
This PR introduces support to call field resolvers without any
arguments. Currently we only check if field resolvers provide arguments
with parentheses.
Field resolvers were determined whether fields have arguments. This is
technically correct but instead of checking field arguments on the
operation side, they have to be determined from the schema definition.
## Prerequisites
The following problem statement refer to this example schema
```graphql
type Query {
categories: [Category!]!
}
type Category {
id: ID!
# The argument is nullable and can be omitted
relevantTopic(orderBy: String): Topic!
}
type Topic {
id: ID!
description: String!
}
```
## Problem Statement
This will correctly call the field resolver
```graphql
query {
categories {
id
relevantTopic("") {
id
description
}
}
}
```
This did not call the field resolver
```graphql
query {
categories {
id
relevantTopic {
id
description
}
}
}
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Enhanced error handling and validation for field resolution
* Improved support for optional arguments in field resolvers
* Better error messages when field definitions cannot be resolved
* **Tests**
* Expanded test coverage for field resolver edge cases
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Checklist
- [ ] I have discussed my proposed changes in an issue and have received
approval to proceed.
- [ ] I have followed the coding standards of the project.
- [ ] Tests or benchmarks have been added or updated.
<!--
Please add any additional information or context regarding your changes
here.
-->1 parent 701ea8d commit 5db8c5a
File tree
5 files changed
+204
-35
lines changed- v2/pkg/engine/datasource/grpc_datasource
5 files changed
+204
-35
lines changedLines changed: 37 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
779 | 779 | | |
780 | 780 | | |
781 | 781 | | |
782 | | - | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
783 | 788 | | |
784 | 789 | | |
785 | 790 | | |
786 | | - | |
| 791 | + | |
787 | 792 | | |
788 | 793 | | |
789 | 794 | | |
| |||
853 | 858 | | |
854 | 859 | | |
855 | 860 | | |
856 | | - | |
857 | | - | |
| 861 | + | |
| 862 | + | |
858 | 863 | | |
859 | 864 | | |
860 | 865 | | |
861 | | - | |
| 866 | + | |
862 | 867 | | |
863 | 868 | | |
864 | 869 | | |
| |||
1097 | 1102 | | |
1098 | 1103 | | |
1099 | 1104 | | |
1100 | | - | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
1101 | 1111 | | |
1102 | 1112 | | |
1103 | 1113 | | |
1104 | 1114 | | |
1105 | 1115 | | |
1106 | 1116 | | |
1107 | 1117 | | |
1108 | | - | |
| 1118 | + | |
1109 | 1119 | | |
1110 | 1120 | | |
1111 | 1121 | | |
| |||
1117 | 1127 | | |
1118 | 1128 | | |
1119 | 1129 | | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
| 1130 | + | |
| 1131 | + | |
1128 | 1132 | | |
1129 | 1133 | | |
1130 | 1134 | | |
1131 | 1135 | | |
1132 | 1136 | | |
1133 | 1137 | | |
1134 | | - | |
| 1138 | + | |
1135 | 1139 | | |
1136 | | - | |
| 1140 | + | |
1137 | 1141 | | |
1138 | 1142 | | |
1139 | 1143 | | |
| |||
1154 | 1158 | | |
1155 | 1159 | | |
1156 | 1160 | | |
1157 | | - | |
1158 | | - | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
1159 | 1164 | | |
1160 | 1165 | | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
| 1166 | + | |
| 1167 | + | |
1164 | 1168 | | |
1165 | 1169 | | |
1166 | | - | |
| 1170 | + | |
1167 | 1171 | | |
1168 | 1172 | | |
1169 | 1173 | | |
1170 | 1174 | | |
1171 | 1175 | | |
1172 | | - | |
| 1176 | + | |
1173 | 1177 | | |
1174 | 1178 | | |
1175 | 1179 | | |
| |||
1256 | 1260 | | |
1257 | 1261 | | |
1258 | 1262 | | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1262 | 1267 | | |
1263 | | - | |
1264 | | - | |
1265 | | - | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1266 | 1271 | | |
1267 | | - | |
| 1272 | + | |
| 1273 | + | |
1268 | 1274 | | |
1269 | 1275 | | |
1270 | 1276 | | |
| |||
Lines changed: 120 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2618 | 2618 | | |
2619 | 2619 | | |
2620 | 2620 | | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
2621 | 2729 | | |
2622 | 2730 | | |
2623 | 2731 | | |
| |||
2651 | 2759 | | |
2652 | 2760 | | |
2653 | 2761 | | |
| 2762 | + | |
2654 | 2763 | | |
2655 | 2764 | | |
2656 | 2765 | | |
| |||
2727 | 2836 | | |
2728 | 2837 | | |
2729 | 2838 | | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
2730 | 2850 | | |
2731 | 2851 | | |
2732 | 2852 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
422 | 430 | | |
423 | 431 | | |
424 | 432 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
| 334 | + | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
391 | 399 | | |
392 | 400 | | |
393 | 401 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4539 | 4539 | | |
4540 | 4540 | | |
4541 | 4541 | | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
| 4565 | + | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
4542 | 4569 | | |
4543 | 4570 | | |
4544 | 4571 | | |
| |||
0 commit comments