Skip to main content

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.

Optimizing Didit API Calls with GraphQL Federated Queries

Contents

In this guide

Jump to the part you need.

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 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 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.

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alberto Rosas

Co-founder and CEO

Alberto Rosas

Alberto Rosas

Co-founder and CEO

About Didit

Questions

Blog questions

Who writes the Didit blog?
The Didit team. Guides reviewed by Alberto Rosas, co-founder and CEO, carry his byline. The rest are published as Didit.
Which topics does the blog cover?
Eight topics: ID verification, business verification (KYB), AML, sanctions and compliance, fraud prevention, transaction monitoring and crypto, country guides, agents and developers, and product updates.
Is the blog available in my language?
Yes, in 15 languages: English, Spanish, French, German, Brazilian and European Portuguese, Catalan, Russian, Arabic, Chinese, Japanese, Hindi, Indonesian, Korean and Swahili. Not every post is translated, so each language shows the posts it has.
Where do I find product updates?
In the changelog at /changelog/ and under the Product updates topic.
Are these posts legal advice?
No. Regulation posts explain rules; your legal team decides how they apply.
How do I find posts on one topic?
Open one of the eight topics, or search the blog.
Are posts dated?
Yes. Every post shows when it was published and when it was last updated.
Do posts link to the docs?
Developer posts link to the matching page on docs.didit.me and to the API reference.
Is the blog the same as the docs?
No. The blog explains rules, markets and product changes for a general reader, while docs.didit.me holds the integration guides and the API reference. Developer posts link the matching docs page and the API reference they describe.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.