From 3a5140c1b4b02ab66201826df007805f7545003d Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Thu, 17 Jun 2021 03:28:51 +0100 Subject: [PATCH] Update gql types and operations --- src/graphql/chat.api.support.ts | 96 ++++++++++++++ src/graphql/types.support.ts | 214 ++++++++++++++++++++++++++++++++ 2 files changed, 310 insertions(+) create mode 100644 src/graphql/chat.api.support.ts create mode 100644 src/graphql/types.support.ts diff --git a/src/graphql/chat.api.support.ts b/src/graphql/chat.api.support.ts new file mode 100644 index 0000000..1c0417d --- /dev/null +++ b/src/graphql/chat.api.support.ts @@ -0,0 +1,96 @@ +import gql from 'graphql-tag'; + +export const GET_PROJECT_THREADS = gql` + query GetProjectThreads($projectId: String!) { + getProjectThreads(projectId: $projectId) { + id + title + threadDescription + userMessages { + id + username + text + attachment { + name + src + } + } + } + } +`; + +export const GET_THREAD_BY_ID = gql` + query GetThreadById($threadId: String!) { + getThreadById(threadId: $threadId) { + id + title + threadDescription + userMessages { + id + username + text + attachment { + name + src + } + } + } + } +`; + +export const MESSAGES = gql` + query Messages($threadId: String!) { + messages(threadId: $threadId) { + id + username + text + attachment { + name + src + } + } + } +`; + +export const CREATE_THREAD = gql` + mutation CreateThread( + $projectId: String! + $title: String! + $threadDescription: String! + ) { + createThread( + projectId: $projectId + title: $title + threadDescription: $threadDescription + ) + } +`; + +export const SEND_MSG = gql` + mutation SendMsg( + $threadId: String! + $username: String! + $msg: String + $file: FileInput + ) { + sendMsg(threadId: $threadId, username: $username, msg: $msg, file: $file) + } +`; + +export const CONNECT_STREAM = gql` + subscription ConnectStream($mutationType: MutationType) { + connectStream(mutationType: $mutationType) { + mutationType + id + userMessage { + id + username + text + attachment { + name + src + } + } + } + } +`; diff --git a/src/graphql/types.support.ts b/src/graphql/types.support.ts new file mode 100644 index 0000000..4510d3f --- /dev/null +++ b/src/graphql/types.support.ts @@ -0,0 +1,214 @@ +export type Maybe = T | null; +export type Exact = { [K in keyof T]: T[K] }; +export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; +export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; +/** All built-in and custom scalars, mapped to their actual values */ +export type Scalars = { + ID: string; + String: string; + Boolean: boolean; + Int: number; + Float: number; +}; + + +export type FileInput = { + name: Scalars['String']; + src: Scalars['String']; +}; + +export type FileOutput = { + __typename?: 'FileOutput'; + name: Scalars['String']; + src: Scalars['String']; +}; + +export type MutationRoot = { + __typename?: 'MutationRoot'; + createThread: Scalars['ID']; + deleteThread: ThreadObject; + sendMsg: Scalars['ID']; +}; + + +export type MutationRootCreateThreadArgs = { + projectId: Scalars['String']; + title: Scalars['String']; + threadDescription: Scalars['String']; +}; + + +export type MutationRootDeleteThreadArgs = { + threadId: Scalars['String']; +}; + + +export type MutationRootSendMsgArgs = { + threadId: Scalars['String']; + username: Scalars['String']; + msg?: Maybe; + file?: Maybe; +}; + +export type MutationType = + | 'CREATED'; + +export type QueryRoot = { + __typename?: 'QueryRoot'; + messages: Array; + getProjectThreads: Array; + getThreadById: ThreadObject; +}; + + +export type QueryRootMessagesArgs = { + threadId: Scalars['String']; +}; + + +export type QueryRootGetProjectThreadsArgs = { + projectId: Scalars['String']; +}; + + +export type QueryRootGetThreadByIdArgs = { + threadId: Scalars['String']; +}; + +export type StreamChanged = { + __typename?: 'StreamChanged'; + mutationType: MutationType; + id: Scalars['ID']; + userMessage?: Maybe; +}; + +export type SubscriptionRoot = { + __typename?: 'SubscriptionRoot'; + connectStream: StreamChanged; +}; + + +export type SubscriptionRootConnectStreamArgs = { + mutationType?: Maybe; +}; + +export type ThreadObject = { + __typename?: 'ThreadObject'; + id: Scalars['String']; + title: Scalars['String']; + threadDescription: Scalars['String']; + userMessages: Array; +}; + +export type UserMessageObject = { + __typename?: 'UserMessageObject'; + id: Scalars['String']; + username: Scalars['String']; + text: Scalars['String']; + attachment: FileOutput; +}; + +export type GetProjectThreadsQueryVariables = Exact<{ + projectId: Scalars['String']; +}>; + + +export type GetProjectThreadsQuery = ( + { __typename?: 'QueryRoot' } + & { getProjectThreads: Array<( + { __typename?: 'ThreadObject' } + & Pick + & { userMessages: Array<( + { __typename?: 'UserMessageObject' } + & Pick + & { attachment: ( + { __typename?: 'FileOutput' } + & Pick + ) } + )> } + )> } +); + +export type GetThreadByIdQueryVariables = Exact<{ + threadId: Scalars['String']; +}>; + + +export type GetThreadByIdQuery = ( + { __typename?: 'QueryRoot' } + & { getThreadById: ( + { __typename?: 'ThreadObject' } + & Pick + & { userMessages: Array<( + { __typename?: 'UserMessageObject' } + & Pick + & { attachment: ( + { __typename?: 'FileOutput' } + & Pick + ) } + )> } + ) } +); + +export type MessagesQueryVariables = Exact<{ + threadId: Scalars['String']; +}>; + + +export type MessagesQuery = ( + { __typename?: 'QueryRoot' } + & { messages: Array<( + { __typename?: 'UserMessageObject' } + & Pick + & { attachment: ( + { __typename?: 'FileOutput' } + & Pick + ) } + )> } +); + +export type CreateThreadMutationVariables = Exact<{ + projectId: Scalars['String']; + title: Scalars['String']; + threadDescription: Scalars['String']; +}>; + + +export type CreateThreadMutation = ( + { __typename?: 'MutationRoot' } + & Pick +); + +export type SendMsgMutationVariables = Exact<{ + threadId: Scalars['String']; + username: Scalars['String']; + msg?: Maybe; + file?: Maybe; +}>; + + +export type SendMsgMutation = ( + { __typename?: 'MutationRoot' } + & Pick +); + +export type ConnectStreamSubscriptionVariables = Exact<{ + mutationType?: Maybe; +}>; + + +export type ConnectStreamSubscription = ( + { __typename?: 'SubscriptionRoot' } + & { connectStream: ( + { __typename?: 'StreamChanged' } + & Pick + & { userMessage?: Maybe<( + { __typename?: 'UserMessageObject' } + & Pick + & { attachment: ( + { __typename?: 'FileOutput' } + & Pick + ) } + )> } + ) } +);