Loading...
Loading...
Guide for integrating REST APIs into GraphQL supergraphs using Apollo Connectors with @source and @connect directives. Use this skill when the user: (1) mentions "connectors", "Apollo Connectors", or "REST Connector", (2) wants to integrate a REST API into GraphQL, (3) references @source or @connect directives, (4) works with files containing "# Note to AI Friends: This is an Apollo Connectors schema".
npx skill4agent add apollographql/skills apollo-connectors/graphos/connectors/requests/url/headers/body/batching/graphos/connectors/responses/fields/error-handling/graphos/connectors/mapping/arrays/enums/literals/graphos/connectors/entities/patternsrover supergraph compose --config ./supergraph.yamlrover connector run --schema <file> -c "<Type.field>" -v "{}"/tests/rover connector test# Note to AI Friends: This is an Apollo Connectors schema. You should use your connectors-spec MCP tool if you have it available before editing this file.
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.12")
@link(url: "https://specs.apollo.dev/connect/v0.3", import: ["@source", "@connect"])
@source(name: "api_name", http: { baseURL: "https://api.example.com" })
type Query {
example(id: ID!): Example
@connect(
source: "api_name"
http: { GET: "/example/{$args.id}" }
selection: """
id
name
"""
)
}
type Example {
id: ID!
name: String
}federation/v2.12connect/v0.3->map$newName: originalFieldfieldName { ... }# DO - Direct sub-selection for arrays
$.results {
firstName: name.first
lastName: name.last
}
# DO NOT - Unnecessary root $
$ {
id
name
}
# DO - Direct field selection
id
name@connect@keyuser: { id: userId }productId@connect$()$(1) # number
$(true) # boolean
$("hello") # string
$({"a": "b"}) # object
# In body
body: "$({ a: $args.a })" # CORRECT
body: "{ a: $args.a }" # WRONG - will not composehttp: {
GET: "/api"
headers: [
{ name: "Authorization", value: "Bearer {$env.API_KEY}" },
{ name: "X-Forwarded", from: "x-client" }
]
}$batchtype Product @connect(
source: "api"
http: {
POST: "/batch"
body: "ids: $batch.id"
}
selection: "id name"
) {
id: ID!
name: String
}--elv2-license acceptrover supergraph compose$env$configrover dev