Graphlit Platform
Developer PortalChangelogPlatform StatusMore InformationJoin Discord
  • Graphlit Platform
    • What is Graphlit?
    • Key Concepts
  • Getting Started
    • Sign up for Graphlit
    • Create Graphlit Project
    • For Python Developers
    • For Node.js Developers
    • For .NET Developers
  • 🚀Quickstart
    • Next.js applications
      • GitHub Code
    • Python applications
      • GitHub Code
  • Graphlit Data API
    • API Usage
      • API Endpoints
      • API Authentication
      • API Explorer
      • GraphQL 101
    • API Reference
      • Content
        • Ingest With Workflow
        • Ingest File
        • Ingest Encoded File
        • Ingest Web Page
        • Ingest Text
        • Semantic Search
          • Query All Content
          • Query Facets
          • Query By Name
          • Filter By Contents
        • Metadata Filtering
          • Filter By Observations
          • Filter By Feeds
          • Filter By Collections
          • Filter By Content Type
          • Filter By File Type
          • Filter By File Size Range
          • Filter By Date Range
        • Summarize Contents
        • Extract Contents
        • Publish Contents
      • Knowledge Graph
        • Labels
        • Categories
        • Persons
        • Organizations
        • Places
        • Events
        • Products
        • Repos
        • Software
      • Collections
      • Feeds
        • Create Feed With Workflow
        • Create RSS Feed
        • Create Podcast Feed
        • Create Web Feed
        • Create Web Search Feed
        • Create Reddit Feed
        • Create Notion Feed
        • Create YouTube Feed
        • User Storage Feeds
          • Create OneDrive Feed
          • Create Google Drive Feed
          • Create SharePoint Feed
        • Cloud Storage Feeds
          • Create Amazon S3 Feed
          • Create Azure Blob Feed
          • Create Azure File Feed
          • Create Google Blob Feed
        • Messaging Feeds
          • Create Slack Feed
          • Create Microsoft Teams Feed
          • Create Discord Feed
        • Email Feeds
          • Create Google Mail Feed
          • Create Microsoft Outlook Feed
        • Issue Feeds
          • Create Linear Feed
          • Create Jira Feed
          • Create GitHub Issues Feed
        • Configuration Options
      • Workflows
        • Ingestion
        • Indexing
        • Preparation
        • Extraction
        • Enrichment
        • Actions
      • Conversations
      • Specifications
        • Azure OpenAI
        • OpenAI
        • Anthropic
        • Mistral
        • Groq
        • Deepseek
        • Replicate
        • Configuration Options
      • Alerts
        • Create Slack Audio Alert
        • Create Slack Text Alert
      • Projects
    • API Changelog
    • Multi-tenant Applications
  • JSON Mode
    • Overview
    • Document JSON
    • Transcript JSON
  • Content Types
    • Files
      • Documents
      • Audio
      • Video
      • Images
      • Animations
      • Data
      • Emails
      • Code
      • Packages
      • Other
    • Web Pages
    • Text
    • Posts
    • Messages
    • Emails
    • Issues
  • Data Sources
    • Feeds
  • Platform
    • Developer Portal
      • Projects
    • Cloud Platform
      • Security
      • Subprocessors
  • Resources
    • Community
Powered by GitBook
On this page
  • Overview
  • Operations

Was this helpful?

  1. Graphlit Data API
  2. API Reference

Collections

Create, manage and query Collections.

Last updated 1 year ago

Was this helpful?

Overview

In Graphlit, content can be grouped into collections, which can contain one or more pieces of content. Content can be added to multiple collections, so it is different than a classic file/folder hierarchy.

For example, you may have a collection of PDFs named "Favorite Research Papers", and a collection of Word documents, PDFs and markdown files named "July uploads", and the same PDF can be a member of both collections.

Collections are named, but the name is not required to be unique across the Graphlit project. Each collection has a unique id field, in format.

Collections are created in the OPENED state, which means that content can be added to or removed from it. See the closeCollection mutation for the ability to close (or lock) the collection, so no content can be added/removed.

Operations

Create Collection

The createCollection mutation enables the creation of a collection by accepting the collection name and it returns essential details, including the ID, name, state, and type of the newly generated collection.

Mutation:

mutation CreateCollection($collection: CollectionInput!) {
  createCollection(collection: $collection) {
    id
    name
    state
    type
  }
}

Variables:

{
  "collection": {
    "name": "Documents"
  }
}

Response:

{
  "type": "COLLECTION",
  "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
  "name": "Documents",
  "state": "OPENED"
}
Update Collection

The updateCollection mutation enables the renaming of a collection by accepting the collection name.

Mutation:

mutation UpdateCollection($collection: CollectionUpdateInput!) {
  updateCollection(collection: $collection) {
    id
    name
    state
    type
  }
}

Variables:

{
  "collection": {
    "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
    "name": "My Documents"
  }
}

Response:

{
  "type": "COLLECTION",
  "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
  "name": "My Documents",
  "state": "OPENED"
}
Delete Collection

