Skip to content

Commit

Permalink
Add fragmentSpread convenience initializer to selection
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMDev committed Sep 21, 2021
1 parent 6f5e31e commit 97a4652
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Sources/ApolloAPI/CodegenV1/Selection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ public enum Selection {
_ name: String,
alias: String? = nil,
_ type: OutputTypeConvertible.Type,
arguments: Field.Arguments? = nil) -> Selection {
return .field(.init(name, alias: alias, type: type.asOutputType, arguments: arguments))
arguments: Field.Arguments? = nil
) -> Selection {
.field(.init(name, alias: alias, type: type.asOutputType, arguments: arguments))
}

static public func typeCase(
if typeCondition: ParentTypeConvertible.Type,
include selectionSet: ApolloAPI.TypeCase.Type
) -> Selection {
return .typeCase(.init(typeCondition: typeCondition.asParentType, selectionSet: selectionSet))
.typeCase(.init(typeCondition: typeCondition.asParentType, selectionSet: selectionSet))
}

static public func fragment(_ fragment: Fragment.Type) -> Selection {
.fragmentSpread(.init(fragment))
}
}
2 changes: 2 additions & 0 deletions Tests/ApolloTests/RequestBodyCreatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ class RequestBodyCreatorTests: XCTestCase {
// then
expect(actual).to(equalJSONValue(expected))
}

#warning("TODO: Test generated input objects converted to variables correctly.")
}

0 comments on commit 97a4652

Please sign in to comment.