Skip to main content
To monitor loan changes, you’ll need to poll the GraphQL API at a cadence appropriate for your use case.

Quick reference

How it works

1

Write a focused query

Request only the fields you need. Don’t fetch the entire loan when you only need the stage.
2

Store the previous state

Cache the values you’re monitoring (e.g., currentStage, task IDs).
3

Poll at your chosen interval

Fetch the data and compare against your cached state.
4

Emit events on change

When a difference is detected, trigger your business logic.

Implementation example

This TypeScript example polls for loan stage changes every 30 minutes and emits an event when a stage changes.

Starter queries

Use these comprehensive queries as starting points. Trim them down to only the fields you need for your specific polling use case.
Full loan data including stages, pricing, rate lock, and associated entities.
Identity and contact details.
Complete financial profile for underwriting.
Debts and obligations for DTI calculation.
Borrower and loan officer tasks for workflow management.

Best practices

Use focused queries

Don’t fetch the entire loan object when you only need currentStage. Smaller queries are faster, reduce bandwidth, and make change detection simpler.

Implement exponential backoff

If requests fail, wait progressively longer before retrying. This prevents overwhelming the API during outages and gives transient issues time to resolve.

Store state efficiently

Only cache what you need for comparison. For stage monitoring, store a Map<loanId, stage> rather than full loan objects. This keeps memory usage low and simplifies the comparison logic.

Stagger requests for many loans

If monitoring hundreds of loans, don’t fire all requests simultaneously. Spread them over the polling interval to avoid rate limits and reduce peak load.

Use pagination cursors for lists

For lists like tasks or documents, track cursors to efficiently detect new items rather than comparing entire arrays. Store the last cursor and fetch only items after it.

Log polling activity

Keep logs of your polling activity for debugging. Include timestamps, loan IDs, and any detected changes. This helps diagnose issues when changes aren’t being detected as expected.

Rate limiting

Polling too aggressively can result in rate limiting. Start with conservative intervals and adjust based on your needs.
If you’re monitoring many loans:
  • Stagger requests rather than firing them simultaneously
  • Use longer intervals for less time-sensitive data
  • Implement circuit breakers to pause polling if you hit rate limits
  • Log all poll activity for debugging