@whook/graphiql v18.1.0
@whook/graphiql
A wrapper for the Whook HTTP Router to provide GraphIQL for local dev
This module provides the GraphIQL UI to your local Whook server !
Usage
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).
Setup
Install the module:
npm i @whook/graphiqlUpdate the types (usually in src/whook.d.ts):
+import type {
+ WhookGraphIQLEnv,
+ 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 runServer function (usually in
src/index.ts):
+ import initHTTPRouter from '@whook/http-router';
+ import wrapHTTPRouterWithGraphIQL from '@whook/graphiql';
// (...)
// It is important to do this in the runServer function since it really
// make sense only when actually running the server
export async function runServer(injectedNames = [], $ = new Knifecycle()) {
// (...)
+ // Add support for GraphIQL UI by wrapping and
+ // overriding the original HTTP Router
+ $.register(
+ wrapHTTPRouterWithGraphIQL(initHTTPRouter),
+ );
return await runBaseServer(injectedNames, $);
}API
Authors
License
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago