apollo-connectors

작성자: apollographql

REST API를 @source 및 @connect 지시문을 사용하여 GraphQL 슈퍼그래프에 통합합니다. 구조화된 5단계 프로세스를 제공합니다: API 구조 조사, 지시문으로 스키마 구현, rover supergraph compose를 통한 검증, 커넥터 실행, 테스트 커버리지. 헤더, 본문 페이로드, N+1 패턴을 위한 배칭, $env를 통한 환경 변수 주입을 포함한 요청 구성을 지원합니다. 필드 선택, 별칭, 중첩 데이터를 위한 하위 선택, 엔티티...를 포함한 응답 매핑을 처리합니다.

npx skills add https://github.com/apollographql/skills --skill apollo-connectors

Apollo Connectors Schema Assistant

MCP Tools

If GraphOS MCP Tools are available, use them:

  • connectors-spec: Fetch the complete Connectors specification before starting any connector work
  • apollo_docs_search: Search for relevant documentation
  • apollo_docs_read: Read specific documentation pages by slug

Documentation paths by topic:

  • Requests: /graphos/connectors/requests/url, /headers, /body, /batching
  • Responses: /graphos/connectors/responses/fields, /error-handling
  • Mapping: /graphos/connectors/mapping, /arrays, /enums, /literals
  • Entities: /graphos/connectors/entities, /patterns

Process

Follow this 5-step process. DO NOT skip any steps.

Step 1: Research

  • Understand the API being called and the structure of responses
  • Ask the user for example API responses if not provided
  • Fetch relevant documentation from MCP tools or reference files
  • DO NOT write any code until research is complete

Step 2: Implement

  • Create the schema using the template below
  • Follow the grammar, methods, and variables in the reference files
  • Ask clarifying questions if unsure about requirements

Step 3: Validate (Compose)

  • Run rover supergraph compose --config ./supergraph.yaml
  • Fix any composition errors before proceeding

Step 4: Execute

  • Run rover connector run --schema <file> -c "<Type.field>" -v "{}"
  • Verify the connector executes correctly

Step 5: Test

  • Create or update test files under /tests/
  • Run rover connector test
  • Ensure full test coverage for each connector

Schema Template

# 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.15")
  @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
}

Version requirements

Use the latest Long-Term Support (LTS) versions of Apollo Federation and Apollo Connectors. Use a preview or experimental spec only when the user explicitly asks for it.

