Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@keystonejs/app-schema-router

keystonejs7MIT5.2.3

KeystoneJS GraphQL App.

readme

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

Option Type Default Description
apiPath String /admin/api The GraphQL API path
routerFn Function () => {} A function which takes (req, res) and returns a routerId
apps Object {} An object with routerIds as keys and GraphQLApps as values

changelog

@keystonejs/app-schema-router

5.2.3

Patch Changes

  • e24e4dfce Thanks @dcousens! - Fixes express.Router() usage to fix inheriting of express application settings

5.2.2

Patch Changes

5.2.1

Patch Changes

5.2.0

Minor Changes

5.1.2

Patch Changes

5.1.1

Patch Changes

5.1.0

Minor Changes

5.0.0

Major Changes

  • 7b4ed362 #1821 Thanks @jesstelford! - Release @keystonejs/* packages (つ^ ◡ ^)つ

    • This is the first release of @keystonejs/* packages (previously @keystone-alpha/*).
    • All packages in the @keystone-alpha namespace are now available in the @keystonejs namespace, starting at version 5.0.0.
    • To upgrade your project you must update any @keystone-alpha/* dependencies in package.json to point to "@keystonejs/*": "^5.0.0" and update any require/import statements in your code.

@keystone-alpha/app-schema-router

1.0.1

Patch Changes

  • 9b532072: Rename Keystone to KeystoneJS in docs where possible in docs

1.0.0

Major Changes

  • 2c64ce15: Initial release of the SchemaRouterApp.