Skip to content

Commit

Permalink
GraphQL codegen / start frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixMalfait committed Jun 20, 2024
1 parent 74d0cbe commit c01ab2e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/twenty-front/codegen-metadata.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
schema: process.env.REACT_APP_SERVER_BASE_URL + '/metadata',
schema: (process.env.REACT_APP_SERVER_BASE_URL ?? 'http://localhost:3000') + '/metadata',
documents: [
'./src/modules/databases/graphql/**/*.ts',
'./src/modules/object-metadata/graphql/*.ts',
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-front/codegen.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
schema: process.env.REACT_APP_SERVER_BASE_URL + '/graphql',
schema: (process.env.REACT_APP_SERVER_BASE_URL ?? 'http://localhost:3000') + '/graphql',
documents: [
'!./src/modules/databases/**',
'!./src/modules/object-metadata/**',
Expand Down
20 changes: 11 additions & 9 deletions packages/twenty-front/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ export type Mutation = {
deleteCurrentWorkspace: Workspace;
deleteOneObject: Object;
deleteUser: User;
disablePostgresProxy: PostgresCredentials;
emailPasswordResetLink: EmailPasswordResetLink;
enablePostgresProxy: PostgresCredentials;
exchangeAuthorizationCode: ExchangeAuthCode;
generateApiKeyToken: ApiKeyToken;
generateJWT: AuthTokens;
Expand Down Expand Up @@ -483,6 +485,14 @@ export type PageInfo = {
startCursor?: Maybe<Scalars['ConnectionCursor']>;
};

export type PostgresCredentials = {
__typename?: 'PostgresCredentials';
id: Scalars['UUID'];
password: Scalars['String'];
user: Scalars['String'];
workspaceId: Scalars['String'];
};

export type ProductPriceEntity = {
__typename?: 'ProductPriceEntity';
created: Scalars['Float'];
Expand All @@ -506,6 +516,7 @@ export type Query = {
currentUser: User;
currentWorkspace: Workspace;
findWorkspaceFromInviteHash: Workspace;
getPostgresCredentials?: Maybe<PostgresCredentials>;
getProductPrices: ProductPricesEntity;
getTimelineCalendarEventsFromCompanyId: TimelineCalendarEventsWithTotal;
getTimelineCalendarEventsFromPersonId: TimelineCalendarEventsWithTotal;
Expand Down Expand Up @@ -1061,8 +1072,6 @@ export type GetTimelineThreadsFromPersonIdQueryVariables = Exact<{

export type GetTimelineThreadsFromPersonIdQuery = { __typename?: 'Query', getTimelineThreadsFromPersonId: { __typename?: 'TimelineThreadsWithTotal', totalNumberOfThreads: number, timelineThreads: Array<{ __typename?: 'TimelineThread', id: any, read: boolean, visibility: MessageChannelVisibility, lastMessageReceivedAt: string, lastMessageBody: string, subject: string, numberOfMessagesInThread: number, participantCount: number, firstParticipant: { __typename?: 'TimelineThreadParticipant', personId?: any | null, workspaceMemberId?: any | null, firstName: string, lastName: string, displayName: string, avatarUrl: string, handle: string }, lastTwoParticipants: Array<{ __typename?: 'TimelineThreadParticipant', personId?: any | null, workspaceMemberId?: any | null, firstName: string, lastName: string, displayName: string, avatarUrl: string, handle: string }> }> } };

export type TimelineThreadFragment = { __typename?: 'TimelineThread', id: any, subject: string, lastMessageReceivedAt: string };

export type TrackMutationVariables = Exact<{
type: Scalars['String'];
data: Scalars['JSON'];
Expand Down Expand Up @@ -1364,13 +1373,6 @@ export const TimelineThreadsWithTotalFragmentFragmentDoc = gql`
}
}
${TimelineThreadFragmentFragmentDoc}`;
export const TimelineThreadFragmentDoc = gql`
fragment timelineThread on TimelineThread {
id
subject
lastMessageReceivedAt
}
`;
export const AuthTokenFragmentFragmentDoc = gql`
fragment AuthTokenFragment on AuthToken {
token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const useCreateManyRecords = <

const createManyRecords = async (
recordsToCreate: Partial<CreatedObjectRecord>[],
upsert?: boolean,
) => {
const sanitizedCreateManyRecordsInput = recordsToCreate.map(
(recordToCreate) => {
Expand Down Expand Up @@ -94,6 +95,7 @@ export const useCreateManyRecords = <
mutation: createManyRecordsMutation,
variables: {
data: sanitizedCreateManyRecordsInput,
upsert: upsert,
},
update: (cache, { data }) => {
const records = data?.[mutationResponseField];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ export const useCreateManyRecordsMutation = ({
const createManyRecordsMutation = gql`
mutation Create${capitalize(
objectMetadataItem.namePlural,
)}($data: [${capitalize(objectMetadataItem.nameSingular)}CreateInput!]!) {
${mutationResponseField}(data: $data) ${mapObjectMetadataToGraphQLQuery({
objectMetadataItems,
objectMetadataItem,
recordGqlFields,
})}
)}($data: [${capitalize(
objectMetadataItem.nameSingular,
)}CreateInput!]!, $upsert: upsert) {
${mutationResponseField}(data: $data, upsert: $upsert) ${mapObjectMetadataToGraphQLQuery(
{
objectMetadataItems,
objectMetadataItem,
recordGqlFields,
},
)}
}`;

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const useSpreadsheetRecordImport = (objectNameSingular: string) => {
return fieldMapping;
});
try {
await createManyRecords(createInputs);
await createManyRecords(createInputs, true);
} catch (error: any) {
enqueueSnackBar(error?.message || 'Something went wrong', {
variant: SnackBarVariant.Error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ export class WorkspaceQueryRunnerService {
);

if (existingDuplicate) {
console.log('updating');
const result = await this.updateOne(
{ id: existingDuplicate.id, data: payload },
options,
Expand Down

0 comments on commit c01ab2e

Please sign in to comment.