The Guild LogoThe Guild Monogram

Search docs

Search icon

Products by The Guild


Hive logoHive blurred logo


Schema Registry for your GraphQL Workflows

Skip to main content

Apollo Federation Transform

federation transform allows to add the resolvers and directives to conform to the federation specification. Much of the federation sourcecode could be reused ensuring it is compliant to the specification. This transform uses graphql-transform-federation package.

yarn add @graphql-mesh/transform-federation

How to use?#

Add the following configuration to your Mesh config file:

- federation:
# Ensure the root queries of this schema show up the combined schema
- name: Query
extend: true
- name: Product
# extend Product {
extend: true
# Product @key(fields: "id") {
- id
# id: Int! @external
- name: id
external: true
queryFieldName: user

Add Reference Resolver as a Code File#

If you want to add more complex business logic, you can point to a code file that exports a resolver function.

resolveReference: ./userResolveReference.js


// So we can point to an existing query field to resolve that entity
module.exports = (root, context, info) =>
context.accounts.Query.user({ root, args: { id: }, context, info })

You can check out our example that uses Federation as a merging strategy.

  • types (type: Array of Object, required):
    • name (type: String, required)
    • config (type: Object):
      * `keyFields` (type: `Array of String`, required)
      * `extend` (type: `Boolean`)
      * `fields` (type: `Array of Object`, required):
      * `name` (type: `String`, required)
      * `config` (type: `Object`, required):
      * `external` (type: `Boolean`)
      * `provides` (type: `String`)
      * `requires` (type: `String`)
      * `resolveReference` - One of:
      * `String`
      * `object`:
      * `queryFieldName` (type: `String`, required) - Name of root field name that resolves the reference
      * `keyArg` (type: `String`) - If the root field name has multiple args,
      you need to define which argument should receive the key