5.2.3 • Published 2 years ago

@keystonejs/app-schema-router v5.2.3

Weekly downloads
205
License
MIT
Repository
github
Last release
2 years ago

GraphQL Schema Router

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

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

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
5.2.3

2 years ago

5.2.2

4 years ago

5.2.1

4 years ago

5.2.0

4 years ago

5.1.2

4 years ago

5.1.1

5 years ago

5.1.0

5 years ago

5.0.0

6 years ago