Create SharePoint Feed
User Intent
Operation
Code Example (TypeScript)
import { Graphlit } from 'graphlit-client';
import {
FeedTypes,
FeedServiceTypes,
SharePointLibrariesInput,
SharePointFoldersInput,
} from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
const authorizationId = process.env.GRAPHLIT_SHAREPOINT_AUTH_ID!;
const sharePointAuth: SharePointLibrariesInput = {
authorizationId,
};
// Enumerate SharePoint document libraries first
const librariesResponse = await graphlit.querySharePointLibraries(sharePointAuth);
const libraries = librariesResponse.sharePointLibraries?.results ?? [];
if (libraries.length === 0) {
throw new Error('No SharePoint libraries available for the authorized account');
}
const { libraryId, libraryName } = libraries[0]!;
console.log(`Using SharePoint library: ${libraryName} (${libraryId})`);
// Optionally enumerate folders inside the library
const foldersResponse = await graphlit.querySharePointFolders(
{ authorizationId },
libraryId!,
);
const folders = foldersResponse.sharePointFolders?.results ?? [];
const targetFolderId = folders[0]?.folderId ?? undefined;
console.log(`Using SharePoint folder: ${folders[0]?.folderName ?? 'Root'} (${targetFolderId ?? 'root'})`);
const feed = await graphlit.createFeed({
name: 'Engineering SharePoint',
type: FeedTypes.Site,
site: {
type: FeedServiceTypes.SharePoint,
authorizationId,
libraryId: libraryId!,
folderId: targetFolderId,
includeSubfolders: true,
fileTypes: ['pdf', 'docx', 'xlsx'],
readLimit: 500,
},
// Optional: add workflow for content processing
// workflow: { id: workflow.createWorkflow.id }
});
console.log(`Created SharePoint feed: ${feed.createFeed.id}`);Configuration
OAuth Setup
What Gets Synced
Last updated