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

put shared renamed types in unions behind a hint #541

Merged
merged 2 commits into from
May 14, 2024

Conversation

temaEmelyan
Copy link
Member

Please make sure you consider the following:

  • Add tests that use __typename in queries
  • Does this change work with all nadel transformations (rename, type rename, hydration, etc)? Add tests for this.
  • Is it worth using hints for this change in order to be able to enable a percentage rollout?
  • Do we need to add integration tests for this change in the graphql gateway?
  • Do we need a pollinator check for this?

that's a follow up on #537
I put all changes that were done there behind a hint so we can have a safer rollout
also in that PR I missed one branch, fixed that and covered with a test


) {
override fun toString(): String {
return "Service{name='$name'}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just so we don't see stuff like Service@323edf

val typeName: String = if (
!executionContext.hints.sharedTypeRenames(service) ||
overallField.objectTypeNames.contains(overallTypeName)
) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, if hints are off, we will always use the old behaviour, just get the overallTypeName

overallTypeName
} else {
overallField.objectTypeNames.single {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that single blew up here during the rollout, handling it safer by defaulting to overallTypeName

}
} else {
objectTypeNames.map {
executionBlueprint.getUnderlyingTypeName(service, overallTypeName = it)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so if something is renamed but the type is declared and renamed in another service
executionBlueprint.getUnderlyingTypeName(service, overallTypeName = it) will not actually get you the underlying name as it's only looking at the types owned by service. this thing executionBlueprint.getUnderlyingTypeName(overallTypeName = it) looks at the whole overall schema tho, for every rename, there can only be 1 underlying name and 1 overall name, so it's always 1 to 1 mapping

executionBlueprint.getUnderlyingTypeName(service, overallTypeName = it)
return if (executionContext.hints.sharedTypeRenames(service)) {
objectTypeNames.map {
executionBlueprint.getUnderlyingTypeName(overallTypeName = it)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This… doesn't feel right.

Sorry I haven't really been following this work, but renames are technically supposed to be per service.

Tbh I don't really remember the full story, but a long time ago I wanted to implement repeated @renamed with a service argument.

@@ -168,8 +168,14 @@ class NadelQueryTransformer private constructor(
}

private fun getUnderlyingTypeNames(objectTypeNames: Collection<String>): List<String> {
return objectTypeNames.map {
executionBlueprint.getUnderlyingTypeName(service, overallTypeName = it)
return if (executionContext.hints.sharedTypeRenames(service)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the bit I missed the first time around. This is covered by the test where I added fragments that used renamed typenames

  query {
    nodes {
      __typename
      ... on Issue {
        id
      }
      ... on JiraComment {
        id
      }
    }
  }

I didn't realise that this thing runs every time before we send the query to the underlying

@temaEmelyan temaEmelyan merged commit 3f80323 into master May 14, 2024
2 checks passed
@temaEmelyan temaEmelyan deleted the put-shared-renamed-types-in-unions-behind-a-hint branch May 14, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants