Skip to content

Commit

Permalink
feat(python-sdk): nested collections and documents (#32)
Browse files Browse the repository at this point in the history
Documents are indexed by a key in a collection, and contain JSON data:
* Create documents in a collection
* Manage tags for a document
* Iterate over documents in a collection (with filtering by tags possible)
* Read document data

Additionally nested collections are introduced.
  • Loading branch information
artem-chupryna authored Sep 25, 2024
1 parent 3c109cd commit a6efc63
Show file tree
Hide file tree
Showing 26 changed files with 1,927 additions and 61 deletions.
122 changes: 122 additions & 0 deletions python/queries.gql
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ fragment CollectionReference on Collection {
key
}

fragment CollectionDocumentReference on CollectionDocument {
id
key
data
tags {
key
value
}
}

fragment CollectionNotFound on CollectionNotFound {
id
}
Expand All @@ -116,3 +126,115 @@ mutation CollectionCreate($organizationID: ID!, $key: ID!, $parentID: ID) {
}
}
}

mutation CollectionCollections(
$organizationID: ID!
$key: ID!
$after: ID
$first: Int
) {
collectionCreate(organizationID: $organizationID, key: $key) {
__typename
... on Collection {
id
key
collections(after: $after, first: $first) {
edges {
node {
... on Collection {
...CollectionReference
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}

mutation CollectionDocument($organizationID: ID!, $key: ID!, $docKey: ID!) {
collectionCreate(organizationID: $organizationID, key: $key) {
__typename
... on Collection {
document(key: $docKey) {
__typename
... on CollectionDocument {
...CollectionDocumentReference
}
}
}
}
}

mutation collectionDocumentSet(
$collectionID: ID!
$key: ID!
$data: Base64JSON!
) {
collectionDocumentSet(collectionID: $collectionID, key: $key, data: $data) {
__typename
... on CollectionDocument {
...CollectionDocumentReference
}
}
}

mutation collectionDocumentDelete($id: ID!) {
collectionDocumentDelete(id: $id) {
__typename
... on CollectionDocument {
...CollectionDocumentReference
}
}
}

mutation collectionDocumentTagAdd($id: ID!, $tag: TagInput!) {
collectionDocumentTagAdd(id: $id, tag: $tag) {
__typename
... on CollectionDocument {
...CollectionDocumentReference
}
}
}

mutation collectionDocumentTagDelete($id: ID!, $tag_key: String!) {
collectionDocumentTagDelete(id: $id, key: $tag_key) {
__typename
... on CollectionDocument {
...CollectionDocumentReference
}
}
}

mutation collectionDocuments(
$organizationID: ID!
$key: ID!
$tag: TagInput
$after: ID
$first: Int
) {
collectionCreate(organizationID: $organizationID, key: $key) {
__typename
... on Collection {
id
key
documents(after: $after, first: $first, tag: $tag) {
edges {
node {
__typename
... on CollectionDocument {
...CollectionDocumentReference
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
Loading

0 comments on commit a6efc63

Please sign in to comment.