Skip to main content
Didit Raises $7.5M to Build the Infrastructure for Identity and Fraud
Didit
Back to blog
Blog · March 7, 2026

Optimizing Didit API Calls with GraphQL Federated Queries

Discover how GraphQL federated queries can dramatically cut costs and boost performance when interacting with the Didit API. Learn about reducing over-fetching, minimizing network latency, and streamlining data retrieval for.

By DiditUpdated
optimizing-didit-api-calls-with-graphql-federated-queries.png

Streamline Data RetrievalGraphQL federated queries allow you to request precisely the data you need from multiple services in a single API call, eliminating over-fetching and under-fetching common in REST APIs.

Reduce Network OverheadBy consolidating multiple requests into one, federated queries significantly decrease the number of round trips between your application and the Didit API, leading to lower latency and faster response times.

Enhance Cost-EfficiencyFewer API calls and reduced data transfer translate directly into lower operational costs, as you only pay for the resources and data consumed, optimizing your identity verification spending.

Didit's Modular AdvantageDidit's open, modular identity platform is uniquely positioned to benefit from GraphQL federated queries, allowing seamless integration and orchestration of various identity primitives like ID Verification, Liveness, and AML Screening through a unified interface.

The Challenge of Traditional API Interactions

In the world of identity verification, applications often need to retrieve various pieces of information about a user or a verification session. Traditional RESTful APIs can sometimes lead to inefficiencies. For instance, you might make one call to initiate an ID Verification session, another to check its status, and yet another to fetch the decision and associated data. This can result in several common problems:

  • Over-fetching: APIs often return more data than your application actually needs, wasting bandwidth and processing power.
  • Under-fetching: Conversely, a single API call might not provide all the necessary data, forcing your application to make multiple subsequent requests.
  • Multiple Round Trips: Each API call incurs network latency, and making many calls in sequence can significantly slow down your application's performance.
  • Increased Cost: Many API providers, including identity verification services, charge based on the number of calls or the volume of data transferred. Inefficient API usage can lead to unexpected costs.

For a platform like Didit, which offers a rich suite of identity primitives including ID Verification (OCR, MRZ, barcodes), Passive & Active Liveness, 1:1 Face Match & Face Search, and AML Screening & Monitoring, efficiently retrieving and combining data across these services is paramount. This is where GraphQL, particularly with a federated approach, offers a powerful solution.

Introducing GraphQL Federated Queries for Identity Verification

GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. It allows clients to specify exactly what data they need, and nothing more. When applied to a complex ecosystem like identity verification, GraphQL federated queries enable you to combine data from multiple underlying services (subgraphs) into a single, unified API. This means you can:

  • Request Specific Data: Instead of receiving a fixed data structure, you define the exact fields your application requires. For example, when checking the result of a Didit ID Verification, you might only need the verification status, the user's name, and the document expiry date, not every single field extracted.
  • Consolidate Requests: Combine queries for different aspects of identity into one. Imagine needing a user's verification decision, their AML screening status, and their proof of address details. With federation, these could all be fetched in a single query, even if they originate from different internal Didit microservices.
  • Optimize for Performance: By reducing the number of requests and the amount of data transferred, your application's load times and responsiveness improve dramatically. This is especially crucial for user-facing flows where every millisecond counts.

For example, you could query for a session's decision (GET /v3/session/{id}/decision/) and simultaneously fetch related user attributes or the status of an associated AML check, all in one go, instead of making separate calls.

Practical Strategies for Implementation

Implementing GraphQL federated queries with Didit's API involves a few key steps:

  1. Define Your Schema: Start by defining a GraphQL schema that represents the data you need from Didit's various services. This schema acts as a contract between your client and your API gateway.
  2. Build a Gateway/Orchestration Layer: Set up a GraphQL gateway (e.g., Apollo Federation Gateway) that understands your unified schema. This gateway will then route parts of the incoming GraphQL query to the appropriate Didit API endpoints or internal microservices.
  3. Map to Didit's REST Endpoints: Within your gateway's resolvers, map the GraphQL fields to the corresponding Didit REST API calls. For instance, a sessionStatus field in GraphQL might resolve by calling Didit's GET /v3/session/{id}/decision/ endpoint.
  4. Leverage Didit's Modular APIs: Didit offers a highly modular architecture. This means individual identity checks like Age Estimation, Phone & Email Verification, or NFC Verification can be integrated as distinct services within your federated graph, providing granular control and efficiency.
  5. Monitor and Iterate: Use tools to monitor your GraphQL gateway's performance and the efficiency of your queries. Optimize resolvers and schema definitions as needed to ensure maximum cost and performance benefits.

Consider a scenario where you need to verify a user's age and run an AML check. Instead of two separate API calls, a single federated GraphQL query could retrieve both results, significantly streamlining your workflow and reducing latency. This is particularly valuable for applications in regulated industries or those requiring rapid onboarding processes.

Cost and Performance Benefits

The advantages of using GraphQL federated queries with a platform like Didit extend beyond just cleaner code:

  • Reduced API Call Volume: By consolidating requests, you naturally decrease the total number of API calls made to Didit, which can directly impact costs if you're on a usage-based pricing model.
  • Lower Data Transfer Costs: Requesting only the necessary data minimizes bandwidth consumption, leading to lower data transfer costs, especially critical in cloud environments.
  • Improved User Experience: Faster data retrieval means quicker load times and more responsive applications, enhancing the overall user experience during critical identity verification steps.
  • Simplified Client Development: Client applications can interact with a single, consistent GraphQL endpoint, abstracting away the complexities of multiple underlying REST APIs. This simplifies development and maintenance.
  • Enhanced Scalability: An optimized API interaction model allows your application to scale more efficiently, handling higher traffic volumes without proportional increases in infrastructure or API costs.

Didit's Free Core KYC and pay-per-successful check model already offer significant cost advantages, and integrating with GraphQL federated queries amplifies these benefits by ensuring you're only paying for precisely what you consume and need.

How Didit Helps

Didit is an AI-native, developer-first identity platform built with an open, modular architecture, making it an ideal candidate for integration with GraphQL federated queries. Our clean APIs and comprehensive documentation mean that mapping our services to your GraphQL schema is straightforward. Whether you're leveraging our ID Verification for document checks, Passive & Active Liveness for fraud prevention, AML Screening & Monitoring for compliance, or Proof of Address for address verification, each component can be seamlessly integrated into your federated graph.

Our commitment to a modular design allows developers to pick and choose the exact identity primitives they need, orchestrate them into custom workflows, and then efficiently query the results. With Didit, you benefit from Free Core KYC, transparent pay-per-successful-check pricing, and no setup fees, ensuring that your pursuit of cost and performance optimization with GraphQL is both effective and economical. Didit provides the building blocks for an efficient, scalable, and secure identity infrastructure that GraphQL federated queries can expose and manage with unparalleled efficiency.

Ready to Get Started?

Ready to see Didit in action? Get a free demo today.

Start verifying identities for free with Didit's free tier.

Infrastructure for identity and fraud.

One API for KYC, KYB, Transaction Monitoring, and Wallet Screening. Integrate in 5 minutes.

Ask an AI to summarise this page
Optimize Didit API Calls with GraphQL Federated Queries.