GraphQL Data Connect SDK - Python Implementation
Complete GraphQL server for ingesting customer credit history from external data providers and feeding it to the RAG pipeline with automatic Shopify B2B company mapping.
Features
✅ GraphQL Server with Strawberry GraphQL
✅ Data Provider Connectors for external GraphQL APIs
✅ Shopify B2B Company Registry with auto-creation
✅ RAG Pipeline Integration with LangChain documents
✅ PostgreSQL Storage with optimized indexes
✅ Credit History Analytics with aggregated views
✅ Multi-Provider Support with connector framework
Quick Start
1. Access GraphiQL IDE
Navigate to http://localhost:5000/graphql/credit-history in your browser to access the interactive GraphQL playground.
2. Example Queries
Fetch Credit History
query GetCreditHistory {
creditHistory(
companyId: "ext_company_123"
startDate: "2025-01-01T00:00:00Z"
limit: 50
) {
totalCount
edges {
node {
id
companyId
shopifyCompanyId
email
date
inflow
outflow
reference
bank
currency
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
Get Company Summary
query GetCompanySummary {
companyCreditSummary(
shopifyCompanyId: "gid://shopify/Company/12345"
)
}
3. Example Mutations
Ingest Credit History
mutation IngestCreditHistory {
ingestCreditHistory(
providerId: "provider_1"
companyId: "ext_company_123"
enrichShopify: true
records: [
{
companyId: "ext_company_123"
email: "finance@acmecorp.com"
date: "2025-01-15T10:30:00Z"
reference: "Invoice payment - INV-2025-001"
inflow: 50000.00
outflow: 0.00
accountName: "Acme Corporation Ltd"
accountNumber: "****1234"
bank: "First National Bank"
currency: "USD"
}
]
) {
success
recordsProcessed
recordsEnriched
shopifyCompaniesCreated
errors
}
}
Trigger Provider Sync
mutation TriggerSync {
triggerProviderSync(
providerId: "provider_1"
companyId: "ext_company_123"
startDate: "2025-01-01T00:00:00Z"
) {
success
recordsProcessed
recordsEnriched
shopifyCompaniesCreated
errors
}
}
Architecture
┌──────────────────────┐
│ External Provider │
│ GraphQL API │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ Data Provider │
│ Connector │
│ (Extract & Transform)
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ Shopify Company │
│ Registry │
│ (Map/Create) │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ Credit History │
│ RAG Loader │
│ (LangChain Docs) │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ Analytics RAG │
│ Pipeline │
│ (Groq LLM) │
└──────────────────────┘
Components
1. GraphQL Schema (credit_history_schema.py)
- Strawberry GraphQL types and schema
- Queries:
creditHistory,companyCreditSummary - Mutations:
ingestCreditHistory,triggerProviderSync
2. Data Provider Connector (data_provider_connector.py)
- Abstract connector framework
- Generic GraphQL provider implementation
- Provider registry for multi-source support
3. Shopify Company Registry (shopify_company_registry.py)
- External ID → Shopify B2B company ID mapping
- Auto-creation of missing companies
- Database caching with 1-hour TTL
4. RAG Loader (credit_history_rag_loader.py)
- PostgreSQL storage with deduplication
- LangChain document creation
- Credit history analytics summaries
5. GraphQL Resolvers (credit_history_resolvers.py)
- Query and mutation resolvers
- ETL pipeline orchestration
- Error handling and validation
Database Schema
Tables
company_id_mappings
- Maps external company IDs to Shopify B2B company GIDs
- Prevents duplicate company creation
credit_history
- Stores all credit transactions
- Indexed by company, date, provider
- JSONB metadata for provider-specific fields
data_provider_configs
- Registry of configured data providers
- Encrypted API keys
- Active/inactive status
Views
credit_history_summary
- Aggregated metrics by company and currency
- Total inflow, outflow, net position
- Transaction counts and date ranges
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/graphql/credit-history |
POST | GraphQL API endpoint |
/graphql/credit-history |
GET | GraphiQL IDE |
Security
🔒 Data Protection
- TLS 1.2+ for all API connections
- Encrypted API keys in database
- Field-level encryption for account numbers
- Audit logs for data access
🔐 Authentication
- API key authentication for data providers
- OAuth client credentials support
- Session-based auth for GraphiQL
Environment Variables
# Database
DATABASE_URL=postgresql://user:pass@host:5432/db
# Shopify
SHOPIFY_ADMIN_API_KEY=your_admin_api_key
SHOPIFY_SHOP_NAME=your-shop.myshopify.com
# Data Provider (example)
PROVIDER_API_URL=https://provider.example.com/graphql
PROVIDER_API_KEY=your_provider_api_key
Next Steps
-
Register Data Provider
from sdk.python.data_provider_connector import DataProviderRegistry registry = DataProviderRegistry() registry.register_provider( provider_id="my_provider", api_url="https://provider.example.com/graphql", api_key="your_api_key" )
-
Query Credit History via GraphQL
- Use GraphiQL IDE or POST to
/graphql/credit-history
- Use GraphiQL IDE or POST to
-
Integrate with Analytics Agent
- Credit history automatically available in RAG pipeline
- Query via analytics_agent for AI-powered insights
Troubleshooting
Issue: GraphQL queries return empty results
Solution: Check that records have been ingested and shopify_company_id is enriched
Issue: Company auto-creation fails
Solution: Verify Shopify Admin API credentials and write_companies scope
Issue: Provider sync fails
Solution: Validate provider GraphQL schema matches expected structure
Support
For issues or questions:
- Check GraphiQL IDE error messages
- Review database logs in PostgreSQL
- Verify provider API connectivity
- Ensure Shopify B2B company exists
Built with ❤️ using Strawberry GraphQL, LangChain, and FastAPI
Release files for huntrecht-sdk 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| huntrecht_sdk-0.1.9.tar.gz | 16.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| huntrecht_sdk-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.9 kB
Release files / huntrecht_sdk-0.1.9.tar.gz
| Download URL | huntrecht_sdk-0.1.9.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f56df6a7ff11af504f7abb4d7d84a8ca0b9d527a060ab965cf445e95ca4ed8b
|
|
BLAKE2b-256 checksum How to use checksums |
af661883fa20af4016738ba9dea10b6633665f543d52972eb23eb3851448e4b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / huntrecht_sdk-0.1.9-py3-none-any.whl
| Download URL | huntrecht_sdk-0.1.9-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
521fbc531630f2abd2b6312fd0a7631cd4bb82d62dd8585bbeddaa95442067b7
|
|
BLAKE2b-256 checksum How to use checksums |
40d2685bbf38f80c6f289ed51de518cd28585fbca5f0fc910a195d02da1d2a9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency log