🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@labdigital/apollo-gateway-directives

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@labdigital/apollo-gateway-directives

This plugin allows you to handle GraphQL directives within Apollo Gateway.

latest
npmnpm
Version
0.1.1
Version published
Maintainers
5
Created
Source

Apollo Gateway Directives Plugin

This plugin allows you to handle GraphQL directives within Apollo Gateway.

Installation

pnpm add @labdigital/apollo-gateway-directives

Usage

import { GatewayDirectivesPlugin } from '@labdigital/apollo-gateway-directives';
import type { BaseContext } from "@apollo/server";
import { buildSchema } from "graphql";

type ContextValue extends BaseContext {
  foobar: string;
}

const directivesPlugin = new GatewayDirectivesPlugin<ContextValue>({
  // Define the directive handlers here
  myDirective: async (
    args: Record<string, unknown>,
    context: ContextValue,
  ) => {
    // Do something with the directive
  }
});

const gateway = new ApolloGateway({
  // ...
});

gateway.onSchemaLoadOrUpdate((schema) => {
  // Parse the schema ourselves since `schema.apiSchema` has not all
  // directives available. See https://github.com/apollographql/federation/issues/2895
  const sdl = buildSchema(schema.coreSupergraphSdl);
  directivesPlugin.parseSchema(sdl);
});

const server = new ApolloServer({
  gateway,
  plugins: [
    directivesPlugin,
  ]
});

await server.start();

FAQs

Package last updated on 23 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts