StrawberryShake modifies queries when generated
Cheesebaron opened this issue · 0 comments
Product
Strawberry Shake
Version
14.x + 15.x
Link to minimal reproduction
https://github.com/Cheesebaron/StrawberryShakeQueryMangling
Steps to reproduce
Build the linked example project and check the obj/berry
output.
What is expected?
The generated code and query is different from the one I have in my .graphql
file and additional types are added to the query. I would expect only the types I explicitly query would end up being queried in the end.
What is actually happening?
When you look at the generated files in ActivitlyListQuery.Client
you will notice in the generated class the following GraphQL query. It is not just a comment, but also what StrawberryShake ends up requesting from the server.
query ActivityList($take: Int, $skip: Int, $activityKinds: [ActivityKind!], $includeHidden: Boolean) {
me {
__typename
activities(take: $take, skip: $skip, kinds: $activityKinds, includeHidden: $includeHidden) {
__typename
items {
__typename
kind
... ActivityListCoursePlay
... ActivityListRangeBullsEye
... ActivityListRangeHitIt
... ActivityListRangeCaptureTheFlag
... ActivityListRangePractice
... ActivityListRangeFMD
... ActivityListCombine
... ActivityListTest
... ActivityListScreenCast
... ActivityListShotAnalysis
... ActivityListVirtualRange
... ActivityListSession
... ActivityListPerformanceCenter
... on SessionActivity {
id
}
... on VirtualRangeSessionActivity {
id
}
... on PerformancePuttingSessionActivity {
id
}
... on SimulatorSessionActivity {
id
}
... on ShotAnalysisSessionActivity {
id
}
... on TracySessionActivity {
id
}
... on DynamicReportActivity {
id
}
... on CombineTestActivity {
id
}
... on TestActivity {
id
}
... on ScreencastActivity {
id
}
... on VideoActivityType {
id
}
... on RangePracticeActivity {
id
}
... on CoursePlayActivity {
id
}
... on ClosestToThePinActivity {
id
}
... on RangeFindMyDistanceActivity {
id
}
... on RangeBullsEyeActivity {
id
}
... on RangeHitItActivity {
id
}
... on RangeCaptureTheFlagActivity {
id
}
... on RangeVirtualGolfPlayActivity {
id
}
... on RangeVirtualGolfPracticeActivity {
id
}
... on PdfReportActivity {
id
}
... on EventReportActivity {
id
}
... on NoteActivity {
id
}
... on PerformanceCenterActivity {
id
}
}
pageInfo {
__typename
hasNextPage
hasPreviousPage
}
totalCount
}
}
}
When you compare that to the actual query in activity-list.graphql
:
query ActivityList($take: Int, $skip: Int, $activityKinds: [ActivityKind!], $includeHidden : Boolean) {
me {
activities (take: $take, skip: $skip, kinds: $activityKinds, includeHidden: $includeHidden)
{
items {
kind
... ActivityListCoursePlay
... ActivityListRangeBullsEye
... ActivityListRangeHitIt
... ActivityListRangeCaptureTheFlag
... ActivityListRangePractice
... ActivityListRangeFMD
... ActivityListCombine
... ActivityListTest
... ActivityListScreenCast
... ActivityListShotAnalysis
... ActivityListVirtualRange
... ActivityListSession
... ActivityListPerformanceCenter
}
pageInfo {
hasNextPage
hasPreviousPage
}
totalCount
}
}
}
Then I don't explicitly add querying for id on all of these types:
... on SessionActivity {
id
}
... on VirtualRangeSessionActivity {
id
}
... on PerformancePuttingSessionActivity {
id
}
... on SimulatorSessionActivity {
id
}
... on ShotAnalysisSessionActivity {
id
}
... on TracySessionActivity {
id
}
... on DynamicReportActivity {
id
}
... on CombineTestActivity {
id
}
... on TestActivity {
id
}
... on ScreencastActivity {
id
}
... on VideoActivityType {
id
}
... on RangePracticeActivity {
id
}
... on CoursePlayActivity {
id
}
... on ClosestToThePinActivity {
id
}
... on RangeFindMyDistanceActivity {
id
}
... on RangeBullsEyeActivity {
id
}
... on RangeHitItActivity {
id
}
... on RangeCaptureTheFlagActivity {
id
}
... on RangeVirtualGolfPlayActivity {
id
}
... on RangeVirtualGolfPracticeActivity {
id
}
... on PdfReportActivity {
id
}
... on EventReportActivity {
id
}
... on NoteActivity {
id
}
... on PerformanceCenterActivity {
id
}
Having this added behind your back is problematic, especially when you have multiple environments where some types are not present because they have not been released yet.
Relevant log output
Additional context
No response