Giter VIP home page Giter VIP logo

multiple-gateways-in-express's Introduction

Multiple Apollo Gateways in a Single Express Server

A demonstration of running multiple instances of Apollo Server and Apollo Gateway within a single Express server. Uses Managed Federation and determines the graphRef from HTTP request headers.

The code in this repository is experimental and has been provided for reference purposes only. Community feedback is welcome but this project may not be supported in the same way that repositories in the official Apollo GraphQL GitHub organization are. If you need help you can file an issue on this repository, contact Apollo to talk to an expert, or create a ticket directly in Apollo Studio.

Installation

git clone [email protected]:apollosolutions/multiple-gateways-in-express.git
cd multiple-gateways-in-express
yarn

Usage

export APOLLO_KEY=<your apollo api key for all graphrefs>
yarn start

Open http://localhost:4000. It will redirect you to Apollo Sandbox. From there you can specify the graphRef by setting a default header in the Connection settings:

Screenshot of the Connection settings in Apollo Sandbox

Known Limitations

  • Assumes that all graphRefs are accessible via the same API key. You could choose to pass separate API keys in the Apollo Server constructor:
    const server = new ApolloServer({
      gateway,
      apollo: {
        graphRef: graphRef,
        key: someOtherAPIKey,
      },
    });
  • Will allow creating any number of instances given enough valid graphRefs and they live for the duration of the Node.js process. It's probably a good idea to cap the number of running instances to avoid using too much memory.

multiple-gateways-in-express's People

Contributors

lennyburdette avatar

Watchers

Andy Roberts avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.