I want to set the baseUrl in the @source
directive via an environment config setting because we promote our schema from lower environments to upper environments, and the URL for the API changes in each environment. However, we also require schema proposals for all changes, so the baseUrl must be configurable outside the schema. I was thinking I could do the following with the {$config.myApiBaseUrl}
inside the @source
directive:
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.10"
import: ["@key", "@policy"]
)
@link(
url: "https://specs.apollo.dev/connect/v0.1"
import: ["@connect", "@source"]
)
@source(
name: "myApi"
http: {
baseURL: "{$config.myApiBaseUrl}"
}
)
type Account @key(fields: "id") {
id: ID!
firstName: String
@connect(
source: "/myApi"
http: { GET: "/accounts/{$this.id}" }
selection: """
firstName
"""
)
}
However, I get the following error during composition:
The value "{$config.myApiBaseUrl}" for
@source(baseURL:) is not a valid URL: relative URL without a base.(INVALID_URL)
Is there something I am missing?