Remove relations for remotes (#5455)
For remotes, we will only create the foreign key, without the relation metadata. Expected behavior will be: - possible to create an activity. But the remote object will not be displayed in the relations of the activity - the remote objects should not be available in the search for relations Also switched the number settings to an enum, since we now have to handle `BigInt` case. --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -1,22 +1,18 @@
|
||||
import {
|
||||
GraphQLInputObjectType,
|
||||
GraphQLList,
|
||||
GraphQLNonNull,
|
||||
GraphQLInt,
|
||||
} from 'graphql';
|
||||
import { GraphQLInputObjectType, GraphQLList, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLBigInt } from 'graphql-scalars';
|
||||
|
||||
import { FilterIs } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/input/filter-is.input-type';
|
||||
|
||||
export const BigIntFilterType = new GraphQLInputObjectType({
|
||||
name: 'BigIntFilter',
|
||||
fields: {
|
||||
eq: { type: GraphQLInt },
|
||||
gt: { type: GraphQLInt },
|
||||
gte: { type: GraphQLInt },
|
||||
in: { type: new GraphQLList(new GraphQLNonNull(GraphQLInt)) },
|
||||
lt: { type: GraphQLInt },
|
||||
lte: { type: GraphQLInt },
|
||||
neq: { type: GraphQLInt },
|
||||
eq: { type: GraphQLBigInt },
|
||||
gt: { type: GraphQLBigInt },
|
||||
gte: { type: GraphQLBigInt },
|
||||
in: { type: new GraphQLList(new GraphQLNonNull(GraphQLBigInt)) },
|
||||
lt: { type: GraphQLBigInt },
|
||||
lte: { type: GraphQLBigInt },
|
||||
neq: { type: GraphQLBigInt },
|
||||
is: { type: FilterIs },
|
||||
},
|
||||
});
|
||||
|
||||
@ -8,7 +8,6 @@ import {
|
||||
GraphQLID,
|
||||
GraphQLInputObjectType,
|
||||
GraphQLInputType,
|
||||
GraphQLInt,
|
||||
GraphQLList,
|
||||
GraphQLNonNull,
|
||||
GraphQLScalarType,
|
||||
@ -26,7 +25,6 @@ import {
|
||||
BooleanFilterType,
|
||||
BigFloatFilterType,
|
||||
RawJsonFilterType,
|
||||
IntFilterType,
|
||||
} from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/input';
|
||||
import { OrderByDirectionType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/enum';
|
||||
import {
|
||||
@ -36,6 +34,8 @@ import {
|
||||
import { PositionScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars/position.scalar';
|
||||
import { RawJSONScalar } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars/raw-json.scalar';
|
||||
import { IDFilterType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/input/id-filter.input-type';
|
||||
import { getNumberFilterType } from 'src/engine/api/graphql/workspace-schema-builder/utils/get-number-filter-type.util';
|
||||
import { getNumberScalarType } from 'src/engine/api/graphql/workspace-schema-builder/utils/get-number-scalar-type.util';
|
||||
|
||||
export interface TypeOptions<T = any> {
|
||||
nullable?: boolean;
|
||||
@ -57,13 +57,6 @@ export class TypeMapperService {
|
||||
return GraphQLID;
|
||||
}
|
||||
|
||||
const numberScalar =
|
||||
fieldMetadataType === FieldMetadataType.NUMBER &&
|
||||
(settings as FieldMetadataSettings<FieldMetadataType.NUMBER>)
|
||||
?.precision === 0
|
||||
? GraphQLInt
|
||||
: GraphQLFloat;
|
||||
|
||||
const typeScalarMapping = new Map<FieldMetadataType, GraphQLScalarType>([
|
||||
[FieldMetadataType.UUID, UUIDScalarType],
|
||||
[FieldMetadataType.TEXT, GraphQLString],
|
||||
@ -72,7 +65,13 @@ export class TypeMapperService {
|
||||
[FieldMetadataType.DATE_TIME, GraphQLISODateTime],
|
||||
[FieldMetadataType.DATE, GraphQLISODateTime],
|
||||
[FieldMetadataType.BOOLEAN, GraphQLBoolean],
|
||||
[FieldMetadataType.NUMBER, numberScalar],
|
||||
[
|
||||
FieldMetadataType.NUMBER,
|
||||
getNumberScalarType(
|
||||
(settings as FieldMetadataSettings<FieldMetadataType.NUMBER>)
|
||||
?.dataType,
|
||||
),
|
||||
],
|
||||
[FieldMetadataType.NUMERIC, BigFloatScalarType],
|
||||
[FieldMetadataType.PROBABILITY, GraphQLFloat],
|
||||
[FieldMetadataType.POSITION, PositionScalarType],
|
||||
@ -91,13 +90,6 @@ export class TypeMapperService {
|
||||
return IDFilterType;
|
||||
}
|
||||
|
||||
const numberScalar =
|
||||
fieldMetadataType === FieldMetadataType.NUMBER &&
|
||||
(settings as FieldMetadataSettings<FieldMetadataType.NUMBER>)
|
||||
?.precision === 0
|
||||
? IntFilterType
|
||||
: FloatFilterType;
|
||||
|
||||
const typeFilterMapping = new Map<
|
||||
FieldMetadataType,
|
||||
GraphQLInputObjectType | GraphQLScalarType
|
||||
@ -109,7 +101,13 @@ export class TypeMapperService {
|
||||
[FieldMetadataType.DATE_TIME, DateFilterType],
|
||||
[FieldMetadataType.DATE, DateFilterType],
|
||||
[FieldMetadataType.BOOLEAN, BooleanFilterType],
|
||||
[FieldMetadataType.NUMBER, numberScalar],
|
||||
[
|
||||
FieldMetadataType.NUMBER,
|
||||
getNumberFilterType(
|
||||
(settings as FieldMetadataSettings<FieldMetadataType.NUMBER>)
|
||||
?.dataType,
|
||||
),
|
||||
],
|
||||
[FieldMetadataType.NUMERIC, BigFloatFilterType],
|
||||
[FieldMetadataType.PROBABILITY, FloatFilterType],
|
||||
[FieldMetadataType.POSITION, FloatFilterType],
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
import { GraphQLInputObjectType } from 'graphql';
|
||||
|
||||
import { NumberDataType } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-settings.interface';
|
||||
|
||||
import {
|
||||
BigIntFilterType,
|
||||
FloatFilterType,
|
||||
IntFilterType,
|
||||
} from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/input';
|
||||
|
||||
export const getNumberFilterType = (
|
||||
subType: NumberDataType | undefined,
|
||||
): GraphQLInputObjectType => {
|
||||
switch (subType) {
|
||||
case NumberDataType.FLOAT:
|
||||
return FloatFilterType;
|
||||
case NumberDataType.BIGINT:
|
||||
return BigIntFilterType;
|
||||
case NumberDataType.INT:
|
||||
return IntFilterType;
|
||||
default:
|
||||
return FloatFilterType;
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,19 @@
|
||||
import { GraphQLInt, GraphQLFloat, GraphQLScalarType } from 'graphql';
|
||||
import { GraphQLBigInt } from 'graphql-scalars';
|
||||
|
||||
import { NumberDataType } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-settings.interface';
|
||||
|
||||
export const getNumberScalarType = (
|
||||
dataType: NumberDataType,
|
||||
): GraphQLScalarType => {
|
||||
switch (dataType) {
|
||||
case NumberDataType.FLOAT:
|
||||
return GraphQLFloat;
|
||||
case NumberDataType.BIGINT:
|
||||
return GraphQLBigInt;
|
||||
case NumberDataType.INT:
|
||||
return GraphQLInt;
|
||||
default:
|
||||
return GraphQLFloat;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user