Get AI summaries of any video or article — Sign up free
Webinar: GraphQL Federation and Knowledge Graphs thumbnail

Webinar: GraphQL Federation and Knowledge Graphs

Ontotext·
6 min read

Based on Ontotext's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

GraphQL Federation provides a single, unified GraphQL interface over multiple knowledge-graph services, even when data is split across different backends.

Briefing

GraphQL Federation is positioned as a practical way to turn a set of separate knowledge-graph services into one unified, queryable graph—without forcing clients to know where each piece of data lives. The core idea is to expose each backend (RDF graph database, annotation store, semantic similarity index, and more) through GraphQL, then use federation to stitch them together into a single schema and a single query language. The result is a “single view” over multiple services, where a client can ask for nested, cross-domain data in one request and receive a consistent response shape.

The session grounds that concept in Ontotext’s stack for knowledge graphs. It describes an RDF layer in GraphDB, plus supporting components such as MongoDB for storing text-analytics outputs (notably Web Annotation JSON-LD) and a semantic vector space index for similarity search. A semantic object service sits on top of RDF and other stores, abstracting RDF “in various flavors” behind GraphQL. From a lightweight object model (expressed in a YAML-like representation), the platform can generate GraphQL schemas, resolvers, and the query/mutation surface automatically—then transpile GraphQL queries into high-performance backend queries.

A key portion of the briefing focuses on GraphQL itself as used for knowledge graphs. GraphQL is treated as an API-level query language with strong typing: schemas define object types, properties, arguments for filtering (including complex boolean logic and regex-style matching), pagination, ordering, and mutation operations. The schema also supports interfaces, unions, variables, aliases, fragments, and inline fragments—features that matter when modeling RDF hierarchies such as Star Wars entities (films, characters, species, planets, people). Introspection is highlighted as a way to drive developer tooling: the schema can be queried so IDEs can offer autocomplete and validate query shapes before execution.

Federation then becomes the mechanism for joining isolated graph services. The knowledge graph is split into bounded contexts: one context handles text analytics and stores entity annotations in MongoDB as Web Annotation JSON-LD; another context hosts the Star Wars universe in GraphDB; a third context provides character similarity using a semantic vector space. Federation keys (for example, using a shared identifier like a character URI) define join points across contexts. Extension types let one service “add” fields from another service onto the same conceptual object, so requesting a character can automatically pull in properties from the Star Wars universe, while also attaching similarity-derived relationships.

A concrete example shows how an annotation query can be extended through federation: start with annotations that reference a character URI, then delegate to the similarity service to find similar characters, and finally extend those characters with RDF-backed details such as homeworld, film appearances, and roles. The client-facing query remains simple; the federation engine coordinates schema aggregation, query planning, delegation to each backend, and joining results. The session also notes that federation can handle more than joins—calculations can be federated too, where a field computed in one service depends on data retrieved from another.

Overall, the takeaway is an architecture pattern: model shared entities with stable keys, expose each bounded context through GraphQL, and let federation produce a single aggregated schema and query execution path. That approach supports independent development of services while still enabling one coherent knowledge-graph experience for application developers.

Cornell Notes

GraphQL Federation is presented as a way to unify multiple knowledge-graph services behind one GraphQL endpoint. Each bounded context—RDF data in GraphDB, text-analytics annotations stored as Web Annotation JSON-LD in MongoDB, and semantic similarity built on a vector space—gets its own GraphQL surface, then federation keys and extension types stitch them into a single schema. Strong typing in GraphQL (schemas, arguments, nullable vs non-nullable fields, introspection) helps validate query shapes and reduces runtime mismatches. In the Star Wars example, a client can query annotations, fetch similar characters from the similarity service, and automatically extend those characters with RDF-backed properties like homeworld and film roles. The practical payoff is one declarative query language for cross-service graph data without clients needing to know which backend holds which field.

Why does the architecture rely on GraphQL (and not direct RDF queries) for knowledge-graph access?

GraphQL is used as an API-level query language with a generated, strongly typed schema. The schema defines object types, properties, arguments for filtering (including boolean operators and regex-style matching), pagination, ordering, and mutations. Because GraphQL validates requests against the schema, clients get predictable response shapes: requested fields map to the returned object structure, and missing non-nullable data triggers errors. In the Ontotext setup, a semantic object service abstracts RDF and other stores behind GraphQL by generating schemas and resolvers from a simpler object model, then transpiling GraphQL queries into backend-specific queries.

