Browse Source

fix: gql meta sync

reinitialize gql endpoint after meta sync

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/914/head
Pranav C 3 years ago
parent
commit
c8f5d32bd3
  1. 5
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts
  2. 53
      packages/nocodb/src/lib/noco/common/handlers/xcMetaDiffSync.ts
  3. 2
      packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts

5
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -1718,9 +1718,10 @@ export default abstract class BaseApiBuilder<T extends Noco>
// table alias functions // table alias functions
protected getInflectedName(_name: string, inflectionFns: string): string { protected getInflectedName(_name: string, inflectionFns: string): string {
let name = _name; let name = _name;
if (process.env.NC_INFLECTION) if (process.env.NC_INFLECTION) {
inflectionFns = 'camelize'; inflectionFns = 'camelize';
}
if (inflectionFns && inflectionFns !== 'none') { if (inflectionFns && inflectionFns !== 'none') {
name = inflectionFns name = inflectionFns
.split(',') .split(',')

53
packages/nocodb/src/lib/noco/common/handlers/xcMetaDiffSync.ts

@ -4,6 +4,7 @@ import xcMetaDiff, {
XcMetaDiffType XcMetaDiffType
} from '../../meta/handlers/xcMetaDiff'; } from '../../meta/handlers/xcMetaDiff';
import XcCache from '../../plugins/adapters/cache/XcCache'; import XcCache from '../../plugins/adapters/cache/XcCache';
import { GqlApiBuilder } from '../../gql/GqlApiBuilder';
// @ts-ignore // @ts-ignore
export default async function(this: BaseApiBuilder<any> | any) { export default async function(this: BaseApiBuilder<any> | any) {
@ -198,11 +199,11 @@ export default async function(this: BaseApiBuilder<any> | any) {
/* update sort field */ /* update sort field */
/* const sIndex = (sortList || []).findIndex( /* const sIndex = (sortList || []).findIndex(
v => v.field === oldColumn._cn v => v.field === oldColumn._cn
); );
if (sIndex > -1) { if (sIndex > -1) {
sortList.splice(sIndex, 1); sortList.splice(sIndex, 1);
}*/ }*/
for (const sort of sortList || []) { for (const sort of sortList || []) {
if ( if (
sort?.field === oldColumn.cn || sort?.field === oldColumn.cn ||
@ -220,12 +221,12 @@ export default async function(this: BaseApiBuilder<any> | any) {
/* update filters */ /* update filters */
// todo: remove only corresponding filter and compare field name // todo: remove only corresponding filter and compare field name
/* if ( /* if (
filters && filters &&
(JSON.stringify(filters)?.includes(`"${oldColumn.cn}"`) || (JSON.stringify(filters)?.includes(`"${oldColumn.cn}"`) ||
JSON.stringify(filters)?.includes(`"${oldColumn._cn}"`)) JSON.stringify(filters)?.includes(`"${oldColumn._cn}"`))
) { ) {
filters.splice(0, filters.length); filters.splice(0, filters.length);
}*/ }*/
for (const filter of filters) { for (const filter of filters) {
if ( if (
filter?.field === oldColumn.cn || filter?.field === oldColumn.cn ||
@ -319,8 +320,8 @@ export default async function(this: BaseApiBuilder<any> | any) {
db_type: this.connectionConfig?.client db_type: this.connectionConfig?.client
// todo: get these info // todo: get these info
/* dr: , /* dr: ,
ur: onUpdate, ur: onUpdate,
fkn*/ fkn*/
} }
); );
populateParams.tableNames.push({ tn: change.tn }); populateParams.tableNames.push({ tn: change.tn });
@ -647,11 +648,11 @@ export default async function(this: BaseApiBuilder<any> | any) {
/* update sort field */ /* update sort field */
/* const sIndex = (sortList || []).findIndex( /* const sIndex = (sortList || []).findIndex(
v => v.field === oldColumn._cn v => v.field === oldColumn._cn
); );
if (sIndex > -1) { if (sIndex > -1) {
sortList.splice(sIndex, 1); sortList.splice(sIndex, 1);
}*/ }*/
for (const sort of sortList || []) { for (const sort of sortList || []) {
if ( if (
sort?.field === oldColumn.cn || sort?.field === oldColumn.cn ||
@ -669,12 +670,12 @@ export default async function(this: BaseApiBuilder<any> | any) {
/* update filters */ /* update filters */
// todo: remove only corresponding filter and compare field name // todo: remove only corresponding filter and compare field name
/* if ( /* if (
filters && filters &&
(JSON.stringify(filters)?.includes(`"${oldColumn.cn}"`) || (JSON.stringify(filters)?.includes(`"${oldColumn.cn}"`) ||
JSON.stringify(filters)?.includes(`"${oldColumn._cn}"`)) JSON.stringify(filters)?.includes(`"${oldColumn._cn}"`))
) { ) {
filters.splice(0, filters.length); filters.splice(0, filters.length);
}*/ }*/
for (const filter of filters) { for (const filter of filters) {
if ( if (
filter?.field === oldColumn.cn || filter?.field === oldColumn.cn ||
@ -769,6 +770,10 @@ export default async function(this: BaseApiBuilder<any> | any) {
await this.xcTablesPopulate(populateParams); await this.xcTablesPopulate(populateParams);
await this.xcTablesPopulate(populateViewsParams); await this.xcTablesPopulate(populateViewsParams);
if (this instanceof GqlApiBuilder) {
await (this as GqlApiBuilder).reInitializeGraphqlEndpoint();
}
return populateParams; return populateParams;
} }

2
packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts

@ -2607,7 +2607,7 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr {
await this.reInitializeGraphqlEndpoint(); await this.reInitializeGraphqlEndpoint();
} }
private async reInitializeGraphqlEndpoint(): Promise<void> { async reInitializeGraphqlEndpoint(): Promise<void> {
this.log( this.log(
`reInitializeGraphqlEndpoint : Reinitializing graphql router endpoint` `reInitializeGraphqlEndpoint : Reinitializing graphql router endpoint`
); );

Loading…
Cancel
Save