apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.89k stars 728 forks source link

Can't able to download schema with apollo-codegen-config.json file Please help me in this #3302

Closed jmohanr closed 11 months ago

jmohanr commented 11 months ago

Summary

When I try to download schema through ./Pods/Apollo/apollo-ios-cli fetch-schema this command getting below error

Error: keyNotFound(CodingKeys(stringValue: "key", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "schemaDownloadConfiguration", intValue: nil), CodingKeys(stringValue: "headers", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"key\", intValue: nil) (\"key\").", underlyingError: nil))

Version

1.0.6

Steps to reproduce the behavior

Logs

No response

Anything else?

{ "schemaName" : "Ke4Enrolment", "options" : { "cocoapodsCompatibleImportStatements" : true }, "input" : { "operationSearchPaths" : [ "*/.graphql" ], "schemaSearchPaths" : [ "*/.graphqls" ] }, "output" : { "testMocks" : { "none" : { } }, "schemaTypes" : { "path" : "./Ke4Enrolment", "moduleType" : { "embeddedInTarget" : { "name" : "Ke4Schema" } } }, "operations" : { "inSchemaModule" : { } } }, "schemaDownloadConfiguration": { "downloadMethod": { "introspection": { "endpointURL": "", "httpMethod": { "POST": {} }, "includeDeprecatedInputValues": false, "outputFormat": "SDL" } }, "downloadTimeout": 60, "headers": [ {"Authorization": "Bearer " }, { "x-api-key": "" } ], "outputPath": "./graphql/schema.graphqls" } }

calvincestari commented 11 months ago

Hi @jmohanr, I think it's the headers configuration that is incorrect.

In 1.0.6 and below you had to use the following format for header keys:

"headers": [ 
  {
    "key": "Authorization",
     "value": "Bearer "
  },
  {
    "key": "x-api-key",
     "value": ""
  }
]

From 1.0.7 though you can simply specify headers as a dictionary like this:

"headers": {
        "Authorization" : "Bearer ",
        "x-api-key" : ""
    }

I recommend upgrading to 1.0.7 to be able to use the new format, or even better get on the latest version 1.7.1.