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

Generate Operation Variables & Field Arguments #2163

Merged
merged 25 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1e1a6e9
Render Operation Variable - single variable
AnthonyMDev Feb 14, 2022
35a5272
Operation Variables - Multiple Variables
AnthonyMDev Feb 14, 2022
b2770a7
WIP: Operation Variable - nullables
AnthonyMDev Feb 14, 2022
f9dcc92
Recfactored to add InputValueRenderable
AnthonyMDev Feb 15, 2022
9006ab9
Fix renamed but not deleted file
AnthonyMDev Feb 15, 2022
b5864cb
Add ExpressibleBy Literals to GraphQLNullable
AnthonyMDev Feb 16, 2022
110a6bf
Correct OperationVariable rendering test behavior
AnthonyMDev Feb 16, 2022
14a0989
WIP: Implementing rendering
AnthonyMDev Feb 16, 2022
fedc884
Fix template string indentation
AnthonyMDev Feb 16, 2022
3c2c08c
Add operation variable default values to CompilationResult
AnthonyMDev Feb 16, 2022
001a49a
Add pet adoption mutation
AnthonyMDev Feb 16, 2022
6af18f7
Add public modifier to input object template
AnthonyMDev Feb 16, 2022
eda88fb
WIP: Fixing Input Object Accessors
AnthonyMDev Feb 16, 2022
df531ec
Add public to input object init and fields
AnthonyMDev Feb 17, 2022
e49a422
Generate InputObject fields with dynamic member accessors
AnthonyMDev Feb 17, 2022
99b65b6
Rename input object "dict" to "data"
AnthonyMDev Feb 17, 2022
b7b56bb
Added PetSearchQuery to AnimalKingdom API
AnthonyMDev Feb 17, 2022
6528aec
Fixed rendering of input enum values
AnthonyMDev Feb 17, 2022
6650fff
Fixed conversion of default value dictionary literal to InputObject
AnthonyMDev Feb 17, 2022
2a18a8a
WIP
AnthonyMDev Feb 18, 2022
ba9c640
Restructured tests to be accurate for behavior with initializing inpu…
AnthonyMDev Feb 18, 2022
3c105a1
Changed Implementation for direct input value initialization
AnthonyMDev Feb 18, 2022
224eda6
WIP: FieldArgument Rendering
AnthonyMDev Feb 18, 2022
3c780f3
Fix field argument rendering to use literals
AnthonyMDev Feb 21, 2022
ddd74ac
Regenerate AnimalKingdomAPI with field arguments
AnthonyMDev Feb 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 102 additions & 6 deletions Apollo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions Apollo.xcodeproj/xcshareddata/xcschemes/AnimalKingdomAPI.xcscheme
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>
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ public class AllAnimalsQuery: GraphQLQuery {

public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Bird.self) }
public static var selections: [Selection] { [
.field("wingspan", Int.self),
.field("wingspan", Float.self),
] }

public var wingspan: Int { data["wingspan"] }
public var wingspan: Float { data["wingspan"] }
public var height: Height { data["height"] }
public var species: String { data["species"] }
public var skinCovering: GraphQLEnum<SkinCovering>? { data["skinCovering"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ public struct ClassroomPetDetails: AnimalKingdomAPI.SelectionSet, Fragment {

public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Bird.self) }
public static var selections: [Selection] { [
.field("wingspan", Int.self),
.field("wingspan", Float.self),
] }

public var wingspan: Int { data["wingspan"] }
public var wingspan: Float { data["wingspan"] }
public var species: String { data["species"] }
public var humanName: String? { data["humanName"] }
public var laysEggs: Bool { data["laysEggs"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class ClassroomPetsQuery: GraphQLQuery {
public var species: String { data["species"] }
public var humanName: String? { data["humanName"] }
public var laysEggs: Bool { data["laysEggs"] }
public var wingspan: Int { data["wingspan"] }
public var wingspan: Float { data["wingspan"] }

public struct Fragments: FragmentContainer {
public let data: DataDict
Expand Down
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 Sources/AnimalKingdomAPI/Generated/Operations/PetSearchQuery.swift
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"] }
}
}
}
4 changes: 2 additions & 2 deletions Sources/AnimalKingdomAPI/Generated/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
.library(name: "AnimalKingdomAPI", targets: ["AnimalKingdomAPI"]),
],
dependencies: [
.package(url: "https://github.com/apollographql/apollo-ios.git", .branch("release/1.0-alpha-incubating")),
.package(url: "https://github.com/apollographql/apollo-ios.git", from: "1.0.0-alpha.1"),
],
targets: [
.target(
Expand All @@ -25,4 +25,4 @@ let package = Package(
path: "."
),
]
)
)
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 }
}
}
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 }
}
}
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 }
}
}
Loading