From e66d047d5104d3df77210b4f3c3fed7920edc1cf Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 1 Aug 2022 21:53:39 +0800 Subject: [PATCH] Add createIntegration API to the GQL schema --- packages/api/src/entity/integration.ts | 8 +- packages/api/src/generated/graphql.ts | 83 +++++++++++++++++++ packages/api/src/generated/schema.graphql | 35 ++++++++ packages/api/src/schema.ts | 37 +++++++++ .../db/migrations/0090.do.integrations.sql | 8 +- .../db/migrations/0090.undo.integrations.sql | 2 + 6 files changed, 168 insertions(+), 5 deletions(-) diff --git a/packages/api/src/entity/integration.ts b/packages/api/src/entity/integration.ts index 406e820db..c4d2bbc88 100644 --- a/packages/api/src/entity/integration.ts +++ b/packages/api/src/entity/integration.ts @@ -9,6 +9,10 @@ import { } from 'typeorm' import { User } from './user' +export enum IntegrationType { + Readwise = 'READWISE', +} + @Entity({ name: 'integrations' }) export class Integration { @PrimaryGeneratedColumn('uuid') @@ -18,8 +22,8 @@ export class Integration { @JoinColumn({ name: 'user_id' }) user!: User - @Column('varchar') - name!: string + @Column('enum', { enum: IntegrationType }) + type!: IntegrationType @Column('varchar') token!: string diff --git a/packages/api/src/generated/graphql.ts b/packages/api/src/generated/graphql.ts index 1ce355cbd..3a8ca3dc9 100644 --- a/packages/api/src/generated/graphql.ts +++ b/packages/api/src/generated/graphql.ts @@ -331,6 +331,30 @@ export type CreateHighlightSuccess = { highlight: Highlight; }; +export type CreateIntegrationError = { + __typename?: 'CreateIntegrationError'; + errorCodes: Array; +}; + +export enum CreateIntegrationErrorCode { + BadRequest = 'BAD_REQUEST', + InvalidToken = 'INVALID_TOKEN', + NotFound = 'NOT_FOUND', + Unauthorized = 'UNAUTHORIZED' +} + +export type CreateIntegrationInput = { + token: Scalars['String']; + type: IntegrationType; +}; + +export type CreateIntegrationResult = CreateIntegrationError | CreateIntegrationSuccess; + +export type CreateIntegrationSuccess = { + __typename?: 'CreateIntegrationSuccess'; + integration: Integration; +}; + export type CreateLabelError = { __typename?: 'CreateLabelError'; errorCodes: Array; @@ -745,6 +769,19 @@ export type HighlightStats = { highlightCount: Scalars['Int']; }; +export type Integration = { + __typename?: 'Integration'; + createdAt: Scalars['Date']; + enabled: Scalars['Boolean']; + id: Scalars['ID']; + type: IntegrationType; + updatedAt: Scalars['Date']; +}; + +export enum IntegrationType { + Readwise = 'READWISE' +} + export type Label = { __typename?: 'Label'; color: Scalars['String']; @@ -897,6 +934,7 @@ export type Mutation = { createArticleSavingRequest: CreateArticleSavingRequestResult; createHighlight: CreateHighlightResult; createHighlightReply: CreateHighlightReplyResult; + createIntegration: CreateIntegrationResult; createLabel: CreateLabelResult; createNewsletterEmail: CreateNewsletterEmailResult; createReaction: CreateReactionResult; @@ -971,6 +1009,11 @@ export type MutationCreateHighlightReplyArgs = { }; +export type MutationCreateIntegrationArgs = { + input: CreateIntegrationInput; +}; + + export type MutationCreateLabelArgs = { input: CreateLabelInput; }; @@ -2505,6 +2548,11 @@ export type ResolversTypes = { CreateHighlightReplySuccess: ResolverTypeWrapper; CreateHighlightResult: ResolversTypes['CreateHighlightError'] | ResolversTypes['CreateHighlightSuccess']; CreateHighlightSuccess: ResolverTypeWrapper; + CreateIntegrationError: ResolverTypeWrapper; + CreateIntegrationErrorCode: CreateIntegrationErrorCode; + CreateIntegrationInput: CreateIntegrationInput; + CreateIntegrationResult: ResolversTypes['CreateIntegrationError'] | ResolversTypes['CreateIntegrationSuccess']; + CreateIntegrationSuccess: ResolverTypeWrapper; CreateLabelError: ResolverTypeWrapper; CreateLabelErrorCode: CreateLabelErrorCode; CreateLabelInput: CreateLabelInput; @@ -2592,6 +2640,8 @@ export type ResolversTypes = { HighlightStats: ResolverTypeWrapper; ID: ResolverTypeWrapper; Int: ResolverTypeWrapper; + Integration: ResolverTypeWrapper; + IntegrationType: IntegrationType; Label: ResolverTypeWrapper