The deleteCollection mutation allows the deletion of a collection by utilizing the id parameter, and it returns the ID and state of the deleted collection.

This does not delete the contents contained by the collection, only the collection itself.

Mutation:

mutation DeleteCollection($id: ID!) {
  deleteCollection(id: $id) {
    id
    state
  }
}

Variables:

{
  "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149"
}

Response:

{
  "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
  "state": "DELETED"
}
Add Contents to Collections

Using the addContentsToCollections mutation, you can add contents to one or more collections by supplying the collections parameter for the array of entity references for the target collections and the contents parameter, which expects an array of entity references. It returns an array, containing the ID, name, state, type, and the relevant details of the added contents within each collection.

Mutation:

mutation AddContentsToCollections($contents: [EntityReferenceInput!]!, $collections: [EntityReferenceInput!]!) {
  addContentsToCollections(contents: $contents, collections: $collections) {
    id
    name
    state
    type
    contents {
      id
      name
    }
  }
}

Variables:

{
  "contents": [
    {
      "id": "113fd754-1afc-4c12-be4f-abab35385690"
    }
  ],
  "collections": [
    {
      "id": "6ca126e7-7f1e-40ed-8911-1fd89f3f9323"
    }
  ]
}

Response:

[
  {
    "type": "COLLECTION",
    "contents": [
      {
        "id": "113fd754-1afc-4c12-be4f-abab35385690",
        "name": "main.docx"
      }
    ],
    "id": "6ca126e7-7f1e-40ed-8911-1fd89f3f9323",
    "name": "My Documents",
    "state": "OPENED"
  }
]
Remove Contents from Collection

Through the removeContentsFromCollection mutation, you can remove specific contents from a collection by providing the entity reference for the targeted collection and the contents parameter, which expects an array of entity references. Upon execution, it returns the ID, name, state, type, and the pertinent details of the removed contents within the collection.

Mutation:

mutation RemoveContentsFromCollection($contents: [EntityReferenceInput!]!, $collection: EntityReferenceInput!) {
  removeContentsFromCollection(contents: $contents, collection: $collection) {
    id
    name
    state
    type
    contents {
      id
      name
    }
  }
}

Variables:

{
  "contents": [
    {
      "id": "113fd754-1afc-4c12-be4f-abab35385690"
    }
  ],
  "collection": {
    "id": "6ca126e7-7f1e-40ed-8911-1fd89f3f9323"
  }
}

Response:

{
  "type": "COLLECTION",
  "contents": [],
  "id": "6ca126e7-7f1e-40ed-8911-1fd89f3f9323",
  "name": "My Documents",
  "state": "OPENED"
}
Get Collection

The collection query allows you to retrieve specific details of a collection by providing the id parameter, including the ID, name, creation date, state, owner ID, and type associated with the collection.

Query:

query GetCollection($id: ID!) {
  collection(id: $id) {
    id
    name
    creationDate
    state
    owner {
      id
    }
    type
  }
}

Variables:

{
  "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149"
}

Response:

{
  "type": "COLLECTION",
  "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
  "name": "My Documents",
  "state": "OPENED",
  "creationDate": "2023-07-02T19:26:52Z",
  "owner": {
    "id": "9422b73d-f8d6-4faf-b7a9-152250c862a4"
  }
}
Query Collections

Query Collections

The collections query allows you to retrieve all collections. It returns a list of collection results, including the ID, name, creation date, state, owner ID, and type for each collection.

Query:

query QueryCollections($filter: CollectionFilter!) {
  collections(filter: $filter) {
    results {
      id
      name
      creationDate
      state
      owner {
        id
      }
      type
    }
  }
}

Variables:

{
  "filter": {
    "offset": 0,
    "limit": 100
  }
}

Response:

{
  "results": [
    {
      "type": "COLLECTION",
      "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
      "name": "My Documents",
      "state": "OPENED",
      "creationDate": "2023-07-02T19:26:52Z",
      "owner": {
        "id": "9422b73d-f8d6-4faf-b7a9-152250c862a4"
      }
    }
  ]
}

Query Collections By Name

The collections query allows you to retrieve collections based on a specific filter criteria, via the name parameter. In this example, the name is set to "Documents." It returns a list of collection results containing the ID, name, creation date, state, owner ID, and type for each matching collection.

Query:

query QueryCollections($filter: CollectionFilter!) {
  collections(filter: $filter) {
    results {
      id
      name
      creationDate
      state
      owner {
        id
      }
      type
    }
  }
}

Variables:

{
  "filter": {
    "name": "Documents",
    "offset": 0,
    "limit": 100
  }
}

Response:

{
  "results": [
    {
      "type": "COLLECTION",
      "id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
      "name": "My Documents",
      "state": "OPENED",
      "creationDate": "2023-07-02T19:26:52Z",
      "owner": {
        "id": "9422b73d-f8d6-4faf-b7a9-152250c862a4"
      }
    }
  ]
}

GUID
Query Collections
Query Collections By Name
Cover

Queries

Cover

Mutations

Cover

Objects