Commit 196fed9
authored
Cosmos DB: Adds circular reference check for entities in graphQL schema (#2192)
## Why make this change?
Today, if graphQL schema has circular reference of entities, DAB won't
be able to load the schema and die with stackoverflow exception when it
tries to traverse the schema.
With JSON data, it can get very complicated to handle all the scenarios
with circular reference.
## What is this change?
Adding a proper exception during the load, if DAB identifies that schema
has circular reference.
If schema is found with circular reference, DAB will throw below
exception.
**DAB Exception**
``` c#
DataApiBuilderException(
message: $"Circular reference detected in the schema for entity '{entityType}'.",
statusCode: System.Net.HttpStatusCode.InternalServerError,
subStatusCode: DataApiBuilderException.SubStatusCodes.ErrorInInitialization);
```
**Schema with circular reference**
```gql
type Character {
id : ID,
name : String,
moons: [Moon], // Character has Moon Reference
}
type Planet @model(name:""Planet"") {
id : ID!,
name : String,
character: Character
}
type Moon {
id : ID,
name : String,
details : String,
character: Character // Moon has Character Reference
}
```
## How was this tested?
- [x] Integration Tests
- [x] Unit Tests1 parent db235d0 commit 196fed9
File tree
2 files changed
+113
-13
lines changed- src
- Core/Services/MetadataProviders
- Service.Tests/Configuration
2 files changed
+113
-13
lines changedLines changed: 36 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
198 | | - | |
| 203 | + | |
| 204 | + | |
199 | 205 | | |
200 | 206 | | |
201 | 207 | | |
202 | 208 | | |
203 | | - | |
204 | | - | |
205 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
206 | 218 | | |
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
210 | 232 | | |
211 | 233 | | |
212 | 234 | | |
| |||
235 | 257 | | |
236 | 258 | | |
237 | 259 | | |
238 | | - | |
| 260 | + | |
239 | 261 | | |
240 | 262 | | |
241 | 263 | | |
242 | | - | |
| 264 | + | |
243 | 265 | | |
244 | 266 | | |
245 | 267 | | |
246 | | - | |
| 268 | + | |
247 | 269 | | |
248 | 270 | | |
249 | 271 | | |
| |||
253 | 275 | | |
254 | 276 | | |
255 | 277 | | |
256 | | - | |
| 278 | + | |
| 279 | + | |
257 | 280 | | |
258 | 281 | | |
259 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
428 | 470 | | |
429 | 471 | | |
430 | 472 | | |
| |||
2938 | 2980 | | |
2939 | 2981 | | |
2940 | 2982 | | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
2941 | 3018 | | |
2942 | 3019 | | |
2943 | 3020 | | |
| |||
0 commit comments