mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Remove functions from non-read actions in GraphQL types (#15251)
This commit is contained in:
@@ -425,44 +425,46 @@ export class GraphQLService {
|
||||
},
|
||||
};
|
||||
|
||||
if (field.type === 'date') {
|
||||
acc[`${field.field}_func`] = {
|
||||
type: DateFunctions,
|
||||
resolve: (obj: Record<string, any>) => {
|
||||
const funcFields = Object.keys(DateFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
||||
return mapKeys(pick(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
||||
},
|
||||
};
|
||||
}
|
||||
if (action === 'read') {
|
||||
if (field.type === 'date') {
|
||||
acc[`${field.field}_func`] = {
|
||||
type: DateFunctions,
|
||||
resolve: (obj: Record<string, any>) => {
|
||||
const funcFields = Object.keys(DateFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
||||
return mapKeys(pick(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (field.type === 'time') {
|
||||
acc[`${field.field}_func`] = {
|
||||
type: TimeFunctions,
|
||||
resolve: (obj: Record<string, any>) => {
|
||||
const funcFields = Object.keys(TimeFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
||||
return mapKeys(pick(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
||||
},
|
||||
};
|
||||
}
|
||||
if (field.type === 'time') {
|
||||
acc[`${field.field}_func`] = {
|
||||
type: TimeFunctions,
|
||||
resolve: (obj: Record<string, any>) => {
|
||||
const funcFields = Object.keys(TimeFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
||||
return mapKeys(pick(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (field.type === 'dateTime' || field.type === 'timestamp') {
|
||||
acc[`${field.field}_func`] = {
|
||||
type: DateTimeFunctions,
|
||||
resolve: (obj: Record<string, any>) => {
|
||||
const funcFields = Object.keys(DateTimeFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
||||
return mapKeys(pick(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
||||
},
|
||||
};
|
||||
}
|
||||
if (field.type === 'dateTime' || field.type === 'timestamp') {
|
||||
acc[`${field.field}_func`] = {
|
||||
type: DateTimeFunctions,
|
||||
resolve: (obj: Record<string, any>) => {
|
||||
const funcFields = Object.keys(DateTimeFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
||||
return mapKeys(pick(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (field.type === 'json' || field.type === 'alias') {
|
||||
acc[`${field.field}_func`] = {
|
||||
type: CountFunctions,
|
||||
resolve: (obj: Record<string, any>) => {
|
||||
const funcFields = Object.keys(CountFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
||||
return mapKeys(pick(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
||||
},
|
||||
};
|
||||
if (field.type === 'json' || field.type === 'alias') {
|
||||
acc[`${field.field}_func`] = {
|
||||
type: CountFunctions,
|
||||
resolve: (obj: Record<string, any>) => {
|
||||
const funcFields = Object.keys(CountFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
||||
return mapKeys(pick(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
|
||||
Reference in New Issue
Block a user