Atom with Related Triples
Discover relationships by finding all triples where an atom appears as subject, predicate, or object.
Query Structureβ
query GetAtomWithTriples($atomId: String!, $limit: Int!) {
atom(term_id: $atomId) {
term_id
label
image
as_subject_triples(limit: $limit, order_by: { created_at: desc }) {
term_id
predicate { label }
object { label image }
}
as_object_triples(limit: $limit, order_by: { created_at: desc }) {
term_id
subject { label image }
predicate { label }
}
}
}
Interactive Examplesβ
Query
query GetAtomWithTriples($atomId: String!, $limit: Int!) {
atom(term_id: $atomId) {
term_id
label
image
as_subject_triples(limit: $limit, order_by: { created_at: desc }) {
term_id
predicate { term_id label }
object { term_id label image }
}
as_object_triples(limit: $limit, order_by: { created_at: desc }) {
term_id
subject { term_id label image }
predicate { term_id label }
}
}
}Variables
Click "Run Query" to execute the GraphQL query and see results
Use Casesβ
Discover Relationshipsβ
Find all relationships for an atom:
const query = `
query GetAtomRelationships($atomId: String!) {
atom(term_id: $atomId) {
term_id
label
as_subject_triples(limit: 20) {
predicate { label }
object { label }
}
as_object_triples(limit: 20) {
subject { label }
predicate { label }
}
}
}
`
Build Knowledge Graphβ
Construct a graph view of relationships:
const query = `
query GetKnowledgeGraph($atomId: String!, $depth: Int!) {
atom(term_id: $atomId) {
term_id
label
as_subject_triples(limit: $depth) {
term_id
predicate { label }
object {
term_id
label
as_subject_triples(limit: 5) {
object { label }
}
}
}
}
}
`
Performance Considerationsβ
- Limit results: Always use limit to prevent over-fetching
- Filter by predicate: Narrow results to specific relationship types
- Avoid deep nesting: Limit graph traversal depth
Related Patternsβ
- Single Triple - Query triple details
- Filter Triples - Advanced filtering
Best Practicesβ
- Use limit on nested triple queries
- Filter by predicate when looking for specific relationships
- Order by created_at for chronological results
- Avoid excessive nesting to prevent slow queries