Skip to main content

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

Best Practices​

  1. Use limit on nested triple queries
  2. Filter by predicate when looking for specific relationships
  3. Order by created_at for chronological results
  4. Avoid excessive nesting to prevent slow queries