Conflict DocumentType in autogeneration of schema code

Summarizing, there is a enum which is a input type called DocumentType and its facing conflict with newest Apollo 1.0 because now there is a defined structure called DocumentType as well.

// This file was automatically generated and should not be edited.

import Apollo

public enum DocumentType: String, EnumType {
  case unspecifiedDocumentType = "UNSPECIFIED_DOCUMENT_TYPE"
  case selfie = "SELFIE"
  /* ... more cases */
}

The autogenerated schema:

// This file was automatically generated and should not be edited.

@_exported import Apollo

public class CustomMutationOperation: GraphQLMutation {
  public static let operationName: String = "operationName"
  public static let document: DocumentType = .notPersisted(
    definition: .init(
      """
         // the document description
      """
    ))

Error:
Type 'DocumentType' has no member 'notPersisted'

There is anything that can be done to solve this conflict?

Hi @celtaheaven :wave: - there was a fix in 1.0.2 specifically for this type of bug - release notes. Please make sure you’re using the latest version available.

Hello @calvincestari,

Thank you for the answer. I’m @celtaheaven collegue.

As you can see in the first image, I’m using the 1.0.2 version and I tried in 1.0.3 too without any success :cry:
Screenshot 2022-11-16 at 17.05.22

I will add here my configuration file, am I doing something wrong?

{
    "schemaName": "XXX",
    "options": {
        "queryStringLiteralFormat": "multiline",
        "deprecatedEnumCases": "include",
        "schemaDocumentation": "include",
        "apqs": "disabled",
        "cocoapodsCompatibleImportStatements": true,
        "warningsOnDeprecatedUsage": "include",
        "conversionStrategies": {
            "enumCases": "camelCase"
        },
        "pruneGeneratedFiles": true
    },
    "input": {
        "operationSearchPaths": [
            "./../../GraphQLModel/**/*.graphql"
        ],
        "schemaSearchPaths": [
            "./../../GraphQLModel/**/*.graphqls",
            "./../**/*.graphqls"
        ]
    },
    "output": {
        "testMocks": {
            "none": {}
        },
        "schemaTypes": {
            "path": "./SchemaData/",
            "moduleType": {
                "other": {}
            }
        },
        "operations": {
            "inSchemaModule": {}
        }
    },
    "schemaDownloadConfiguration": {
        "downloadMethod": {
            "introspection": {
                "endpointURL": "https://xxx.com.br/",
                "httpMethod": {
                    "POST": {}
                },
                "includeDeprecatedInputValues": false,
                "outputFormat": "SDL"
            }
        },
        "downloadTimeout": 60,
        "headers": [],
        "outputPath": "./all-schema.graphqls"
    }
}

I think another person has exactly the same issue as me on Apollo Github:

Hiya @Humberto_Vieira_de_C - version 1.0.4 was released yesterday and includes a fix for this. Let me know if that doesn’t work for you.

1 Like

I have a similar conflict but with Selection type. Is there any way to just make codegen always prefix with Apollo. so that these conflicts don’t happen?

Hi @tahirmt - unfortunately no way to prefix type names but Anthony and I have discussed the issue and will see what can be done to resolve this and some other type name conflicts we’ve seen lately.

Thank you. Looking forward to resolve this. I can work around it by adding a namespace to the type after codegen is complete through a script.

1 Like