Skip to content

Commit

Permalink
fix: Removes local cache mutation type condition setter (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvincestari authored and gh-action-runner committed Sep 18, 2024
1 parent d2185aa commit 53f7cad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
let actual = subject.test_render(childEntity: allAnimals.computed)

// then
expect(actual).to(equalLineByLine(expected, atLine: 18, ignoringExtraLines: true))
expect(actual).to(equalLineByLine(expected, atLine: 15, ignoringExtraLines: true))
}

// MARK: - Accessor Tests
Expand Down Expand Up @@ -263,7 +263,7 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
expect(actual).to(equalLineByLine(expected, atLine: 12, ignoringExtraLines: true))
}

func test__render_inlineFragmentAccessors__rendersAccessorWithGetterAndSetter() async throws {
func test__render_inlineFragmentAccessors__rendersAccessorWithGetterOnly() async throws {
// given
schemaSDL = """
type Query {
Expand All @@ -290,10 +290,7 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
"""

let expected = """
public var asDog: AsDog? {
get { _asInlineFragment() }
set { if let newData = newValue?.__data._data { __data._data = newData }}
}
public var asDog: AsDog? { _asInlineFragment() }
"""

// when
Expand Down Expand Up @@ -391,7 +388,7 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
let actual = subject.test_render(childEntity: allAnimals.computed)

// then
expect(actual).to(equalLineByLine(expected, atLine: 21, ignoringExtraLines: true))
expect(actual).to(equalLineByLine(expected, atLine: 18, ignoringExtraLines: true))
}

// MARK: - Casing Tests
Expand Down Expand Up @@ -435,7 +432,7 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
public struct AsDog: Myschema.MutableInlineFragment {
"""

expect(actual).to(equalLineByLine(expected, atLine: 18, ignoringExtraLines: true))
expect(actual).to(equalLineByLine(expected, atLine: 15, ignoringExtraLines: true))
}

func test__casingForMutableInlineFragment__givenUppercasedSchemaName_generatesUppercasedNamespace() async throws {
Expand Down Expand Up @@ -477,7 +474,7 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
public struct AsDog: MYSCHEMA.MutableInlineFragment {
"""

expect(actual).to(equalLineByLine(expected, atLine: 18, ignoringExtraLines: true))
expect(actual).to(equalLineByLine(expected, atLine: 15, ignoringExtraLines: true))
}

func test__casingForMutableInlineFragment__givenCapitalizedSchemaName_generatesCapitalizedNamespace() async throws {
Expand Down Expand Up @@ -519,6 +516,6 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
public struct AsDog: MySchema.MutableInlineFragment {
"""

expect(actual).to(equalLineByLine(expected, atLine: 18, ignoringExtraLines: true))
expect(actual).to(equalLineByLine(expected, atLine: 15, ignoringExtraLines: true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -478,16 +478,7 @@ struct SelectionSetTemplate {

let typeName = inlineFragment.renderedTypeName
return """
\(renderAccessControl())var \(typeName.firstLowercased): \(typeName)? {\
\(if: isMutable,
"""
get { _asInlineFragment() }
set { if let newData = newValue?.__data._data { __data._data = newData }}
}
""",
else: " _asInlineFragment() }"
)
\(renderAccessControl())var \(typeName.firstLowercased): \(typeName)? { _asInlineFragment() }
"""
}

Expand Down

0 comments on commit 53f7cad

Please sign in to comment.