-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate Operation Variables & Field Arguments (#2163)
* Render Operation Variable - single variable * Operation Variables - Multiple Variables * WIP: Operation Variable - nullables * Recfactored to add InputValueRenderable Finished implementation of operation variable generation * Fix renamed but not deleted file * Add ExpressibleBy Literals to GraphQLNullable * Correct OperationVariable rendering test behavior * WIP: Implementing rendering * Fix template string indentation * Add operation variable default values to CompilationResult * Add pet adoption mutation * Add public modifier to input object template * WIP: Fixing Input Object Accessors * Add public to input object init and fields * Generate InputObject fields with dynamic member accessors * Rename input object "dict" to "data" * Added PetSearchQuery to AnimalKingdom API * Fixed rendering of input enum values * Fixed conversion of default value dictionary literal to InputObject * WIP * Restructured tests to be accurate for behavior with initializing inpuit object default values directly * Changed Implementation for direct input value initialization * WIP: FieldArgument Rendering * Fix field argument rendering to use literals * Regenerate AnimalKingdomAPI with field arguments
- Loading branch information
1 parent
1e71ad0
commit ad37c60
Showing
45 changed files
with
2,009 additions
and
320 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
Apollo.xcodeproj/xcshareddata/xcschemes/AnimalKingdomAPI.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1320" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "DE3C7A00260A6B9800D2F4FF" | ||
BuildableName = "AnimalKingdomAPI.framework" | ||
BlueprintName = "AnimalKingdomAPI" | ||
ReferencedContainer = "container:Apollo.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "DE3C7A00260A6B9800D2F4FF" | ||
BuildableName = "AnimalKingdomAPI.framework" | ||
BlueprintName = "AnimalKingdomAPI" | ||
ReferencedContainer = "container:Apollo.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
Sources/AnimalKingdomAPI/Generated/Operations/PetAdoptionMutation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
|
||
import ApolloAPI | ||
|
||
public class PetAdoptionMutation: GraphQLMutation { | ||
public let operationName: String = "PetAdoptionMutation" | ||
public let document: DocumentType = .notPersisted( | ||
definition: .init( | ||
""" | ||
mutation PetAdoptionMutation($input: PetAdoptionInput!) { | ||
adoptPet(input: $input) { | ||
id | ||
humanName | ||
} | ||
} | ||
""" | ||
)) | ||
|
||
public var input: PetAdoptionInput | ||
|
||
public init(input: PetAdoptionInput) { | ||
self.input = input | ||
} | ||
|
||
public var variables: Variables? { | ||
["input": input] | ||
} | ||
|
||
public struct Data: AnimalKingdomAPI.SelectionSet { | ||
public let data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Mutation.self) } | ||
public static var selections: [Selection] { [ | ||
.field("adoptPet", AdoptPet.self, arguments: ["input": .variable("input")]), | ||
] } | ||
|
||
public var adoptPet: AdoptPet { data["adoptPet"] } | ||
|
||
/// AdoptPet | ||
public struct AdoptPet: AnimalKingdomAPI.SelectionSet { | ||
public let data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Interface(AnimalKingdomAPI.Pet.self) } | ||
public static var selections: [Selection] { [ | ||
.field("id", ID.self), | ||
.field("humanName", String?.self), | ||
] } | ||
|
||
public var id: ID { data["id"] } | ||
public var humanName: String? { data["humanName"] } | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
Sources/AnimalKingdomAPI/Generated/Operations/PetSearchQuery.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
|
||
import ApolloAPI | ||
|
||
public class PetSearchQuery: GraphQLQuery { | ||
public let operationName: String = "PetSearch" | ||
public let document: DocumentType = .notPersisted( | ||
definition: .init( | ||
""" | ||
query PetSearch($filters: PetSearchFilters = {species: ["Dog", "Cat"], size: SMALL, measurements: {height: 10.5, weight: 5.0}}) { | ||
pets(filters: $filters) { | ||
id | ||
humanName | ||
} | ||
} | ||
""" | ||
)) | ||
|
||
public var filters: GraphQLNullable<PetSearchFilters> | ||
|
||
public init(filters: GraphQLNullable<PetSearchFilters> = .init( | ||
PetSearchFilters( | ||
species: ["Dog", "Cat"], | ||
size: .init(.SMALL), | ||
measurements: .init( | ||
MeasurementsInput( | ||
height: 10.5, | ||
weight: 5.0 | ||
) | ||
) | ||
) | ||
)) { | ||
self.filters = filters | ||
} | ||
|
||
public var variables: Variables? { | ||
["filters": filters] | ||
} | ||
|
||
public struct Data: AnimalKingdomAPI.SelectionSet { | ||
public let data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Query.self) } | ||
public static var selections: [Selection] { [ | ||
.field("pets", [Pet].self, arguments: ["filters": .variable("filters")]), | ||
] } | ||
|
||
public var pets: [Pet] { data["pets"] } | ||
|
||
/// Pet | ||
public struct Pet: AnimalKingdomAPI.SelectionSet { | ||
public let data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Interface(AnimalKingdomAPI.Pet.self) } | ||
public static var selections: [Selection] { [ | ||
.field("id", ID.self), | ||
.field("humanName", String?.self), | ||
] } | ||
|
||
public var id: ID { data["id"] } | ||
public var humanName: String? { data["humanName"] } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/MeasurementsInput.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
|
||
import ApolloAPI | ||
|
||
public struct MeasurementsInput: InputObject { | ||
public private(set) var data: InputDict | ||
|
||
public init(_ data: InputDict) { | ||
self.data = data | ||
} | ||
|
||
public init( | ||
height: Float, | ||
weight: Float, | ||
wingspan: GraphQLNullable<Float> = nil | ||
) { | ||
data = InputDict([ | ||
"height": height, | ||
"weight": weight, | ||
"wingspan": wingspan | ||
]) | ||
} | ||
|
||
public var height: Float { | ||
get { data.height } | ||
set { data.height = newValue } | ||
} | ||
|
||
public var weight: Float { | ||
get { data.weight } | ||
set { data.weight = newValue } | ||
} | ||
|
||
public var wingspan: GraphQLNullable<Float> { | ||
get { data.wingspan } | ||
set { data.wingspan = newValue } | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/PetAdoptionInput.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
|
||
import ApolloAPI | ||
|
||
public struct PetAdoptionInput: InputObject { | ||
public private(set) var data: InputDict | ||
|
||
public init(_ data: InputDict) { | ||
self.data = data | ||
} | ||
|
||
public init( | ||
ownerID: ID, | ||
petID: ID, | ||
humanName: GraphQLNullable<String> = nil, | ||
favoriteToy: String, | ||
isSpayedOrNeutered: Bool?, | ||
measurements: GraphQLNullable<MeasurementsInput> = nil | ||
) { | ||
data = InputDict([ | ||
"ownerID": ownerID, | ||
"petID": petID, | ||
"humanName": humanName, | ||
"favoriteToy": favoriteToy, | ||
"isSpayedOrNeutered": isSpayedOrNeutered, | ||
"measurements": measurements | ||
]) | ||
} | ||
|
||
public var ownerID: ID { | ||
get { data.ownerID } | ||
set { data.ownerID = newValue } | ||
} | ||
|
||
public var petID: ID { | ||
get { data.petID } | ||
set { data.petID = newValue } | ||
} | ||
|
||
public var humanName: GraphQLNullable<String> { | ||
get { data.humanName } | ||
set { data.humanName = newValue } | ||
} | ||
|
||
public var favoriteToy: String { | ||
get { data.favoriteToy } | ||
set { data.favoriteToy = newValue } | ||
} | ||
|
||
public var isSpayedOrNeutered: Bool? { | ||
get { data.isSpayedOrNeutered } | ||
set { data.isSpayedOrNeutered = newValue } | ||
} | ||
|
||
public var measurements: GraphQLNullable<MeasurementsInput> { | ||
get { data.measurements } | ||
set { data.measurements = newValue } | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/PetSearchFilters.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
|
||
import ApolloAPI | ||
|
||
public struct PetSearchFilters: InputObject { | ||
public private(set) var data: InputDict | ||
|
||
public init(_ data: InputDict) { | ||
self.data = data | ||
} | ||
|
||
public init( | ||
species: [String], | ||
size: GraphQLNullable<GraphQLEnum<RelativeSize>> = nil, | ||
measurements: GraphQLNullable<MeasurementsInput> = nil | ||
) { | ||
data = InputDict([ | ||
"species": species, | ||
"size": size, | ||
"measurements": measurements | ||
]) | ||
} | ||
|
||
public var species: [String] { | ||
get { data.species } | ||
set { data.species = newValue } | ||
} | ||
|
||
public var size: GraphQLNullable<GraphQLEnum<RelativeSize>> { | ||
get { data.size } | ||
set { data.size = newValue } | ||
} | ||
|
||
public var measurements: GraphQLNullable<MeasurementsInput> { | ||
get { data.measurements } | ||
set { data.measurements = newValue } | ||
} | ||
} |
Oops, something went wrong.