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
protected getInflectedName(_name: string, inflectionFns: string): string {
let name = _name;
if (process.env.NC_INFLECTION)
if (process.env.NC_INFLECTION) {
inflectionFns = 'camelize';
}
if (inflectionFns && inflectionFns !== 'none') {
name = inflectionFns
.split(',')

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

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

Loading…
Cancel
Save