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

fix: InputDict dynamicMember operator conflict with hash function #2607

Merged
merged 11 commits into from
Oct 26, 2022
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.height }
set { __data.height = newValue }
get { __data["height"] }
set { __data["height"] = newValue }
}

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

@available(*, deprecated, message: "No longer valid.")
public var wingspan: GraphQLNullable<Double> {
get { __data.wingspan }
set { __data.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.ownerID }
set { __data.ownerID = newValue }
get { __data["ownerID"] }
set { __data["ownerID"] = newValue }
}

public var petID: ID {
get { __data.petID }
set { __data.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.humanName }
set { __data.humanName = newValue }
get { __data["humanName"] }
set { __data["humanName"] = newValue }
}

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

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

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

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

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

public var measurements: GraphQLNullable<MeasurementsInput> {
get { __data.measurements }
set { __data.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.\(field.name.asInputParameterName) }
set { __data.\(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.red }
set { __data.red = newValue }
get { __data["red"] }
set { __data["red"] = newValue }
}

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

public var blue: Int {
get { __data.blue }
set { __data.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.stars }
set { __data.stars = newValue }
get { __data["stars"] }
set { __data["stars"] = newValue }
}

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

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