6.0.8 • Published 3 years ago

@itoa/app-schema-router v6.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

GraphQL Schema Router

This is the last active development release of this package as Itoa 5 is now in a 6 to 12 month active maintenance phase. For more information please read our Itoa 5 and beyond post.

View changelog

A ItoaJS App that route requests to different GraphQL schemas.

The SchemaRouterApp allows you to define a routerFn which takes (req, res) and returns a routerId, which is used to pick between different GraphQL schemas which exist at the same apiPath.

Usage

const { Itoa } = require('@itoa/itoa');
const { GraphQLAppPlayground } = require('@itoa/app-graphql-playground');
const { SchemaRouterApp } = require('@itoa/app-schema-router');
const { GraphQLApp } = require('@itoa/app-graphql');
const { AdminUIApp } = require('@itoa/app-admin-ui');

module.exports = {
  itoa: new Itoa(),
  apps: [
    new GraphQLAppPlayground({ apiPath })
    new SchemaRouterApp({
      apiPath,
      routerFn: (req) => req.session.itoaItemId ? 'private' : 'public',
      apps: {
        public: new GraphQLApp({ apiPath, schemaName: 'public', graphiqlPath: undefined }),
        private: new GraphQLApp({ apiPath, schemaName: 'private', graphiqlPath: undefined }),
      },
    }),
    new AdminUIApp()
  ],
};

Config

OptionTypeDefaultDescription
apiPathString/admin/apiThe GraphQL API path
routerFnFunction() => {}A function which takes (req, res) and returns a routerId
appsObject{}An object with routerIds as keys and GraphQLApps as values
6.0.8

3 years ago

6.0.7

3 years ago

6.0.1

4 years ago

6.0.0

4 years ago

5.2.3

4 years ago

5.2.2

4 years ago