Skip to content

Commit

Permalink
Add local cache mutation typealias definitions to embedded template f…
Browse files Browse the repository at this point in the history
…or the schema
  • Loading branch information
calvincestari committed Jun 14, 2022
1 parent f869fea commit 879c7b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Sources/ApolloCodegenLib/Templates/SchemaTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ struct SchemaTemplate: TemplateRenderer {
\(embeddedAccessControlModifier(config: config))\
typealias InlineFragment = \(schemaName)_InlineFragment
\(embeddedAccessControlModifier(config: config))\
typealias MutableSelectionSet = \(schemaName)_MutableSelectionSet
\(embeddedAccessControlModifier(config: config))\
typealias MutableInlineFragment = \(schemaName)_MutableInlineFragment
"""),
else: protocolDefinition(prefix: nil, schemaName: schemaName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class SchemaTemplateTests: XCTestCase {
typealias InlineFragment = AName_InlineFragment
typealias MutableSelectionSet = AName_MutableSelectionSet
typealias MutableInlineFragment = AName_MutableInlineFragment
"""

let expectedDetached = """
Expand Down Expand Up @@ -201,7 +205,7 @@ class SchemaTemplateTests: XCTestCase {
let actual = renderTemplate()

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

func test__render__givenModuleSwiftPackageManager_shouldGenerateEnumDefinition_withPublicModifier() {
Expand All @@ -216,7 +220,7 @@ class SchemaTemplateTests: XCTestCase {
let actual = renderTemplate()

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

func test__render__givenModuleOther_shouldGenerateEnumDefinition_withPublicModifier() {
Expand All @@ -231,7 +235,7 @@ class SchemaTemplateTests: XCTestCase {
let actual = renderTemplate()

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

func test__render__givenWithReferencedObjects_generatesObjectTypeFunctionCorrectlyCased() {
Expand Down Expand Up @@ -261,7 +265,7 @@ class SchemaTemplateTests: XCTestCase {
let actual = renderTemplate()

// then
expect(actual).to(equalLineByLine(expected, atLine: 8))
expect(actual).to(equalLineByLine(expected, atLine: 12))
}

func test__render__givenWithReferencedOtherTypes_generatesObjectTypeNotIncludingNonObjectTypesFunction() {
Expand Down Expand Up @@ -292,6 +296,6 @@ class SchemaTemplateTests: XCTestCase {
let actual = renderTemplate()

// then
expect(actual).to(equalLineByLine(expected, atLine: 8))
expect(actual).to(equalLineByLine(expected, atLine: 12))
}
}

0 comments on commit 879c7b7

Please sign in to comment.