-
Notifications
You must be signed in to change notification settings - Fork 0
apis_graphql
makr-code edited this page Dec 21, 2025
·
1 revision
Status: ✅ Implementiert
Version: 1.0
Datum: 30. November 2025
ThemisDB bietet eine GraphQL API als Alternative zur REST API. GraphQL ermöglicht flexible Abfragen mit exakter Feldauswahl und effizienter Datenabfrage.
-
GraphQL Parser
- Query, Mutation, Subscription Operationen
- Field Selections mit Aliases
- Argumente (alle Typen)
- Variablen mit Default-Werten
- Verschachtelte Selections
- Kommentare
-
Schema
- Built-in Scalar Types (String, Int, Float, Boolean, ID, JSON)
- Document Types
- Graph Types (Node, Edge)
- Vector Search Types
- Timeseries Types
- Query und Mutation Types
-
Executor
- Field Resolution
- Nested Selection Execution
- Error Handling
- Custom Resolvers
-
Schema Introspection
- SDL (Schema Definition Language) Export
- Type Queries
type Query {
# Einzelnes Dokument abrufen
document(collection: String!, id: ID!): Document
# Dokumente auflisten
documents(collection: String!, limit: Int, offset: Int): [Document!]!
# AQL Query ausführen
aql(query: String!, variables: JSON): JSON
# Vector-Suche
vectorSearch(collection: String!, vector: [Float!]!, k: Int): [VectorSearchResult!]!
# Graph-Traversierung
graphTraversal(startNode: ID!, depth: Int, direction: String): [Node!]!
}type Mutation {
# Dokument erstellen
createDocument(collection: String!, input: DocumentInput!): Document!
# Dokument aktualisieren
updateDocument(collection: String!, id: ID!, input: DocumentInput!): Document
# Dokument löschen
deleteDocument(collection: String!, id: ID!): Boolean!
# Graph-Kante erstellen
createEdge(source: ID!, target: ID!, type: String!, properties: JSON): Edge!
}type Document {
id: ID!
collection: String!
data: JSON!
createdAt: String
updatedAt: String
}
input DocumentInput {
data: JSON!
}type Node {
id: ID!
labels: [String]
properties: JSON
}
type Edge {
id: ID!
type: String!
source: Node!
target: Node!
properties: JSON
}type VectorSearchResult {
id: ID!
score: Float!
document: Document
}#include "api/graphql.h"
using namespace themis::graphql;
// GraphQL Query parsen
auto result = Parser::parse(R"(
query GetUser($userId: ID!) {
document(collection: "users", id: $userId) {
id
data
createdAt
}
}
)");
if (result.success) {
const auto& op = result.document.operations[0];
std::cout << "Operation: " << op.name << std::endl;
}// Execution Context aufbauen
ExecutionContext ctx;
ctx.tenant_id = "acme-corp";
ctx.user_id = "user123";
// Variable setzen
ctx.variables["userId"] = Value::string("user-456");
// Resolver definieren
ctx.resolvers["document"] = [](const Field& field,
const std::shared_ptr<Value>& parent,
const ExecutionContext& ctx) {
// Collection und ID aus Argumenten lesen
auto collection = field.arguments.at("collection")->asString();
auto id = field.arguments.at("id")->asString();
// Dokument laden (hier: Mock-Daten)
ValueMap doc;
doc["id"] = Value::string(id);
doc["collection"] = Value::string(collection);
doc["data"] = Value::object({{"name", Value::string("John")}});
doc["createdAt"] = Value::string("2025-11-30T12:00:00Z");
return Value::object(std::move(doc));
};
// Query ausführen
Executor executor;
auto result = executor.execute(parseResult.document, ctx);
if (!result.hasErrors()) {
// result.data enthält das Ergebnis
}Schema schema = ThemisSchemaBuilder::build();
// SDL exportieren
std::string sdl = schema.toSDL();
std::cout << sdl << std::endl;POST /graphql HTTP/1.1
Host: localhost:8080
Content-Type: application/json
X-Tenant-ID: acme-corp
Authorization: Bearer <token>
{
"query": "query { documents(collection: \"users\", limit: 10) { id data } }",
"variables": {}
}{
"data": {
"documents": [
{"id": "user-1", "data": {"name": "Alice"}},
{"id": "user-2", "data": {"name": "Bob"}}
]
},
"errors": []
}{
document(collection: "users", id: "user-123") {
id
data
}
}query GetUser($collection: String!, $id: ID!) {
document(collection: $collection, id: $id) {
id
data
createdAt
updatedAt
}
}mutation CreateUser {
createDocument(collection: "users", input: {
data: {
name: "John Doe",
email: "john@example.com"
}
}) {
id
createdAt
}
}{
firstUser: document(collection: "users", id: "1") { id data }
secondUser: document(collection: "users", id: "2") { id data }
}{
vectorSearch(collection: "documents", vector: [0.1, 0.2, 0.3], k: 10) {
id
score
document {
id
data
}
}
}{
graphTraversal(startNode: "user:alice", depth: 3, direction: "OUTBOUND") {
id
labels
properties
}
}// Null
auto nullVal = Value::null();
// Boolean
auto boolVal = Value::boolean(true);
// Integer
auto intVal = Value::integer(42);
// Float
auto floatVal = Value::floating(3.14159);
// String
auto strVal = Value::string("Hello");
// Enum
auto enumVal = Value::enumValue("ACTIVE");
// List
ValueList list;
list.push_back(Value::integer(1));
list.push_back(Value::integer(2));
auto listVal = Value::list(std::move(list));
// Object
ValueMap map;
map["key"] = Value::string("value");
auto objVal = Value::object(std::move(map));- Keine Fragments (geplant)
- Keine Directives (geplant)
- Keine Inline Fragments
- Keine Subscriptions über WebSocket (nur Polling)
- HTTP Handler Integration
- Fragment Support
- Directive Support
- Subscription über WebSocket
- Batching Support
- Persisted Queries
- Query Complexity Analysis
Letzte Aktualisierung: 30. November 2025
Maintainer: ThemisDB Team
ThemisDB v1.3.4 | GitHub | Documentation | Discussions | License
Last synced: January 02, 2026 | Commit: 6add659
Version: 1.3.0 | Stand: Dezember 2025
- Übersicht
- Home
- Dokumentations-Index
- Quick Reference
- Sachstandsbericht 2025
- Features
- Roadmap
- Ecosystem Overview
- Strategische Übersicht
- Geo/Relational Storage
- RocksDB Storage
- MVCC Design
- Transaktionen
- Time-Series
- Memory Tuning
- Chain of Thought Storage
- Query Engine & AQL
- AQL Syntax
- Explain & Profile
- Rekursive Pfadabfragen
- Temporale Graphen
- Zeitbereichs-Abfragen
- Semantischer Cache
- Hybrid Queries (Phase 1.5)
- AQL Hybrid Queries
- Hybrid Queries README
- Hybrid Query Benchmarks
- Subquery Quick Reference
- Subquery Implementation
- Content Pipeline
- Architektur-Details
- Ingestion
- JSON Ingestion Spec
- Enterprise Ingestion Interface
- Geo-Processor Design
- Image-Processor Design
- Hybrid Search Design
- Fulltext API
- Hybrid Fusion API
- Stemming
- Performance Tuning
- Migration Guide
- Future Work
- Pagination Benchmarks
- Enterprise README
- Scalability Features
- HTTP Client Pool
- Build Guide
- Implementation Status
- Final Report
- Integration Analysis
- Enterprise Strategy
- Verschlüsselungsstrategie
- Verschlüsselungsdeployment
- Spaltenverschlüsselung
- Encryption Next Steps
- Multi-Party Encryption
- Key Rotation Strategy
- Security Encryption Gap Analysis
- Audit Logging
- Audit & Retention
- Compliance Audit
- Compliance
- Extended Compliance Features
- Governance-Strategie
- Compliance-Integration
- Governance Usage
- Security/Compliance Review
- Threat Model
- Security Hardening Guide
- Security Audit Checklist
- Security Audit Report
- Security Implementation
- Development README
- Code Quality Pipeline
- Developers Guide
- Cost Models
- Todo Liste
- Tool Todo
- Core Feature Todo
- Priorities
- Implementation Status
- Roadmap
- Future Work
- Next Steps Analysis
- AQL LET Implementation
- Development Audit
- Sprint Summary (2025-11-17)
- WAL Archiving
- Search Gap Analysis
- Source Documentation Plan
- Changefeed README
- Changefeed CMake Patch
- Changefeed OpenAPI
- Changefeed OpenAPI Auth
- Changefeed SSE Examples
- Changefeed Test Harness
- Changefeed Tests
- Dokumentations-Inventar
- Documentation Summary
- Documentation TODO
- Documentation Gap Analysis
- Documentation Consolidation
- Documentation Final Status
- Documentation Phase 3
- Documentation Cleanup Validation
- API
- Authentication
- Cache
- CDC
- Content
- Geo
- Governance
- Index
- LLM
- Query
- Security
- Server
- Storage
- Time Series
- Transaction
- Utils
Vollständige Dokumentation: https://makr-code.github.io/ThemisDB/