Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StrawberryShake modifies queries when generated #7781

Open
Cheesebaron opened this issue Nov 29, 2024 · 0 comments
Open

StrawberryShake modifies queries when generated #7781

Cheesebaron opened this issue Nov 29, 2024 · 0 comments

Comments

@Cheesebaron
Copy link
Contributor

Cheesebaron commented Nov 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants