Skip to content

[Improvement in docs] Plugin Federation #1474

@CyrilBLA

Description

@CyrilBLA

Federation schema

In order for the queries to merge properly with fastify and mercurius gateway it's better to add in each subschema :

import SchemaBuilder from '@pothos/core';
import DirectivesPlugin from '@pothos/plugin-directives';
import FederationPlugin from '@pothos/plugin-federation';

const builder = new SchemaBuilder<{
  DefaultFieldNullability: true;
  FederationPolicies: 'user:policy';
}>({
  plugins: [DirectivesPlugin, FederationPlugin],
  directives: {
    useGraphQLToolsUnorderedDirectives: true,
  },
});

builder.queryType({
  directives: {
    extends: true,
  },
});

export const schema = builder.toSubGraphSchema({
  linkUrl: 'https://specs.apollo.dev/federation/v2.5',
  federationDirectives: ['@extends'],
});

With this on, schemas will merge perfectly on the gateway endpoint.

Shouldn't it be great to have it documented or put in the example ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions