Skip to content

Declarative: GraphQL requester with cursor pagination #836

@devin-ai-integration

Description

@devin-ai-integration

Problem

Many APIs use GraphQL instead of REST, but the declarative CDK only supports REST API requests. Connectors that need GraphQL must implement custom Python components, preventing them from being fully declarative (manifest-only).

Current Workaround

Connectors like source-github implement custom GraphQL query builders and pagination logic in Python. See:

Proposed Solution

Add a declarative GraphQLRequester component that supports:

  1. Query templates: Define GraphQL queries with variable interpolation
  2. Variables: Pass variables to queries from config/state/parent records
  3. Cursor pagination: Support endCursor/hasNextPage pagination pattern
  4. Record extraction: Extract records from nested edges/nodes structure
  5. Error handling: Handle GraphQL-specific errors in the errors field

Example Configuration

retriever:
  type: GraphQLRetriever
  url_base: "https://api.github.com"
  path: "/graphql"
  authenticator:
    type: BearerAuthenticator
    api_token: "{{ config.access_token }}"
  query_template: |
    query($owner: String!, $name: String!, $cursor: String) {
      repository(owner: $owner, name: $name) {
        issues(first: 100, after: $cursor) {
          pageInfo {
            hasNextPage
            endCursor
          }
          edges {
            node {
              id
              title
              state
              createdAt
            }
          }
        }
      }
    }
  variables:
    owner: "{{ stream_slice.owner }}"
    name: "{{ stream_slice.name }}"
    cursor: "{{ next_page_token }}"
  record_selector:
    extractor:
      field_path: ["data", "repository", "issues", "edges", "node"]
  paginator:
    type: GraphQLCursorPaginator
    page_info_path: ["data", "repository", "issues", "pageInfo"]
    cursor_field: "endCursor"
    has_next_page_field: "hasNextPage"

Impact

This would enable connectors using GraphQL APIs (GitHub, GitLab, Shopify, etc.) to be fully declarative while maintaining their GraphQL functionality.

Related

Code References

Metadata

Metadata

Labels

manifest-only feature gapsMissing capabilities that prevent connectors from being fully declarative (manifest-only)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions