Example GraphQL Queries
Practical examples of GraphQL queries for fetching calls, signals, and documents from the BuildBetter API.
Example Queries
Below are example GraphQL queries for each major data type (calls, signals, and documents). These examples demonstrate how to retrieve data along with related fields like participants or metadata. You can run these queries against the GraphQL endpoint (replacing variables or IDs with real values) to test and get a feel for the responses. Each query is annotated with what it’s fetching:
Example 1: Fetching Recent Calls with Participants
The following query retrieves a list of recent calls in your organization, including each call’s basic info and its participants. It limits to 5 calls and orders them by start time (most recent first). It also fetches the call type and the names of attendees.
- Explanation: This query uses the
interview
field to list calls. We requestid
,name
, andstarted_at
for each call. The nestedtype
selection fetches the call’s type name (if types are used in your setup). Theattendees.person
nested selection fetches each participant’s first and last name. The result will be an array of up to 5 calls, each with a list of attendees. If you need more calls, adjust thelimit
or use pagination.
Example 2: Fetching Signals for a Call (with Context and Topics)
This query fetches all signals (extractions) for a specific call, given its ID. It retrieves details about each signal, including the summary, context snippet, timestamps, and associated type and topics. It also includes the speaker who said it (participant name).
- Explanation: We use a variable
$callId
to filterextraction
records for a specific call. The query returns signals sorted by their occurrence time in the call. For each signal, we get thesummary
andcontext
text. We also getstart_sec
andend_sec
which indicate when in the call the signal happens. Thetypes
array gives the category of the signal, andtopics
gives any tagged topics. Finally,attendee.person
provides the name of the participant who spoke that signal’s content. This query is useful to display a timeline of important points in a call along with who said them and what they are about.
Note: Replace $callId
with the actual call ID you want to inspect. If running via a GraphQL client, provide callId
in the query variables. Only signals from calls you have access to will be returned (others are filtered out by the server’s permissions).
Example 3: Fetching a Document with Source Calls
This query retrieves a specific document by ID, including its content, status, creator, and any source calls that were used to generate it. This is useful for getting an AI-generated summary and knowing which calls it covers.
- Explanation: We use the
document_by_pk
field to fetch a single document by its primary key (ID). For that document, we request itsname
,status
, andcontent
. We also get thecreated_at
timestamp and thecreator
(with the creator’s name). Theinput_data
array is included to list any calls that contributed to this document. For each related call, we fetch itsid
,name
, andstarted_at
. If the document was created from multiple calls, you will see multiple entries ininput_data
. If it was from a folder, thecall
field would be null and afolder
field might appear (not requested above for brevity).
To use this query, provide the document ID as the variable docId
. The response will give you the document’s content and relevant metadata. For example, you can display the document’s title, status (e.g., Completed or Processing), who created it, and list the calls that were summarized to create it.
These examples can be modified as needed – you can request additional fields or fewer fields depending on what you need for your application. Remember that GraphQL will only return the fields you ask for, so omitting fields can reduce payload size.