Skip to content

Commit

Permalink
Make fulfilledFragments always use fully qualified name (removing Sel…
Browse files Browse the repository at this point in the history
…f.self)
  • Loading branch information
AnthonyMDev committed Jun 8, 2023
1 parent bc2f3ee commit 070e27c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 49 deletions.
12 changes: 5 additions & 7 deletions Sources/ApolloCodegenLib/Templates/SelectionSetTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,15 @@ struct SelectionSetTemplate {
private func InitializerFulfilledFragments(
_ selectionSet: IR.SelectionSet
) -> TemplateString {
var fulfilledFragments: [String] = ["Self"]
var fulfilledFragments: OrderedSet<String> = []

var next = selectionSet.scopePath.last.value.scopePath.head
while next.next != nil {
defer { next = next.next.unsafelyUnwrapped }
var currentNode = Optional(selectionSet.scopePath.last.value.scopePath.head)
while let node = currentNode {
defer { currentNode = node.next }

let selectionSetName = SelectionSetNameGenerator.generatedSelectionSetName(
for: selectionSet,
to: next,
to: node,
format: .fullyQualified,
pluralizer: config.pluralizer
)
Expand Down Expand Up @@ -694,8 +694,6 @@ fileprivate extension IR.MergedSelections.MergedSource {
func generatedSelectionSetNamesOfFullfilledFragments(
pluralizer: Pluralizer
) -> [String] {
guard let fragment else { return [] }

let entityRootNameInFragment = SelectionSetNameGenerator
.generatedSelectionSetName(
for: self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class FragmentTemplateTests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestFragment.self)
]
))
}
Expand Down Expand Up @@ -460,7 +460,7 @@ class FragmentTemplateTests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestFragment.self)
]
))
}
Expand Down Expand Up @@ -567,7 +567,7 @@ class FragmentTemplateTests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestFragment.self)
]
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class OperationDefinitionTemplateTests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -381,7 +381,7 @@ class OperationDefinitionTemplateTests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -325,7 +325,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -392,9 +392,9 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsAnimalUnion.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsAnimalUnion.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsAnimalUnion.AsDog.self)
]
))
}
Expand Down Expand Up @@ -457,9 +457,9 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsPet.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsPet.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsPet.AsWarmBlooded.self)
]
))
}
Expand Down Expand Up @@ -604,7 +604,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"nestedList_optional_optional_optional": nestedList_optional_optional_optional,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -661,7 +661,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"fieldthree": fieldthree,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -710,7 +710,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"aliased": aliased,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -762,7 +762,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friends": friends._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -814,7 +814,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friends": friends._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -866,7 +866,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friends": friends._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -918,7 +918,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friend": friend._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -976,7 +976,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"__typename": __typename,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -1028,7 +1028,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friends": friends._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -1080,7 +1080,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friend": friend._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -1143,8 +1143,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"age": age,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsPet.self)
]
))
}
Expand Down Expand Up @@ -1221,7 +1221,9 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"feet": feet,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsCat.Height.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.Height.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsPet.Height.self)
]
))
}
Expand Down Expand Up @@ -1278,7 +1280,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(AnimalDetails.self)
]
))
Expand Down Expand Up @@ -1342,7 +1344,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(Fragment2.self),
ObjectIdentifier(AnimalDetails.self)
]
Expand Down Expand Up @@ -1405,8 +1407,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsPet.self),
ObjectIdentifier(AnimalDetails.self)
]
))
Expand Down Expand Up @@ -1464,7 +1466,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"__typename": __typename,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand All @@ -1482,8 +1484,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.AsPet.self),
ObjectIdentifier(AnimalDetails.self)
]
))
Expand Down Expand Up @@ -1570,8 +1572,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"name": name,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(Fragment1.Predator.self),
ObjectIdentifier(Fragment1.Predator.AsPet.self),
ObjectIdentifier(PetFragment.self),
ObjectIdentifier(PredatorFragment.self),
ObjectIdentifier(PredatorFragment.AsPet.self)
Expand Down Expand Up @@ -1654,8 +1656,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"name": name,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(Fragment1.Predator.self),
ObjectIdentifier(Fragment1.Predator.AsPet.self),
ObjectIdentifier(PetFragment.self),
ObjectIdentifier(PredatorFragment.Predator.self),
ObjectIdentifier(PredatorFragment.Predator.AsPet.self)
Expand Down Expand Up @@ -1711,7 +1713,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"name": name,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand Down Expand Up @@ -1769,8 +1771,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friend": friend._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfA.self)
]
))
}
Expand Down Expand Up @@ -1828,8 +1830,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friend": friend._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfAAndNotB.self)
]
))
}
Expand Down Expand Up @@ -1889,9 +1891,9 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"friend": friend._fieldData,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfA.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfA.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfA.IfNotB.self)
]
))
}
Expand Down Expand Up @@ -1951,8 +1953,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfA.Friend.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfA.Friend.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfA.Friend.IfNotB.self)
]
))
}
Expand Down Expand Up @@ -2011,7 +2013,7 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"__typename": __typename,
],
fulfilledFragments: [
ObjectIdentifier(Self.self)
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self)
]
))
}
Expand All @@ -2029,8 +2031,8 @@ class SelectionSetTemplate_Initializers_Tests: XCTestCase {
"species": species,
],
fulfilledFragments: [
ObjectIdentifier(Self.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.self),
ObjectIdentifier(TestOperationQuery.Data.AllAnimal.IfA.self),
ObjectIdentifier(AnimalDetails.self)
]
))
Expand Down

0 comments on commit 070e27c

Please sign in to comment.