schemaNamespace ignored when generating Swift code

hey,
I’m generating Swift code using a apollo-codegen-configuration.json definition but the schemaNamespace does not seem to have any effect on the generated code. According to the docs the schemaNamespace should create a caseless enum to avoid name clashes

My config is the following

{
  "schemaNamespace": "V2",
  "schemaName": "MyApi",
  "schemaDownloadConfiguration": {
    
  },
  "input": {
    "operationSearchPaths": ["../Projects/**/*-pmts-v2.graphql"],
    "schemaSearchPaths": ["../Projects/PMTNetworking/Sources/GraphQL/schema-pmts-v2.graphqls"]
  },
  "output": {
    "pruneGeneratedFiles": true,
    "testMocks": {
      "none": {}
    },
    "schemaTypes": {
      "path": "../Projects/PMTNetworking/Sources/GraphQL/GeneratedV2",
      "moduleType": {
        "other": {}
      }
    },
    "operations": {
      "inSchemaModule": {}
    }
  }
}

What did I do wrong?

cheers

Hi @JanC - the caseless enum is only created when the embeddedInTarget module type is used. This is to create a namespace to prevent potential clashes in the target code. When the other module type is used the namespace is the module name which means the enum namespace isn’t needed.

1 Like