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: Removes local cache mutation type condition setter #485

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading