Create Google Drive Feed

Feed: Create Google Drive Feed

User Intent

"I want to sync my Google Drive files into Graphlit for search and AI interactions"

Operation

  • SDK Method: graphlit.createFeed() with Google Drive configuration

  • GraphQL: createFeed mutation

  • Entity Type: Feed

  • Common Use Cases: Google Drive sync, document search, file monitoring, team knowledge base

TypeScript (Canonical)

import { Graphlit } from 'graphlit-client';
import {
  ContentTypes,
  FeedInput,
  FeedServiceTypes,
  FeedTypes,
  FileTypes,
  SearchTypes,
} from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

// Create Google Drive feed
const feedInput: FeedInput = {
  name: 'Company Google Drive',
  type: FeedTypes.Site,
  site: {
    type: FeedServiceTypes.GoogleDrive,
    googleDrive: {
      refreshToken: process.env.GOOGLE_REFRESH_TOKEN!,
      folderIds: ['folder-id'],
      includeFiles: true,
    },
  },
};

const response = await graphlit.createFeed(feedInput);
const feedId = response.createFeed.id;

console.log(`Google Drive feed created: ${feedId}`);

// Poll for initial sync completion
while (true) {
  const status = await graphlit.isFeedDone(feedId);
  if (status.isFeedDone.result) {
    break;
  }
  console.log('Still syncing Google Drive files...');
  await new Promise((resolve) => setTimeout(resolve, 10_000));
}

console.log('Google Drive feed sync complete!');

// Query synced files
const files = await graphlit.queryContents({
  feeds: [{ id: feedId }],
  types: [ContentTypes.File],
});

console.log(`Synced ${files.contents.results.length} files from Google Drive`);

Create feed (snake_case)

feed_input = FeedInput( name="Company Google Drive", type=FeedTypes.Site, site=SiteFeedPropertiesInput( type=FeedServiceTypes.GoogleDrive, include_files=True, folder_ids=["folder-id-1", "folder-id-2"], refresh_token=os.environ["GOOGLE_REFRESH_TOKEN"] ) )

response = await graphlit.createFeed(feed_input) feed_id = response.createFeed.id

Poll for completion

is_done = False while not is_done: status = await graphlit.isFeedDone(feed_id) is_done = status.isFeedDone.result if status.isFeedDone else False

Parameters

FeedInput (Required)

  • name (string): Feed name

  • type (FeedTypes): Must be GOOGLE

  • google (GoogleFeedPropertiesInput): Google Drive configuration

GoogleFeedPropertiesInput (Required)

  • type (FeedServiceTypes): Must be GOOGLE_DRIVE

  • refreshToken (string): Google OAuth refresh token

    • Requires Google Drive API access

    • Scopes: https://www.googleapis.com/auth/drive.readonly

  • includeFiles (boolean): Sync files (recommended: true)

  • folderIds (string[]): Specific folders to sync

    • Empty array = sync entire drive (not recommended for large drives)

    • Get folder IDs from Google Drive URLs

Optional

  • correlationId (string): For tracking

  • collections (EntityReferenceInput[]): Auto-add files to collections

  • workflow (EntityReferenceInput): Apply workflow to files

Response

Developer Hints

OAuth Refresh Token Required

Getting Google OAuth Token:

  1. Create Google Cloud project at https://console.cloud.google.com

  2. Enable Google Drive API

  3. Create OAuth 2.0 credentials

  4. Required scope: https://www.googleapis.com/auth/drive.readonly

  5. Exchange authorization code for refresh token

  6. Store refresh token securely

Important: Never commit refresh tokens to source control.

Folder ID Discovery

Getting Folder IDs:

Example:

File Type Filtering

Continuous Sync

Important: Feeds run continuously. To stop syncing, disable or delete the feed.

Variations

1. Sync Entire Drive

Sync all files (use carefully):

2. Sync Specific Folders

Target specific folders:

3. Sync with Auto-Collection

Add files to collection automatically:

4. Sync with Workflow

Apply preparation workflow to files:

5. Team-Specific Feeds

Create feeds per team:

6. Query Synced Files

Search through synced Google Drive files:

Common Issues

Issue: Invalid token error Solution: Refresh token expired or invalid. Re-authenticate and get new refresh token. Ensure correct Google Drive API scopes.

Issue: No files syncing Solution: Check includeFiles: true is set. Verify folder IDs are correct. Check OAuth token has Drive access.

Issue: Folder not found error Solution: Verify folder IDs from Drive URLs. Ensure OAuth account has access to folders.

Issue: Feed syncs slowly Solution: This is normal for large folders. Use isFeedDone() to poll. Initial sync can take 10-30 minutes for hundreds of files.

Issue: Some files missing Solution: Check file permissions. OAuth account must have read access to all files in folder.

Production Example

Complete Google Drive sync pipeline:

Multi-folder organization:

Last updated

Was this helpful?