Receiving "cannotCreateFile" Error fetching schema with apollo-ios-cli

Hello,

I’m upgrading an iOS project from Apollo v0.53.0 Swift Package to v1.0.7 and receive a Error: cannotCreateFile(at: "/Users/jimmc/Developer/unified-ios-sandbox") failure using apollo-ios-cli.

This is the command I’m using: ./apollo-ios-cli generate --verbose --fetch-schema
And this is the schemaDownloadConfiguration section of apollo-codegen-config.json:

    "schemaDownloadConfiguration": {
        "downloadMethod": {
            "introspection": {
                "endpointURL": "https://api.redacted.com/mobile-bff/graphql",
                "httpMethod": {
                    "POST": {}
                },
                "includeDeprecatedInputValues": false,
                "outputFormat": "SDL"
            }
        },
        "downloadTimeout": 60,
        "outputPath": "./MobileBFF"
    }

Full output from the command:

[DEBUG - ApolloCodegenLib:ApolloSchemaDownloader.swift:345] - Downloading schema via introspection from https://api.redacted.com/mobile-bff/graphql
Error: cannotCreateFile(at: "/Users/jimmc/Developer/unified-ios-sandbox/MobileBFF")

I’ve tried multiple outputPaths, with and without sudo but I get the same error and a different path. Maybe my environment is setup incorrectly? I’m able to download the schema using the exiting ApollCodegen toolset from v0.53.0.

TIA, Jim

Hi @jimmc_dat, this seems quite odd. Have you tried using a filename for outputPath instead of a directory? Eg: "outputPath": "./MobileBFF/schema.graphqls".

Looking in the code, that path used in the error description is the path used in the call to FileManager.createFile so I’m wondering if it’s encountering a directory at `./MobileBFF’, unable to write a file there and erroring with a not very helpful message.

Hi @calvincestari, that was it! Thank you. Thinking back on it now, I should have tried that but I didn’t see where we were specifying a filename for the generate step (just a folder path) with the v0.53.0 version of the toolset.

Cheers, Jim

It’s not a great experience when things are ambiguous. I’ll see what we can do to improve either the error message or make it clearer what that value needs to specify. Glad you got it working though!

I’ve created `ApolloSchemaDownloadConfiguration.outputPath` is ambiguous · Issue #2864 · apollographql/apollo-ios · GitHub where we can track progress on this.

1 Like