mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
core: update hook usage
This commit is contained in:
1 parent
ab933bc9d5
commit
757b5e6bc1
27 files changed
+63
-64
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import { makeExecutableSchema } from '@graphql-tools/schema';
|
||||
import { graphql, GraphQLSchema } from 'graphql';
|
||||
import { resolvers, typeDefs } from 'graphql-scalars';
|
||||
import { debounce } from 'lodash';
|
||||
import { Context as PluginContext } from '../context';
|
||||
import * as bus from '../service/bus';
|
||||
import { Handler } from '../service/server';
|
||||
|
||||
@@ -90,10 +92,6 @@ export function rebuild() {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
bus.on('app/started', () => {
|
||||
rebuild();
|
||||
bus.on('api/update', rebuild);
|
||||
});
|
||||
|
||||
class ApiHandler extends Handler {
|
||||
query(q: string, variables: any) {
|
||||
@@ -124,6 +122,8 @@ class ApiHandler extends Handler {
|
||||
}
|
||||
|
||||
export const sideEffect = true;
|
||||
export function apply(ctx) {
|
||||
export function apply(ctx: PluginContext) {
|
||||
ctx.Route('api', '/api', ApiHandler);
|
||||
ctx.on('ready', rebuild);
|
||||
ctx.on('api/update', debounce(rebuild));
|
||||
}
|
||||
Reference in new issue
Block a user