Comment on page
Collections
Create, manage and query Collections.
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 GUID 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.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"
}
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"
}
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"
}
Using the
addCollectionContents
mutation, you can add contents to a collection by supplying the id
parameter for the target collection and the contents
parameter, which expects an array of entity references. It returns the ID, name, state, type, and the relevant details of the added contents within the collection.Mutation:
mutation AddCollectionContents($id: ID!, $contents: [EntityReferenceInput!]!) {
addCollectionContents(id: $id, contents: $contents) {
id
name
state
type
contents {
id
name
}
}
}
Variables:
{
"id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
"contents": [
{
"id": "bd7d8150-666f-43be-9e75-a692576adf9b"
}
]
}
Response:
{
"type": "COLLECTION",
"contents": [
{
"id": "bd7d8150-666f-43be-9e75-a692576adf9b",
"name": "main.docx"
}
],
"id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
"name": "My Documents",
"state": "OPENED"
}
Through the
removeCollectionContents
mutation, you can remove specific contents from a collection by providing the id
parameter 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 RemoveCollectionContents($id: ID!, $contents: [EntityReferenceInput!]!) {
removeCollectionContents(id: $id, contents: $contents) {
id
name
state
type
contents {
id
name
}
}
}
Variables:
{
"id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
"contents": [
{
"id": "bd7d8150-666f-43be-9e75-a692576adf9b"
}
]
}
Response:
{
"type": "COLLECTION",
"contents": [],
"id": "6d2f8905-b6a1-48bf-b58d-a6441aaa4149",
"name": "My Documents",
"state": "OPENED"
}
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
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"
}
}
]
}
Last modified 4mo ago