IMPORTANT
GraQL is prerelease, experimental, and a demonstration piece. Use at your own risk.
Federation
What is Federation?
Federation allows you to publish multiple GraphQL APIs that work together as one. Multiple microservices, monoliths, or other architectures we haven't yet devised can "join" their schemas into one "superschema" with a single HTTP endpoint allowing access to multiple APIs.
How Do I Federate?
Easily! GraQL bundles Apollo's federation-jvm module, built on top of graphql-java. It does all of the heavy lifting.
All we need to do is add directives to our schema that state which types are entry points from the supergraph into our schema.
In this example, we're registering ToDo
as such a type by adding the @key
directive
type ToDo @key(fields: "id") { # <4>
id: ID!
title: String!
completed: Boolean!
dateCompleted: DateTime
author: Author!
}
How Does This Work?
GraQL automatically registers any necessary DataFetcher
s and TypeResolver
s needed by a federation router through its GraQLFederationProvider
and GraQLFederatedEntityResolver
classes.