What role do federation keys and extension types play in joining separate knowledge-graph contexts?

Federation keys define the shared identifier used to join entities across services—for example, a character’s URI in JSON-LD and the same identifier used in the Star Wars RDF model. Extension types let one service add fields from another service onto the same conceptual object. In practice, an annotation stored in MongoDB can reference a character URI; federation uses that key to fetch the character from the Star Wars universe (GraphDB) and also attach similarity-derived fields from the semantic vector space service.

How does the Star Wars example demonstrate cross-service queries without client-side complexity?

A single client query can start from annotations (MongoDB Web Annotation JSON-LD), then ask for similar characters (semantic vector space service), and finally request RDF-backed details (GraphDB) such as homeworld, film appearances, and roles. The federation engine coordinates delegation: it splits the query across services, retrieves each portion, and joins results before returning a unified response. From the client’s perspective, the query remains declarative and does not require knowledge of which backend stores each field.

What GraphQL features matter most when modeling RDF hierarchies like characters, films, and planets?

Interfaces and unions support RDF-like type hierarchies (e.g., a character interface implemented by humans, droids, and other subtypes). Inline fragments allow type-specific fields—such as returning “height” only for human objects while other character subtypes omit it. Aliases support querying the same field multiple times with different arguments (e.g., different episode IDs) without breaking JSON structure. Fragments reduce repetition by reusing field selections across queries.

How can federation go beyond joins to support federated calculations?

Federation can compute fields in one service using data retrieved from another. The session describes an example where an object extends a planet and a calculation for gravity depends on an external field (like diameter) sourced from a different service. Federation passes the required external data into the calculating service so the computed value can be returned as part of the unified response.

What does “schema aggregation” mean in GraphQL Federation for this stack?

A gateway collects each service’s schema (including object types, extension points, and federation directives) and merges them into an aggregate schema. That aggregate schema exposes a single unified view to clients. When a federated query arrives, the engine validates it against the aggregate schema, then uses the schema’s join points and keys to plan which sub-queries to delegate to each backend and how to join the results.

Review Questions

  1. How do federation keys and extension types enable a MongoDB-stored Web Annotation JSON-LD entity to be enriched with GraphDB RDF properties in one GraphQL response?
  2. Which GraphQL schema features (interfaces, unions, fragments, aliases) are most useful for representing RDF subtype differences in the Star Wars model?
  3. Describe the end-to-end flow of a federated query that starts from annotations, then fetches similar characters, then returns RDF-backed fields.

Key Points

  1. 1

    GraphQL Federation provides a single, unified GraphQL interface over multiple knowledge-graph services, even when data is split across different backends.

  2. 2

    A semantic object service can generate GraphQL schemas, resolvers, and query/mutation surfaces from a simpler object model, then transpile GraphQL into backend queries.

  3. 3

    GraphQL’s strong typing (nullable vs non-nullable fields, schema validation, introspection) helps ensure predictable response shapes and reduces query-shape errors.

  4. 4

    Federation keys (shared identifiers such as character URIs) define join points across bounded contexts like MongoDB annotations, GraphDB RDF, and semantic similarity indexes.

  5. 5

    Extension types let one service add fields from another service onto the same conceptual object, enabling cross-context enrichment in one request.

  6. 6

    Federation can also support federated calculations where a computed field depends on data retrieved from another service.

Highlights

A client can query annotations stored in MongoDB, then seamlessly request similar characters from a vector-space service and RDF-backed details from GraphDB—all through one GraphQL query.
GraphQL schemas generated from an object model drive validation, autocomplete via introspection, and consistent response shapes for knowledge-graph applications.
Federation keys and extension types turn independently built bounded contexts into a single aggregated schema and a coherent knowledge-graph experience.

Topics

  • GraphQL Federation
  • Knowledge Graphs
  • Semantic Object Service
  • Web Annotation JSON-LD
  • Semantic Similarity

Mentioned

  • Yasiin Stoical
  • Gem Rayfield
  • Jameson
  • RDF
  • JSON-LD
  • API
  • NLP
  • IDF
  • tf-idf