Confirm the current LTS before writing @link URLs or federation_version. Prefer the GraphOS docs tools when they are available:

  • Federation: read /graphos/schema-design/federated-schemas/reference/versions and use the highest version marked LTS. That version is the schema @link (https://specs.apollo.dev/federation/vX.Y). Set federation_version in supergraph.yaml to the latest patch of that same LTS line.
  • Connectors: read /graphos/connectors/getting-started/version-requirements and /graphos/connectors/reference/changelog. Use the latest Connectors spec that is generally available (not marked experimental) and compatible with that Federation LTS (https://specs.apollo.dev/connect/vX.Y).

The template above uses the current LTS: Federation v2.15 and Connectors v0.3. If the docs list a newer LTS, use the docs.

Reference Files

Before implementing connectors, read the relevant reference files:

Key Rules

Selection Mapping

  • Prefer sub-selections over ->map for cleaner mappings
  • Do NOT use $ when selecting fields directly from root
  • Field aliasing: newName: originalField (only when renaming)
  • Sub-selection: fieldName { ... } (to map nested content)
# 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

Entities

  • Add @connect on a type to make it an entity (no @key needed)
  • Create entity stubs in parent selections: user: { id: userId }
  • When you see an ID field (e.g., productId), create an entity relationship
  • Each entity should have ONE authoritative subgraph with @connect

Literal Values

Use $() wrapper for literal values in mappings:

$(1)              # number
$(true)           # boolean
$("hello")        # string
$({"a": "b"})     # object

# In body
body: "$({ a: $args.a })"  # CORRECT
body: "{ a: $args.a }"     # WRONG - will not compose

Headers

http: {
  GET: "/api"
  headers: [
    { name: "Authorization", value: "Bearer {$env.API_KEY}" },
    { name: "X-Forwarded", from: "x-client" }
  ]
}

Batching

Convert N+1 patterns using $batch:

type Product @connect(
  source: "api"
  http: {
    POST: "/batch"
    body: "ids: $batch.id"
  }
  selection: "id name"
) {
  id: ID!
  name: String
}

Ground Rules

  • NEVER make up syntax or directive values not in this specification
  • NEVER use --elv2-license accept (for humans only)
  • ALWAYS ask for example API responses before writing code
  • ALWAYS validate with rover supergraph compose after changes
  • ALWAYS create entity relationships when you see ID fields
  • Prefer $env over $config for environment variables
  • Use rover dev for running Apollo Router locally

apollographql의 다른 스킬

apollo-federation
apollographql
Apollo Federation은 여러 GraphQL API(서브그래프)를 하나의 통합된 슈퍼그래프로 구성할 수 있게 해줍니다.
apollo-ios
apollographql
Apollo iOS는 Apple 플랫폼을 위한 강력한 타입의 GraphQL 클라이언트입니다. GraphQL 작업과 스키마에서 Swift 타입을 생성하며, async/await 클라이언트, 정규화된 캐시(인메모리 또는 SQLite 기반), 쿼리, 뮤테이션 및 멀티파트 구독을 처리하는 플러그형 인터셉터 기반 HTTP 전송, 그리고 모든 작업 유형을 전달할 수 있는 선택적 WebSocket 전송(graphql-transport-ws)을 제공합니다.
apollo-router
apollographql
Apollo Router는 Apollo Federation 2 슈퍼그래프를 실행하기 위해 Rust로 작성된 고성능 그래프 라우터입니다. 서브그래프 앞에 위치하여 쿼리 계획, 실행 및 응답 구성을 처리합니다.
apollo-router-plugin-creator
apollographql
Apollo Router용 네이티브 Rust 플러그인을 생성합니다.
apollo-server
apollographql
Apollo Server 5.x를 활용한 GraphQL 서버 구축 완전 가이드. 스키마 정의, 리졸버, 컨텍스트 설정, TypeScript 지원을 통한 오류 처리를 다룹니다. 프로토타이핑을 위한 독립 실행 모드와 Express, Fastify, Koa, 서버리스 환경과의 통합을 지원합니다. 리졸버 패턴, 인증/권한 부여, 플러그인, N+1 문제 방지를 위한 DataLoader, 성능 최적화 기법을 포함합니다. 데이터 소스, 오류...에 대한 참조 문서를 제공합니다.
graphql-operations
apollographql
효율적이고 타입 안전한 GraphQL 작업을 작성하고 프래그먼트로 구성하기 위한 모범 사례 가이드입니다. 쿼리, 뮤테이션, 서브스크립션 및 프래그먼트를 다루며, 명명 규칙, 변수 구문, 지시어 사용법을 포함합니다. 핵심 원칙을 강조합니다: 필요한 필드만 요청하고, 모든 작업에 이름을 지정하며, 하드코딩된 값 대신 변수를 사용하고, 캐시 가능성을 위해 id 필드를 포함합니다. 컴포넌트와 함께 프래그먼트를 배치하고 조건부 필드에 @include / @skip 지시어를 사용할 것을 권장합니다...
graphql-schema
apollographql
업계 모범 사례 가이드로, 직관적이고 성능이 뛰어나며 유지보수 가능한 GraphQL 스키마 설계를 다룹니다. 클라이언트 중심의 타입 구성, 명시적 널 가능성 패턴, 하위 호환성을 고려한 진화 전략 등 핵심 설계 원칙을 포함합니다. 타입, 명명 규칙, 커서 기반 페이지네이션, 오류 모델링, 보안 고려 사항에 대한 참조 문서를 제공합니다. 인터페이스, 유니온, 입력 타입, 뮤테이션, ID 전략에 대한 실용적인 패턴과 코드 예제를 포함합니다...
rover
apollographql
Apollo Rover CLI는 GraphQL 스키마, 페더레이션 및 로컬 슈퍼그래프 개발을 관리합니다. 서브그래프 스키마를 게시, 가져오기 및 검증하고, 로컬 또는 GraphOS를 통해 페더레이티드 슈퍼그래프를 구성합니다. 스키마 검사(배포 전 검증), 린팅, 실행 중인 서버에서의 인트로스펙션을 포함합니다. rover dev 명령어는 자동 스키마 구성을 통해 개발 워크플로를 위한 로컬 라우터를 시작합니다. 게시 전 검증 및 JSON 출력을 통한 스크립팅을 지원하는 CI/CD 패턴을 지원합니다. 필요...