mgagliardo91 / postgraphile-apollo-federation-plugin

Apollo federation support for PostGraphile. Forked from https://github.com/graphile/federation since that project is no longer maintained.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postgraphile-apollo-federation-plugin

Travis CI npm version

Apollo federation support for PostGraphile (or any Graphile Engine schema).

Installation

npm install postgraphile-apollo-federation-plugin

CLI usage

postgraphile --append-plugins postgraphile-apollo-federation-plugin

Library usage

const express = require("express");
const { postgraphile } = require("postgraphile");
const { default: postgraphile-apollo-federation-plugin } = require("postgraphile-apollo-federation-plugin");

const app = express();

app.use(
  postgraphile(process.env.DATABASE_URL, "public", {
    appendPlugins: [postgraphile-apollo-federation-plugin],
  })
);

app.listen(process.env.PORT || 3000);

How?

This plugin exposes the Global Object Identification Specification (i.e. Node interface) in a way that's compatible with Apollo Federation.

Requires PostGraphile v4.4.2-rc.0+

Testing

Docker can be used to spin up a test instance for running Jest tests. The instance will be exposed at port 5432. See .env.example for the exported Postgre connection.

docker compose up -d
./scripts/test

Do you need this?

Only use this if you're planning to have your API consumed by Apollo Federation; exposing these redundant interfaces to regular users may be confusing.

Status

Proof of concept. No tests, use at your own risk! Pull requests very welcome.

About

Apollo federation support for PostGraphile. Forked from https://github.com/graphile/federation since that project is no longer maintained.

License:MIT License


Languages

Language:TypeScript 97.7%Language:Shell 1.7%Language:JavaScript 0.6%