5.1.2 • Published 4 years ago

@keystone-next/app-schema-router-legacy v5.1.2

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

GraphQL Schema Router

View changelog

A KeystoneJS 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 { Keystone } = require('@keystone-next/keystone-legacy');
const { GraphQLAppPlayground } = require('@keystone-next/app-graphql-playground-legacy');
const { SchemaRouterApp } = require('@keystone-next/app-schema-router-legacy');
const { GraphQLApp } = require('@keystone-next/app-graphql-legacy');
const { AdminUIApp } = require('@keystone-next/app-admin-ui-legacy');

module.exports = {
  keystone: new Keystone(),
  apps: [
    new GraphQLAppPlayground({ apiPath })
    new SchemaRouterApp({
      apiPath,
      routerFn: (req) => req.session.keystoneItemId ? '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