Remove singular/plural from field-metadata (#2085)

* Remove singular/plural from field-metadata

* revert removing id from create input

* remove console log

* remove console log

* codegen

* missing files

* fix tests
This commit is contained in:
Weiko 2023-10-17 15:21:58 +02:00 committed by GitHub
parent 0d6386bc8d
commit 1344e78acb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 213 additions and 130 deletions

View File

@ -14,8 +14,8 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
*/
const documents = {
"\n mutation CreateOneObject($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n }\n }\n": types.CreateOneObjectDocument,
"\n mutation CreateOneField($input: CreateOneFieldInput!) {\n createOneField(input: $input) {\n id\n type\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n": types.CreateOneFieldDocument,
"\n query Objects {\n objects(paging: { first: 100 }) {\n edges {\n node {\n id\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 100 }) {\n edges {\n node {\n id\n type\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n": types.ObjectsDocument,
"\n mutation CreateOneField($input: CreateOneFieldInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n": types.CreateOneFieldDocument,
"\n query Objects {\n objects(paging: { first: 100 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 100 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n": types.ObjectsDocument,
};
/**
@ -39,11 +39,11 @@ export function graphql(source: "\n mutation CreateOneObject($input: CreateOneO
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n mutation CreateOneField($input: CreateOneFieldInput!) {\n createOneField(input: $input) {\n id\n type\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n"): (typeof documents)["\n mutation CreateOneField($input: CreateOneFieldInput!) {\n createOneField(input: $input) {\n id\n type\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n"];
export function graphql(source: "\n mutation CreateOneField($input: CreateOneFieldInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n"): (typeof documents)["\n mutation CreateOneField($input: CreateOneFieldInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query Objects {\n objects(paging: { first: 100 }) {\n edges {\n node {\n id\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 100 }) {\n edges {\n node {\n id\n type\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n"): (typeof documents)["\n query Objects {\n objects(paging: { first: 100 }) {\n edges {\n node {\n id\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 100 }) {\n edges {\n node {\n id\n type\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n"];
export function graphql(source: "\n query Objects {\n objects(paging: { first: 100 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 100 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n"): (typeof documents)["\n query Objects {\n objects(paging: { first: 100 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 100 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n"];
export function graphql(source: string) {
return (documents as any)[source] ?? {};

View File

@ -171,12 +171,9 @@ export type Company = {
export type CreateFieldInput = {
description?: InputMaybe<Scalars['String']['input']>;
icon?: InputMaybe<Scalars['String']['input']>;
labelPlural?: InputMaybe<Scalars['String']['input']>;
labelSingular: Scalars['String']['input'];
namePlural?: InputMaybe<Scalars['String']['input']>;
nameSingular: Scalars['String']['input'];
label: Scalars['String']['input'];
name: Scalars['String']['input'];
objectId: Scalars['String']['input'];
placeholder?: InputMaybe<Scalars['String']['input']>;
type: Scalars['String']['input'];
};
@ -381,6 +378,16 @@ export type CursorPaging = {
last?: InputMaybe<Scalars['Int']['input']>;
};
export type DeleteOneFieldInput = {
/** The id of the record to delete. */
id: Scalars['ID']['input'];
};
export type DeleteOneObjectInput = {
/** The id of the record to delete. */
id: Scalars['ID']['input'];
};
export type Favorite = {
__typename?: 'Favorite';
company?: Maybe<Company>;
@ -403,10 +410,29 @@ export type FieldConnection = {
totalCount: Scalars['Int']['output'];
};
export type FieldDeleteResponse = {
__typename?: 'FieldDeleteResponse';
createdAt?: Maybe<Scalars['DateTime']['output']>;
description?: Maybe<Scalars['String']['output']>;
icon?: Maybe<Scalars['String']['output']>;
id?: Maybe<Scalars['ID']['output']>;
isActive?: Maybe<Scalars['Boolean']['output']>;
isCustom?: Maybe<Scalars['Boolean']['output']>;
isNullable?: Maybe<Scalars['Boolean']['output']>;
label?: Maybe<Scalars['String']['output']>;
name?: Maybe<Scalars['String']['output']>;
/** @deprecated Use label name instead */
placeholder?: Maybe<Scalars['String']['output']>;
type?: Maybe<Scalars['String']['output']>;
updatedAt?: Maybe<Scalars['DateTime']['output']>;
};
export type Mutation = {
__typename?: 'Mutation';
createOneField: Field;
createOneObject: Object;
deleteOneField: FieldDeleteResponse;
deleteOneObject: ObjectDeleteResponse;
updateOneField: Field;
updateOneObject: Object;
};
@ -422,6 +448,16 @@ export type MutationCreateOneObjectArgs = {
};
export type MutationDeleteOneFieldArgs = {
input: DeleteOneFieldInput;
};
export type MutationDeleteOneObjectArgs = {
input: DeleteOneObjectInput;
};
export type MutationUpdateOneFieldArgs = {
input: UpdateOneFieldInput;
};
@ -441,6 +477,22 @@ export type ObjectConnection = {
totalCount: Scalars['Int']['output'];
};
export type ObjectDeleteResponse = {
__typename?: 'ObjectDeleteResponse';
createdAt?: Maybe<Scalars['DateTime']['output']>;
dataSourceId?: Maybe<Scalars['String']['output']>;
description?: Maybe<Scalars['String']['output']>;
icon?: Maybe<Scalars['String']['output']>;
id?: Maybe<Scalars['ID']['output']>;
isActive?: Maybe<Scalars['Boolean']['output']>;
isCustom?: Maybe<Scalars['Boolean']['output']>;
labelPlural?: Maybe<Scalars['String']['output']>;
labelSingular?: Maybe<Scalars['String']['output']>;
namePlural?: Maybe<Scalars['String']['output']>;
nameSingular?: Maybe<Scalars['String']['output']>;
updatedAt?: Maybe<Scalars['DateTime']['output']>;
};
export type ObjectFieldsConnection = {
__typename?: 'ObjectFieldsConnection';
/** Array of edges. */
@ -582,11 +634,8 @@ export type UpdateFieldInput = {
description?: InputMaybe<Scalars['String']['input']>;
icon?: InputMaybe<Scalars['String']['input']>;
isActive?: InputMaybe<Scalars['Boolean']['input']>;
labelPlural?: InputMaybe<Scalars['String']['input']>;
labelSingular?: InputMaybe<Scalars['String']['input']>;
namePlural?: InputMaybe<Scalars['String']['input']>;
nameSingular?: InputMaybe<Scalars['String']['input']>;
placeholder?: InputMaybe<Scalars['String']['input']>;
label: Scalars['String']['input'];
name: Scalars['String']['input'];
};
export type UpdateObjectInput = {
@ -767,10 +816,9 @@ export type Field = {
isActive: Scalars['Boolean']['output'];
isCustom: Scalars['Boolean']['output'];
isNullable: Scalars['Boolean']['output'];
labelPlural: Scalars['String']['output'];
labelSingular: Scalars['String']['output'];
namePlural: Scalars['String']['output'];
nameSingular: Scalars['String']['output'];
label: Scalars['String']['output'];
name: Scalars['String']['output'];
/** @deprecated Use label name instead */
placeholder?: Maybe<Scalars['String']['output']>;
type: Scalars['String']['output'];
updatedAt: Scalars['DateTime']['output'];
@ -826,14 +874,14 @@ export type CreateOneFieldMutationVariables = Exact<{
}>;
export type CreateOneFieldMutation = { __typename?: 'Mutation', createOneField: { __typename?: 'field', id: string, type: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } };
export type CreateOneFieldMutation = { __typename?: 'Mutation', createOneField: { __typename?: 'field', id: string, type: string, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } };
export type ObjectsQueryVariables = Exact<{ [key: string]: never; }>;
export type ObjectsQuery = { __typename?: 'Query', objects: { __typename?: 'ObjectConnection', totalCount: number, edges: Array<{ __typename?: 'objectEdge', node: { __typename?: 'object', id: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any, fields: { __typename?: 'ObjectFieldsConnection', totalCount: number, edges: Array<{ __typename?: 'fieldEdge', node: { __typename?: 'field', id: string, type: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } };
export type ObjectsQuery = { __typename?: 'Query', objects: { __typename?: 'ObjectConnection', totalCount: number, edges: Array<{ __typename?: 'objectEdge', node: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any, fields: { __typename?: 'ObjectFieldsConnection', totalCount: number, edges: Array<{ __typename?: 'fieldEdge', node: { __typename?: 'field', id: string, type: string, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } };
export const CreateOneObjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneObject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateOneObjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<CreateOneObjectMutation, CreateOneObjectMutationVariables>;
export const CreateOneFieldDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneField"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateOneFieldInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneField"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<CreateOneFieldMutation, CreateOneFieldMutationVariables>;
export const ObjectsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Objects"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"objects"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"fields"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]} as unknown as DocumentNode<ObjectsQuery, ObjectsQueryVariables>;
export const CreateOneFieldDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneField"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateOneFieldInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneField"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<CreateOneFieldMutation, CreateOneFieldMutationVariables>;
export const ObjectsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Objects"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"objects"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"fields"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]} as unknown as DocumentNode<ObjectsQuery, ObjectsQueryVariables>;

View File

@ -1298,6 +1298,23 @@ export type FieldConnection = {
totalCount: Scalars['Int'];
};
export type FieldDeleteResponse = {
__typename?: 'FieldDeleteResponse';
createdAt?: Maybe<Scalars['DateTime']>;
description?: Maybe<Scalars['String']>;
icon?: Maybe<Scalars['String']>;
id?: Maybe<Scalars['ID']>;
isActive?: Maybe<Scalars['Boolean']>;
isCustom?: Maybe<Scalars['Boolean']>;
isNullable?: Maybe<Scalars['Boolean']>;
label?: Maybe<Scalars['String']>;
name?: Maybe<Scalars['String']>;
/** @deprecated Use label name instead */
placeholder?: Maybe<Scalars['String']>;
type?: Maybe<Scalars['String']>;
updatedAt?: Maybe<Scalars['DateTime']>;
};
export enum FileFolder {
Attachment = 'Attachment',
PersonPicture = 'PersonPicture',
@ -1848,6 +1865,22 @@ export type ObjectConnection = {
totalCount: Scalars['Int'];
};
export type ObjectDeleteResponse = {
__typename?: 'ObjectDeleteResponse';
createdAt?: Maybe<Scalars['DateTime']>;
dataSourceId?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
icon?: Maybe<Scalars['String']>;
id?: Maybe<Scalars['ID']>;
isActive?: Maybe<Scalars['Boolean']>;
isCustom?: Maybe<Scalars['Boolean']>;
labelPlural?: Maybe<Scalars['String']>;
labelSingular?: Maybe<Scalars['String']>;
namePlural?: Maybe<Scalars['String']>;
nameSingular?: Maybe<Scalars['String']>;
updatedAt?: Maybe<Scalars['DateTime']>;
};
export type ObjectFieldsConnection = {
__typename?: 'ObjectFieldsConnection';
/** Array of edges. */
@ -3540,10 +3573,9 @@ export type Field = {
isActive: Scalars['Boolean'];
isCustom: Scalars['Boolean'];
isNullable: Scalars['Boolean'];
labelPlural: Scalars['String'];
labelSingular: Scalars['String'];
namePlural: Scalars['String'];
nameSingular: Scalars['String'];
label: Scalars['String'];
name: Scalars['String'];
/** @deprecated Use label name instead */
placeholder?: Maybe<Scalars['String']>;
type: Scalars['String'];
updatedAt: Scalars['DateTime'];

View File

@ -13,10 +13,8 @@ export const CREATE_ONE_FIELD = gql`
createOneField(input: $input) {
id
type
nameSingular
namePlural
labelSingular
labelPlural
name
label
description
icon
placeholder

View File

@ -22,10 +22,8 @@ export const GET_ALL_OBJECTS = gql`
node {
id
type
nameSingular
namePlural
labelSingular
labelPlural
name
label
description
icon
placeholder

View File

@ -45,13 +45,10 @@ export const useSeedCustomObjectsTemp = () => {
input: {
field: {
objectId: supplierObjectId,
labelSingular: 'Name',
nameSingular: 'name',
label: 'Name',
name: 'name',
type: 'text',
description: 'Name',
labelPlural: 'Names',
namePlural: 'names',
placeholder: 'Name',
icon: 'IconBuilding',
},
},
@ -67,13 +64,10 @@ export const useSeedCustomObjectsTemp = () => {
input: {
field: {
objectId: supplierObjectId,
labelSingular: 'City',
nameSingular: 'city',
label: 'City',
name: 'city',
type: 'text',
description: 'City',
labelPlural: 'Cities',
namePlural: 'cities',
placeholder: 'City',
icon: 'IconMap',
},
},

View File

@ -15,9 +15,7 @@ export const generateFindManyCustomObjectsQuery = ({
edges {
node {
id
${metadataObject.fields
.map((field) => field.nameSingular)
.join('\n')}
${metadataObject.fields.map((field) => field.name).join('\n')}
}
cursor
}

View File

@ -13,22 +13,12 @@ export class CreateFieldInput {
@IsString()
@IsNotEmpty()
@Field()
nameSingular: string;
@IsString()
@IsOptional()
@Field({ nullable: true })
namePlural?: string;
name: string;
@IsString()
@IsNotEmpty()
@Field()
labelSingular: string;
@IsString()
@IsOptional()
@Field({ nullable: true })
labelPlural?: string;
label: string;
// Todo: use a type enum and share with typeorm entity
@IsEnum([

View File

@ -1,28 +1,18 @@
import { Field, InputType } from '@nestjs/graphql';
import { IsBoolean, IsOptional, IsString } from 'class-validator';
import { IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator';
@InputType()
export class UpdateFieldInput {
@IsString()
@IsOptional()
@Field({ nullable: true })
nameSingular?: string;
@IsNotEmpty()
@Field()
name: string;
@IsString()
@IsOptional()
@Field({ nullable: true })
namePlural?: string;
@IsString()
@IsOptional()
@Field({ nullable: true })
labelSingular?: string;
@IsString()
@IsOptional()
@Field({ nullable: true })
labelPlural?: string;
@IsNotEmpty()
@Field()
label: string;
@IsString()
@IsOptional()

View File

@ -38,7 +38,7 @@ export const fieldMetadataAutoResolverOpts: AutoResolverOpts<
update: {
many: { disabled: true },
},
delete: { disabled: true },
delete: { many: { disabled: true } },
guards: [JwtAuthGuard],
},
];

View File

@ -51,20 +51,12 @@ export class FieldMetadata {
type: string;
@Field()
@Column({ nullable: false, name: 'name_singular' })
nameSingular: string;
@Column({ nullable: false })
name: string;
@Field()
@Column({ nullable: true, name: 'name_plural' })
namePlural: string;
@Field()
@Column({ nullable: false, name: 'label_singular' })
labelSingular: string;
@Field()
@Column({ nullable: true, name: 'label_plural' })
labelPlural: string;
@Column({ nullable: false })
label: string;
@Column({ nullable: false, name: 'target_column_map', type: 'jsonb' })
targetColumnMap: FieldMetadataTargetColumnMap;

View File

@ -44,8 +44,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadata> {
const fieldAlreadyExists = await this.fieldMetadataRepository.findOne({
where: {
nameSingular: record.nameSingular,
namePlural: record.namePlural,
name: record.name,
objectId: record.objectId,
workspaceId: record.workspaceId,
},

View File

@ -10,6 +10,7 @@ import { AddTargetColumnMap1696409050890 } from './migrations/1696409050890-add-
import { MetadataNameLabelRefactoring1697126636202 } from './migrations/1697126636202-MetadataNameLabelRefactoring';
import { RemoveFieldMetadataPlaceholder1697471445015 } from './migrations/1697471445015-removeFieldMetadataPlaceholder';
import { AddSoftDelete1697474804403 } from './migrations/1697474804403-addSoftDelete';
import { RemoveSingularPluralFromFieldLabelAndName1697534910933 } from './migrations/1697534910933-removeSingularPluralFromFieldLabelAndName';
config();
@ -31,6 +32,7 @@ export const typeORMMetadataModuleOptions: TypeOrmModuleOptions = {
MetadataNameLabelRefactoring1697126636202,
RemoveFieldMetadataPlaceholder1697471445015,
AddSoftDelete1697474804403,
RemoveSingularPluralFromFieldLabelAndName1697534910933,
],
};

View File

@ -116,17 +116,17 @@ export class MigrationRunnerService {
default: 'public.uuid_generate_v4()',
},
{
name: 'created_at',
name: 'createdAt',
type: 'timestamp',
default: 'now()',
},
{
name: 'updated_at',
name: 'updatedAt',
type: 'timestamp',
default: 'now()',
},
{
name: 'deleted_at',
name: 'deletedAt',
type: 'timestamp',
isNullable: true,
},

View File

@ -0,0 +1,49 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class RemoveSingularPluralFromFieldLabelAndName1697534910933
implements MigrationInterface
{
name = 'RemoveSingularPluralFromFieldLabelAndName1697534910933';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" DROP COLUMN "name_singular"`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" DROP COLUMN "name_plural"`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" DROP COLUMN "label_singular"`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" DROP COLUMN "label_plural"`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" ADD "name" character varying NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" ADD "label" character varying NOT NULL`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" DROP COLUMN "label"`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" DROP COLUMN "name"`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" ADD "label_plural" character varying`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" ADD "label_singular" character varying NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" ADD "name_plural" character varying`,
);
await queryRunner.query(
`ALTER TABLE "metadata"."field_metadata" ADD "name_singular" character varying NOT NULL`,
);
}
}

View File

@ -30,7 +30,7 @@ export class BeforeCreateOneObject<T extends ObjectMetadata>
);
instance.input.dataSourceId = lastDataSourceMetadata.id;
instance.input.targetTableName = instance.input.nameSingular;
instance.input.targetTableName = instance.input.namePlural;
instance.input.workspaceId = workspaceId;
instance.input.isActive = false;
instance.input.isCustom = true;

View File

@ -38,6 +38,7 @@ export const objectMetadataAutoResolverOpts: AutoResolverOpts<
update: {
many: { disabled: true },
},
delete: { many: { disabled: true } },
guards: [JwtAuthGuard],
},
];

View File

@ -36,19 +36,19 @@ describe('PGGraphQLQueryBuilder', () => {
beforeEach(() => {
const fields = [
{
nameSingular: 'name',
name: 'name',
targetColumnMap: {
value: 'column_name',
} as FieldMetadataTargetColumnMap,
},
{
nameSingular: 'age',
name: 'age',
targetColumnMap: {
value: 'column_age',
} as FieldMetadataTargetColumnMap,
},
{
nameSingular: 'complexField',
name: 'complexField',
targetColumnMap: {
subField1: 'column_subField1',
subField2: 'column_subField2',

View File

@ -10,21 +10,21 @@ describe('convertArguments', () => {
beforeEach(() => {
fields = [
{
nameSingular: 'firstName',
name: 'firstName',
targetColumnMap: {
value: 'column_1randomFirstNameKey',
} as FieldMetadataTargetColumnMap,
type: 'text',
},
{
nameSingular: 'age',
name: 'age',
targetColumnMap: {
value: 'column_randomAgeKey',
} as FieldMetadataTargetColumnMap,
type: 'text',
},
{
nameSingular: 'website',
name: 'website',
targetColumnMap: {
link: 'column_randomLinkKey',
text: 'column_randomTex7Key',

View File

@ -12,13 +12,13 @@ describe('convertFieldsToGraphQL', () => {
beforeEach(() => {
fields = [
{
nameSingular: 'simpleField',
name: 'simpleField',
targetColumnMap: {
value: 'column_RANDOMSTRING1',
} as FieldMetadataTargetColumnMap,
},
{
nameSingular: 'complexField',
name: 'complexField',
targetColumnMap: {
link: 'column_RANDOMSTRING2',
text: 'column_RANDOMSTRING3',
@ -74,7 +74,7 @@ describe('convertFieldsToGraphQL', () => {
test('should handle empty targetColumnMap gracefully', () => {
const emptyField = {
nameSingular: 'emptyField',
name: 'emptyField',
targetColumnMap: {},
} as FieldMetadata;

View File

@ -11,15 +11,13 @@ describe('getFieldAliases', () => {
// Setup sample field metadata
fields = [
{
nameSingular: 'singleValueField',
namePlural: 'singleValueFields',
name: 'singleValueField',
targetColumnMap: {
value: 'column_singleValue',
} as FieldMetadataTargetColumnMap,
},
{
nameSingular: 'multipleValuesField',
namePlural: 'multipleValuesFields',
name: 'multipleValuesField',
targetColumnMap: {
link: 'column_value1',
text: 'column_value2',
@ -47,8 +45,7 @@ describe('getFieldAliases', () => {
const fieldsWithEmptyMap = [
...fields,
{
nameSingular: 'emptyField',
namePlural: 'emptyFields',
name: 'emptyField',
targetColumnMap: {} as FieldMetadataTargetColumnMap,
},
] as FieldMetadata[];

View File

@ -4,8 +4,7 @@ import { FieldMetadata } from 'src/metadata/field-metadata/field-metadata.entity
export const convertArguments = (args: any, fields: FieldMetadata[]): any => {
const fieldsMap = new Map(
// TODO: Handle plural for fields when we add relations
fields.map((metadata) => [metadata.nameSingular, metadata]),
fields.map((metadata) => [metadata.name, metadata]),
);
if (Array.isArray(args)) {

View File

@ -8,8 +8,7 @@ export const convertFieldsToGraphQL = (
acc = '',
) => {
const fieldsMap = new Map(
// TODO: Handle plural for fields when we add relations
fields.map((metadata) => [metadata.nameSingular, metadata]),
fields.map((metadata) => [metadata.name, metadata]),
);
for (const [key, value] of Object.entries(select)) {
@ -29,9 +28,7 @@ export const convertFieldsToGraphQL = (
// Otherwise it means it's a special type with multiple values, so we need fetch all fields
fieldAlias = `
${entries
.map(
([key, value]) => `___${metadata.nameSingular}_${key}: ${value}`,
)
.map(([key, value]) => `___${metadata.name}_${key}: ${value}`)
.join('\n')}
`;
}

View File

@ -7,8 +7,7 @@ export const getFieldAliases = (fields: FieldMetadata[]) => {
if (values.length === 1) {
return {
...acc,
// TODO: Handle plural for fields when we add relations
[column.nameSingular]: values[0],
[column.name]: values[0],
};
} else {
return {

View File

@ -30,12 +30,12 @@ describe('generateCreateInputType', () => {
test('should generate fields with correct types and descriptions', () => {
const columns = [
{
nameSingular: 'firstName',
name: 'firstName',
type: 'text',
isNullable: false,
},
{
nameSingular: 'age',
name: 'age',
type: 'number',
isNullable: true,
},

View File

@ -46,12 +46,12 @@ describe('generateObjectType', () => {
test('should generate fields based on provided columns', () => {
const columns = [
{
nameSingular: 'firstName',
name: 'firstName',
type: 'text',
isNullable: false,
},
{
nameSingular: 'age',
name: 'age',
type: 'number',
isNullable: true,
},

View File

@ -29,12 +29,12 @@ describe('generateUpdateInputType', () => {
test('should generate fields with correct types and descriptions', () => {
const columns = [
{
nameSingular: 'firstName',
name: 'firstName',
type: 'text',
isNullable: true,
},
{
nameSingular: 'age',
name: 'age',
type: 'number',
isNullable: true,
},

View File

@ -40,7 +40,7 @@ describe('mapColumnTypeToGraphQLType', () => {
test('should create a GraphQLEnumType for enum fields', () => {
const column = new FieldMetadata();
column.type = 'enum';
column.nameSingular = 'Status';
column.name = 'Status';
column.enums = ['ACTIVE', 'INACTIVE'];
const result = mapColumnTypeToGraphQLType(column);

View File

@ -22,7 +22,7 @@ export const generateCreateInputType = (
columns.forEach((column) => {
const graphqlType = mapColumnTypeToGraphQLType(column, true);
fields[column.nameSingular] = {
fields[column.name] = {
type: !column.isNullable ? new GraphQLNonNull(graphqlType) : graphqlType,
};
});

View File

@ -33,7 +33,7 @@ export const generateObjectType = <TSource = any, TContext = any>(
columns.forEach((column) => {
const graphqlType = mapColumnTypeToGraphQLType(column);
fields[column.nameSingular] = {
fields[column.name] = {
type: !column.isNullable ? new GraphQLNonNull(graphqlType) : graphqlType,
};
});

View File

@ -22,7 +22,7 @@ export const generateUpdateInputType = (
columns.forEach((column) => {
const graphqlType = mapColumnTypeToGraphQLType(column, true);
// No GraphQLNonNull wrapping here, so all fields are optional
fields[column.nameSingular] = {
fields[column.name] = {
type: graphqlType,
};
});

View File

@ -65,7 +65,7 @@ export const mapColumnTypeToGraphQLType = (
return GraphQLInt;
case 'enum': {
if (column.enums && column.enums.length > 0) {
const enumName = `${pascalCase(column.nameSingular)}Enum`;
const enumName = `${pascalCase(column.name)}Enum`;
return new GraphQLEnumType({
name: enumName,