A wrapper for the Whook HTTP Router to provide GraphIQL for local dev
npm install @whook/graphiql[//]: # ( )
[//]: # (This file is automatically generated by a metapak)
[//]: # (module. Do not change it except between the)
[//]: # (content:start/end flags, your changes would)
[//]: # (be overridden.)
[//]: # ( )

[//]: # (::contents:start)
This module provides the GraphIQL UI to your local
Whook server !
The DEV_MODE=1 environment variable must be used when starting your server
(the npm run dev script of default Whook projects does it by default).
Install the module:
``sh`
npm i @whook/graphiql
Update the types (usually in src/whook.d.ts):
`diff
+import {
+ type WhookGraphIQLEnv,
+ type WhookGraphIQLConfig,
+} from '@whook/graphiql';
// ...
declare module 'application-services' {
export interface AppEnvVars
extends BaseAppEnvVars,
WhookBaseEnv,
// (...)
+ WhookGraphIQLEnv,
WhookSwaggerUIEnv {}
// (...)
export interface AppConfig
extends WhookBaseConfigs,
// (...)
+ WhookGraphIQLConfig,
JWTServiceConfig {}
// ...
}
`
Then, just wrap the HTTP router with this module and register it again with the
Knifecycle instance inside the runProcess function (usually insrc/index.ts):
`diff
+ import { initHTTPRouter } from '@whook/whook';
+ import wrapHTTPRouterWithGraphIQL from '@whook/graphiql';
// (...)
// It is important to do this in the runProcess function since it really
// make sense only when actually running the server
export async function runProcess(injectedNames = [], $ = new Knifecycle()) {
// (...)
+ // Add support for GraphIQL UI by wrapping and
+ // overriding the original HTTP Router
+ $.register(
+ wrapHTTPRouterWithGraphIQL(initHTTPRouter),
+ );
return await runBaseProcess(injectedNames, $);
}
``
[//]: # (::contents:end)