Skip to content

Commit 51dbdbd

Browse files
AnthonyMDevgh-action-runner
authored andcommitted
Add RootSelectionSet convenience initializer from inline fragment (#748)
1 parent 8d1abc5 commit 51dbdbd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apollo-ios/Sources/ApolloAPI/SelectionSet.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,16 @@ extension SelectionSet where Fragments: FragmentContainer {
128128
public var fragments: Fragments { Fragments(_dataDict: __data) }
129129
}
130130

131+
// MARK: - Root Entity Type Conversion Helpers
132+
131133
extension InlineFragment {
132134
@inlinable public var asRootEntityType: RootEntityType {
133135
RootEntityType.init(_dataDict: __data)
134136
}
135137
}
138+
139+
extension RootSelectionSet {
140+
public init<T: InlineFragment>(_ inlineFragment: T) where T.RootEntityType == Self {
141+
self = inlineFragment.asRootEntityType
142+
}
143+
}

0 commit comments

Comments
 (0)