Skip to content

[Data Connect] Bug: Swift SDK generates conflicting property/class names #9704

@samtsangbiz

Description

@samtsangbiz

[REQUIRED] Environment info

firebase-tools: 15.1.0

Platform: macOS

[REQUIRED] Test case

Create a Firebase Data Connect mutation with an underscore-prefixed or PascalCase name:

# File: dataconnect/app-connector/mutations.gql

mutation _Placeholder @auth(level: NO_ACCESS) {
  company_upsert(data: { cik: "_placeholder" })
}

Configure Swift SDK generation in connector.yaml:

connectorId: app
generate:
swiftSdk:
outputDir: ../apps/ios/MyApp/DataConnect
package: MyAppDataConnect

[REQUIRED] Steps to reproduce

  1. Create a Data Connect connector with a mutation named _Placeholder (or any PascalCase name like CreateUser)
  2. Run firebase dataconnect:sdk:generate
  3. Open the generated Swift project in Xcode
  4. Attempt to build the project

[REQUIRED] Expected behavior

The generated Swift SDK should compile without errors. The SDK generator should ensure that property names use camelCase to avoid conflicts with class names.

Expected generated code:
// Property uses camelCase, class uses PascalCase - no conflict
public let placeholderMutation: PlaceholderMutation

[REQUIRED] Actual behavior

The generated Swift code produces a compilation error because the property name and class name are identical:

Xcode Error:

  Use of 'PlaceholderMutation' refers to instance method rather than class 'PlaceholderMutation' in module 'MyAppDataConnect'

  Generated code (AppClient.swift):
  public class AppConnector {
    init(dataConnect: DataConnect) {
      // Property and class have the same name - causes Swift conflict
      self.PlaceholderMutation = PlaceholderMutation(dataConnect: dataConnect)
    }

    // MARK: Operations
    public let PlaceholderMutation: PlaceholderMutation  // ❌ Conflict!
  }

Root Cause:
When the GraphQL operation name starts with uppercase (after removing _ prefix), the SDK generator uses the same casing for both the property name and class name, causing a Swift naming conflict.

GraphQL Name Generated Property Generated Class Result
_Placeholder PlaceholderMutation PlaceholderMutation ❌ Conflict
CreateUser CreateUserMutation CreateUserMutation ❌ Conflict
placeholder placeholderMutation PlaceholderMutation ✅ Works
createUser createUserMutation CreateUserMutation ✅ Works

Workaround:
Use camelCase for all GraphQL operation names (e.g., placeholder instead of _Placeholder).

Suggested Fix:
The SDK generator should normalize property names to camelCase regardless of the input GraphQL operation name casing.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions