Skip to main content

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

  1. 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"
    )
    
  2. Query Credit History via GraphQL

    • Use GraphiQL IDE or POST to /graphql/credit-history
  3. 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:

  1. Check GraphiQL IDE error messages
  2. Review database logs in PostgreSQL
  3. Verify provider API connectivity
  4. Ensure Shopify B2B company exists

Built with ❤️ using Strawberry GraphQL, LangChain, and FastAPI

Metadata

Release files for huntrecht-sdk 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for huntrecht-sdk 0.3.1
File Size Uploaded Provenance Actions
huntrecht_sdk-0.3.1.tar.gz 18.4 kB With provenance Details for huntrecht_sdk-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for huntrecht-sdk 0.3.1
File Interpreter ABI Platform Actions
huntrecht_sdk-0.3.1-py3-none-any.whl Python 3 none any Details for huntrecht_sdk-0.3.1-py3-none-any.whl

Total release size: 39.5 kB

Release files / huntrecht_sdk-0.3.1.tar.gz

Download URL huntrecht_sdk-0.3.1.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
730b0889f0bb3eacae944d7a982fa41f00ce96143e929dffc0f8da72b77497a9
BLAKE2b-256 checksum
How to use checksums
5c411cb0883aa9d8287b85be9edc227eeaa4ace161d180f00848c8e27ab4c0df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

Release files / huntrecht_sdk-0.3.1-py3-none-any.whl

Download URL huntrecht_sdk-0.3.1-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1821a49af08d686a5b4cefab4a50f6bcad7af3505ad48667541c62b724825961
BLAKE2b-256 checksum
How to use checksums
86b9e5beb90dbbc9a0568882f4403282c8a38de48903b918221d1977e6c7aded
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

Security for huntrecht-sdk 0.3.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for huntrecht_sdk-0.3.1.tar.gz

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 Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page