diff --git a/Rakefile.rb b/Rakefile.rb index 00b7425..7e559a6 100644 --- a/Rakefile.rb +++ b/Rakefile.rb @@ -1,5 +1,6 @@ require "bundler/setup" +load "rake/tasks/schema.rake" load "rake/tasks/nanoc.rake" load "rake/tasks/gem.rake" load "rake/tasks/rubocop.rake" diff --git a/rake/tasks/schema.rake b/rake/tasks/schema.rake new file mode 100644 index 0000000..e60aa94 --- /dev/null +++ b/rake/tasks/schema.rake @@ -0,0 +1,20 @@ +namespace :schema do + workdir = File.join(__dir__, "..", "..") + desc "Regenerate the GraphQL schema (server-side and client-side)" + task regen: %i[regen:server regen:client] + + task :'regen:server' do + Dir.chdir(workdir) do + require "twenty-server" + schema = File.join(Dir.getwd, "share", "twenty-server", "schema.graphql") + mkdir_p File.dirname(schema) + File.binwrite schema, Twenty::GraphQL::Schema.to_definition + end + end + + task :'regen:client' do + Dir.chdir(File.join(workdir, "twenty-client")) do + sh "npm exec graphql-codegen" + end + end +end diff --git a/twenty-client/Rakefile.rb b/twenty-client/Rakefile.rb deleted file mode 100644 index cdaf0b8..0000000 --- a/twenty-client/Rakefile.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "bundler/setup" -namespace :schema do - desc "Generate src/js/types/schema.ts" - task :regen do - path = File.join "..", "twenty-server" - Bundler.with_unbundled_env { - Dir.chdir(path) { sh "bundle exec rake schema:regen" } - } - sh "npm exec graphql-codegen" - end -end diff --git a/twenty-client/codegen.yml b/twenty-client/codegen.yml index 0781d70..70dd79b 100644 --- a/twenty-client/codegen.yml +++ b/twenty-client/codegen.yml @@ -1,5 +1,5 @@ schema: -- ../twenty-backend/share/twenty-backend/schema.graphql +- ../twenty-server/share/twenty-server/schema.graphql generates: src/js/types/schema.ts: diff --git a/twenty-client/src/js/types/schema.ts b/twenty-client/src/js/types/schema.ts index f245397..206d793 100644 --- a/twenty-client/src/js/types/schema.ts +++ b/twenty-client/src/js/types/schema.ts @@ -1,56 +1,43 @@ export type Maybe = T | null; export type InputMaybe = Maybe; -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; -}; -export type MakeEmpty< - T extends { [key: string]: unknown }, - K extends keyof T, -> = { [_ in K]?: never }; -export type Incremental = - | T - | { - [P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never; - }; +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 }; +export type MakeEmpty = { [_ in K]?: never }; +export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { - ID: { input: string; output: string }; - String: { input: string; output: string }; - Boolean: { input: boolean; output: boolean }; - Int: { input: number; output: number }; - Float: { input: number; output: number }; + ID: { input: string; output: string; } + String: { input: string; output: string; } + Boolean: { input: boolean; output: boolean; } + Int: { input: number; output: number; } + Float: { input: number; output: number; } /** An ISO 8601-encoded datetime */ - ISO8601DateTime: { input: any; output: any }; + ISO8601DateTime: { input: any; output: any; } }; /** Autogenerated return type of CompleteTask. */ export type CompleteTaskPayload = { - __typename?: "CompleteTaskPayload"; - errors?: Maybe>; - ok?: Maybe; + __typename?: 'CompleteTaskPayload'; + errors?: Maybe>; + ok?: Maybe; }; /** Autogenerated return type of CreateTask. */ export type CreateTaskPayload = { - __typename?: "CreateTaskPayload"; - errors: Array; + __typename?: 'CreateTaskPayload'; + errors: Array; }; /** Autogenerated return type of DestroyTask. */ export type DestroyTaskPayload = { - __typename?: "DestroyTaskPayload"; - errors?: Maybe>; - ok?: Maybe; + __typename?: 'DestroyTaskPayload'; + errors?: Maybe>; + ok?: Maybe; }; export type Mutation = { - __typename?: "Mutation"; + __typename?: 'Mutation'; completeTask?: Maybe; createTask?: Maybe; destroyTask?: Maybe; @@ -58,89 +45,96 @@ export type Mutation = { updateTask?: Maybe; }; + export type MutationCompleteTaskArgs = { - taskId: Scalars["Int"]["input"]; + taskId: Scalars['Int']['input']; }; + export type MutationCreateTaskArgs = { input: TaskInput; }; + export type MutationDestroyTaskArgs = { - taskId: Scalars["Int"]["input"]; + taskId: Scalars['Int']['input']; }; + export type MutationSetRandomProjectColorArgs = { - projectId: Scalars["Int"]["input"]; + projectId: Scalars['Int']['input']; }; + export type MutationUpdateTaskArgs = { input: TaskInput; - taskId: Scalars["Int"]["input"]; + taskId: Scalars['Int']['input']; }; export type Project = { - __typename?: "Project"; - color: Scalars["String"]["output"]; - id: Scalars["Int"]["output"]; - name: Scalars["String"]["output"]; - path: Scalars["String"]["output"]; + __typename?: 'Project'; + color: Scalars['String']['output']; + id: Scalars['Int']['output']; + name: Scalars['String']['output']; + path: Scalars['String']['output']; tasks: Array; }; export type Query = { - __typename?: "Query"; + __typename?: 'Query'; findTask?: Maybe; projects: Array; tasks: Array; }; + export type QueryFindTaskArgs = { - taskId: Scalars["Int"]["input"]; + taskId: Scalars['Int']['input']; }; + export type QueryTasksArgs = { - projectId?: InputMaybe; + projectId?: InputMaybe; status: TaskStatus; }; /** Autogenerated return type of SetRandomProjectColor. */ export type SetRandomProjectColorPayload = { - __typename?: "SetRandomProjectColorPayload"; - errors: Array; + __typename?: 'SetRandomProjectColorPayload'; + errors: Array; project?: Maybe; }; export type Task = { - __typename?: "Task"; - content: Scalars["String"]["output"]; - id: Scalars["Int"]["output"]; - inProgress: Scalars["Boolean"]["output"]; - isBacklogged: Scalars["Boolean"]["output"]; - isComplete: Scalars["Boolean"]["output"]; - isReady: Scalars["Boolean"]["output"]; + __typename?: 'Task'; + content: Scalars['String']['output']; + id: Scalars['Int']['output']; + inProgress: Scalars['Boolean']['output']; + isBacklogged: Scalars['Boolean']['output']; + isComplete: Scalars['Boolean']['output']; + isReady: Scalars['Boolean']['output']; project: Project; status: TaskStatus; - title: Scalars["String"]["output"]; - updatedAt: Scalars["ISO8601DateTime"]["output"]; + title: Scalars['String']['output']; + updatedAt: Scalars['ISO8601DateTime']['output']; }; export type TaskInput = { - content?: InputMaybe; - projectId?: InputMaybe; + content?: InputMaybe; + projectId?: InputMaybe; status?: InputMaybe; - title?: InputMaybe; + title?: InputMaybe; }; export enum TaskStatus { - Backlog = "backlog", - Complete = "complete", - InProgress = "in_progress", - Ready = "ready", + Backlog = 'backlog', + Complete = 'complete', + InProgress = 'in_progress', + Ready = 'ready' } /** Autogenerated return type of UpdateTask. */ export type UpdateTaskPayload = { - __typename?: "UpdateTaskPayload"; - errors: Array; + __typename?: 'UpdateTaskPayload'; + errors: Array; }; diff --git a/twenty-server/Rakefile.rb b/twenty-server/Rakefile.rb deleted file mode 100644 index 1e23b82..0000000 --- a/twenty-server/Rakefile.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "bundler/setup" -require "fileutils" - -namespace :schema do - desc "Generate share/twenty-server/schema.graphql" - task :regen do - require "twenty-server" - schema = File.join(__dir__, "share", "twenty-server", "schema.graphql") - FileUtils.mkdir_p File.dirname(schema) - File.binwrite schema, Twenty::GraphQL::Schema.to_definition - end -end