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:
- Query templates: Define GraphQL queries with variable interpolation
- Variables: Pass variables to queries from config/state/parent records
- Cursor pagination: Support
endCursor/hasNextPage pagination pattern
- Record extraction: Extract records from nested
edges/nodes structure
- 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
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-githubimplement custom GraphQL query builders and pagination logic in Python. See:source-github/graphql.py- Custom GraphQL query buildersource-github/streams.py- Streams using GraphQL (ProjectsV2, Reviews, Reactions)Proposed Solution
Add a declarative
GraphQLRequestercomponent that supports:endCursor/hasNextPagepagination patternedges/nodesstructureerrorsfieldExample Configuration
Impact
This would enable connectors using GraphQL APIs (GitHub, GitLab, Shopify, etc.) to be fully declarative while maintaining their GraphQL functionality.
Related
Code References
source-github/graphql.py- GraphQL query builder implementationsource-github/streams.py:1485-1580- ProjectsV2 stream using GraphQL