GraphQL Example: Fetching Transcript IDs from Fireflies

This example demonstrates how to use GraphQL within the ForgeFX Tools Collection to fetch all transcript IDs from Fireflies.ai. It showcases a simple query that retrieves only the necessary data.

The Query

query GetAllTranscriptIds {
  transcripts(first: 100) {
    edges {
      node {
        id
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

This query does the following:

  1. Requests the first 100 transcripts (adjust this number as needed).
  2. For each transcript, it only retrieves the id.
  3. Includes pageInfo for pagination if there are more than 100 transcripts.

Using the Query in ForgeFX Tools

Here’s how you might use this query in a ForgeFX tool:

import { GraphQLClient, gql } from 'graphql-request';
 
const query = gql`
  query GetAllTranscriptIds {
    transcripts(first: 100) {
      edges {
        node {
          id
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
`;
 
async function fetchTranscriptIds() {
  const client = new GraphQLClient('https://api.fireflies.ai/graphql', {
    headers: {
      Authorization: `Bearer ${YOUR_API_KEY}`,
    },
  });
 
  try {
    const data = await client.request(query);
    
    // Extract and log the transcript IDs
    const transcriptIds = data.transcripts.edges.map(edge => edge.node.id);
    console.log('Transcript IDs:', transcriptIds);
 
    // Check if there are more pages
    if (data.transcripts.pageInfo.hasNextPage) {
      console.log('There are more transcripts. Implement pagination to fetch them all.');
    }
 
  } catch (error) {
    console.error('Error fetching transcript IDs:', error);
  }
}
 
fetchTranscriptIds();

This example shows how to fetch just the transcript IDs using GraphQL. It’s a simple query that demonstrates the efficiency of GraphQL in retrieving only the specific data you need. If you have more than 100 transcripts, you’ll need to implement pagination to fetch all IDs.