Skip to content

Commit

Permalink
Remove @dynamicMemberLookup from InputDict
Browse files Browse the repository at this point in the history
  • Loading branch information
calvincestari committed Oct 26, 2022
1 parent 1eab1b0 commit 6f5fcea
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ public struct MeasurementsInput: InputObject {
}

public var height: Double {
get { __data[dynamicMember: "height"] }
set { __data[dynamicMember: "height"] = newValue }
get { __data["height"] }
set { __data["height"] = newValue }
}

public var weight: Double {
get { __data[dynamicMember: "weight"] }
set { __data[dynamicMember: "weight"] = newValue }
get { __data["weight"] }
set { __data["weight"] = newValue }
}

@available(*, deprecated, message: "No longer valid.")
public var wingspan: GraphQLNullable<Double> {
get { __data[dynamicMember: "wingspan"] }
set { __data[dynamicMember: "wingspan"] = newValue }
get { __data["wingspan"] }
set { __data["wingspan"] = newValue }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@ public struct PetAdoptionInput: InputObject {
}

public var ownerID: ID {
get { __data[dynamicMember: "ownerID"] }
set { __data[dynamicMember: "ownerID"] = newValue }
get { __data["ownerID"] }
set { __data["ownerID"] = newValue }
}

public var petID: ID {
get { __data[dynamicMember: "petID"] }
set { __data[dynamicMember: "petID"] = newValue }
get { __data["petID"] }
set { __data["petID"] = newValue }
}

/// The given name the pet is called by its human.
public var humanName: GraphQLNullable<String> {
get { __data[dynamicMember: "humanName"] }
set { __data[dynamicMember: "humanName"] = newValue }
get { __data["humanName"] }
set { __data["humanName"] = newValue }
}

public var favoriteToy: String {
get { __data[dynamicMember: "favoriteToy"] }
set { __data[dynamicMember: "favoriteToy"] = newValue }
get { __data["favoriteToy"] }
set { __data["favoriteToy"] = newValue }
}

public var isSpayedOrNeutered: Bool? {
get { __data[dynamicMember: "isSpayedOrNeutered"] }
set { __data[dynamicMember: "isSpayedOrNeutered"] = newValue }
get { __data["isSpayedOrNeutered"] }
set { __data["isSpayedOrNeutered"] = newValue }
}

public var measurements: GraphQLNullable<MeasurementsInput> {
get { __data[dynamicMember: "measurements"] }
set { __data[dynamicMember: "measurements"] = newValue }
get { __data["measurements"] }
set { __data["measurements"] = newValue }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ public struct PetSearchFilters: InputObject {
}

public var hash: GraphQLNullable<String> {
get { __data[dynamicMember: "hash"] }
set { __data[dynamicMember: "hash"] = newValue }
get { __data["hash"] }
set { __data["hash"] = newValue }
}

public var species: [String] {
get { __data[dynamicMember: "species"] }
set { __data[dynamicMember: "species"] = newValue }
get { __data["species"] }
set { __data["species"] = newValue }
}

public var size: GraphQLNullable<GraphQLEnum<RelativeSize>> {
get { __data[dynamicMember: "size"] }
set { __data[dynamicMember: "size"] = newValue }
get { __data["size"] }
set { __data["size"] = newValue }
}

public var measurements: GraphQLNullable<MeasurementsInput> {
get { __data[dynamicMember: "measurements"] }
set { __data[dynamicMember: "measurements"] = newValue }
get { __data["measurements"] }
set { __data["measurements"] = newValue }
}
}
7 changes: 3 additions & 4 deletions Sources/ApolloAPI/SchemaTypes/InputObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ extension InputObject {
}

/// A structure that wraps the underlying data dictionary used by `InputObject`s.
@dynamicMemberLookup
public struct InputDict: GraphQLOperationVariableValue, Hashable {

private var data: [String: GraphQLOperationVariableValue]
Expand All @@ -31,9 +30,9 @@ public struct InputDict: GraphQLOperationVariableValue, Hashable {

public var _jsonEncodableValue: (any JSONEncodable)? { data._jsonEncodableObject }

public subscript<T: GraphQLOperationVariableValue>(dynamicMember key: StaticString) -> T {
get { data[key.description] as! T }
set { data[key.description] = newValue }
public subscript<T: GraphQLOperationVariableValue>(key: String) -> T {
get { data[key] as! T }
set { data[key] = newValue }
}

public static func == (lhs: InputDict, rhs: InputDict) -> Bool {
Expand Down
4 changes: 2 additions & 2 deletions Sources/ApolloCodegenLib/Templates/InputObjectTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ struct InputObjectTemplate: TemplateRenderer {
\(documentation: field.documentation, config: config)
\(deprecationReason: field.deprecationReason, config: config)
public var \(field.name.asInputParameterName): \(field.renderInputValueType(config: config.config)) {
get { __data[dynamicMember: "\(field.name.asInputParameterName)"] }
set { __data[dynamicMember: "\(field.name.asInputParameterName)"] = newValue }
get { __data["\(field.name.asInputParameterName)"] }
set { __data["\(field.name.asInputParameterName)"] = newValue }
}
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public struct ColorInput: InputObject {
}

public var red: Int {
get { __data[dynamicMember: "red"] }
set { __data[dynamicMember: "red"] = newValue }
get { __data["red"] }
set { __data["red"] = newValue }
}

public var green: Int {
get { __data[dynamicMember: "green"] }
set { __data[dynamicMember: "green"] = newValue }
get { __data["green"] }
set { __data["green"] = newValue }
}

public var blue: Int {
get { __data[dynamicMember: "blue"] }
set { __data[dynamicMember: "blue"] = newValue }
get { __data["blue"] }
set { __data["blue"] = newValue }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public struct ReviewInput: InputObject {

/// 0-5 stars
public var stars: Int {
get { __data[dynamicMember: "stars"] }
set { __data[dynamicMember: "stars"] = newValue }
get { __data["stars"] }
set { __data["stars"] = newValue }
}

/// Comment about the movie, optional
public var commentary: GraphQLNullable<String> {
get { __data[dynamicMember: "commentary"] }
set { __data[dynamicMember: "commentary"] = newValue }
get { __data["commentary"] }
set { __data["commentary"] = newValue }
}

/// Favorite color, optional
public var favorite_color: GraphQLNullable<ColorInput> {
get { __data[dynamicMember: "favorite_color"] }
set { __data[dynamicMember: "favorite_color"] = newValue }
get { __data["favorite_color"] }
set { __data["favorite_color"] = newValue }
}
}
Loading

0 comments on commit 6f5fcea

Please sign in to comment.