ChilliCream / ChilliCream/graphql-platform
Generating predictable model classes in strawberry shake
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Product
Strawberry Shake
Is your feature request related to a problem?
A recent issue ive encounter is that the generated client in Strawberry Shake is not consistent when using fragments
E.g the following graphl queries agains a schema.
fragment MySchool on School {
id
name
}
fragment MyStudent on Student {
id
name
age
school {
...MySchool
}
}
query GetStudentById($id: Int!) {
student(id: $id) {
...MyStudent
}
}
query GetStudents {
students {
...MyStudent
}
}
In this case it will generate two models for student. GetStudentById_Student and GetStudents_Students_Student both inherting from their own dedicated interfaces that in turn inherits from IMyStudent. But deeply nested properties like the School property on GetStudents_Students_Student and GetStudentById_Student gets randomly assigned a type that is either IGetStudents_Students_Student_School or IGetStudentById_Student_School.
The solution you'd like
Since they are both implementing the fragment interface IMyStudent it clearly means the school property can only be of one type and IMO that should be IMySchool which is the fragments interface. One could also argu that student and students properties should also use the interface IMyStudent instead of their own interfaces since the fragment is an intent to express a named contract.
Link to minimal reproduction from #7194: https://github.com/pm7y/StrawberryShakeBugRepro
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal reproduction linked from #7194 and inspect the generated model types for the fragment-based queries. The work is done when nested properties have predictable shared types, using the fragment interfaces consistently where the issue specifies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100