Last updated

GraphQL Analytics Tutorial

Use Papr GraphQL to run structured analysis on your memory graph.

Scenario

Natural-language search helps find context. GraphQL helps compute structured insights for dashboards, reporting, and agent reasoning.

What You Will Build

  • A GraphQL query workflow
  • Filtered and aggregated insight extraction
  • A pattern for combining retrieval with analytics

Prerequisites

  • Papr API key
  • Existing memories in your workspace

Step 1: Execute a GraphQL Query

curl -X POST https://memory.papr.ai/v1/graphql \
  -H "X-API-Key: $PAPR_MEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Client-Type: curl" \
  -d '{
    "query": "query { nodes(type: \"Task\") { id properties } }"
  }'

Step 2: Scope by Tenant or User

Use tenant-aware writes and searches first (organization_id, namespace_id) so GraphQL analysis reflects correct boundaries.

Step 3: Combine with Retrieval

  1. Use /v1/memory/search to find relevant context cluster.
  2. Use GraphQL to compute structured summaries over related entities.
  3. Return both to downstream agent logic.

Python Example

import os
from papr_memory import Papr

client = Papr(x_api_key=os.environ.get("PAPR_MEMORY_API_KEY"))

result = client.graphql.query(
    query="""
    query {
      nodes(type: "Opportunity") {
        id
        properties
      }
    }
    """
)

print(result)

Common Patterns

  • Entity inventory by type
  • Relationship-centric drilldowns
  • Topic-based operational snapshots
  • Agent-readable structured summaries

Production Notes

  • Keep GraphQL queries versioned in your app repository.
  • Validate query latency under realistic dataset size.
  • Pair analytics queries with retrieval quality checks.

Next Steps