Azure / Azure/data-api-builder
GraphQL relationships can cause a stack overflow exception
- Vorherrschende Sprache
- C#
- Sterne
- 1.5k
- Forks
- 370
- Ø Merge
- 3 T. 22 Std.
- Gemergte PRs (30 T.)
- 9
Beschreibung
Due to the type walking within our schema builder, it's possible to create a GraphQL schema that will result in a stack overflow exception.
Here's an example of a schema that causes the problem:
```graphql
interface Node {
id: ID!
}
enum GameState {
WaitingForPlayers
Started
Completed
}
type Question implements Node @model {
id: ID!
question: String!
correctAnswer: String!
answers: [String!]!
}
type Player implements Node @model {
id: ID!
name: String!
game(gameId: ID!): Game!
games: [Game!]!
}
type Game implements Node @model {
id: ID!
state: GameState
players: [Player!]!
questions: [Question!]!
}
```
The head of the stack is here:
```
at Azure.DataApiBuilder.Service.GraphQLBuilder.GraphQLUtils.IsBuiltInType(HotChocolate.Language.ITypeNode)
at Azure.DataApiBuilder.Service.GraphQLBuilder.Mutations.CreateMutationBuilder.FieldAllowedOnCreateInput(HotChocolate.Language.FieldDefinitionNode, Azure.DataApiBuilder.Config.DatabaseType, System.Collections.Generic.IEnumerable`1)
```
But the full exception message is over 10k lines long.
I'm not sure what the state of relationships are in Cosmos, but this is realistic GraphQL schema (and the one I use for the demos I generally do).
My guess is that it doesn't like that `Player` references `Game` which references `Player` which references `Game` which...
Beitragsleitfaden
Rechercherichtung
Reproduziere den Stack Overflow mit dem GraphQL-Schema aus dem Issue und untersuche GraphQLUtils.IsBuiltInType und Mutations.FieldAllowedOnCreateInput, die im Stack Trace identifiziert wurden. Verfolge, wie die Player–Game-Beziehung wiederholt durchlaufen wird, und stelle eine begrenzte Traversierung her; als erledigt gilt die Aufgabe, wenn dieses Schema ohne Stack Overflow erstellt wird und das bestehende Mutationsverhalten intakt bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, graphql
- Bereich
- api, backend-api-design
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100