From 7e7fbb7cc4d700fb67abc581a2e38e39c36a3ffb Mon Sep 17 00:00:00 2001 From: guen Date: Wed, 29 Oct 2025 03:03:02 +0700 Subject: [PATCH] chore(operations): ignore GraphQL codegen output and add postinstall build --- .gitignore | 1 + packages/operations/package.json | 3 +- packages/operations/src/codegen/gql.ts | 58 ----- packages/operations/src/codegen/graphql.ts | 247 --------------------- packages/operations/src/codegen/index.ts | 1 - 5 files changed, 3 insertions(+), 307 deletions(-) delete mode 100644 packages/operations/src/codegen/gql.ts delete mode 100644 packages/operations/src/codegen/graphql.ts delete mode 100644 packages/operations/src/codegen/index.ts diff --git a/.gitignore b/.gitignore index ce66c1d..6885238 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ dist-ssr .out .output packages/docs/.vitepress/cache/ +packages/operations/src/codegen/ diff --git a/packages/operations/package.json b/packages/operations/package.json index cbb32b2..c18ac32 100644 --- a/packages/operations/package.json +++ b/packages/operations/package.json @@ -6,7 +6,8 @@ "description": "", "main": "./src/index.ts", "scripts": { - "build": "graphql-codegen" + "build": "graphql-codegen", + "postinstall": "pnpm build" }, "peerDependencies": { "@apollo/client": "^4.0.0", diff --git a/packages/operations/src/codegen/gql.ts b/packages/operations/src/codegen/gql.ts deleted file mode 100644 index eb035f1..0000000 --- a/packages/operations/src/codegen/gql.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* eslint-disable */ -import * as types from './graphql'; -import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - -/** - * Map of all GraphQL operations in the project. - * - * This map has several performance disadvantages: - * 1. It is not tree-shakeable, so it will include all operations in the project. - * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle. - * 3. It does not support dead code elimination, so it will add unused operations. - * - * Therefore it is highly recommended to use the babel or swc plugin for production. - * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size - */ -type Documents = { - "fragment PostDetail on Post {\n id\n title\n body\n}": typeof types.PostDetailFragmentDoc, - "mutation UpdatePost($postId: Int!, $post: UpdatePostInput!) {\n updatePost(postId: $postId, post: $post) {\n id\n title\n }\n}": typeof types.UpdatePostDocument, - "query UserById($userByIdId: Int!) {\n userById(id: $userByIdId) {\n id\n name\n email\n }\n}\n\nquery Posts($userId: Int, $first: Int) {\n posts(userId: $userId, first: $first) {\n id\n ...PostDetail\n }\n}": typeof types.UserByIdDocument, -}; -const documents: Documents = { - "fragment PostDetail on Post {\n id\n title\n body\n}": types.PostDetailFragmentDoc, - "mutation UpdatePost($postId: Int!, $post: UpdatePostInput!) {\n updatePost(postId: $postId, post: $post) {\n id\n title\n }\n}": types.UpdatePostDocument, - "query UserById($userByIdId: Int!) {\n userById(id: $userByIdId) {\n id\n name\n email\n }\n}\n\nquery Posts($userId: Int, $first: Int) {\n posts(userId: $userId, first: $first) {\n id\n ...PostDetail\n }\n}": types.UserByIdDocument, -}; - -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - * - * - * @example - * ```ts - * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`); - * ``` - * - * The query argument is unknown! - * Please regenerate the types. - */ -export function graphql(source: string): unknown; - -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql(source: "fragment PostDetail on Post {\n id\n title\n body\n}"): (typeof documents)["fragment PostDetail on Post {\n id\n title\n body\n}"]; -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql(source: "mutation UpdatePost($postId: Int!, $post: UpdatePostInput!) {\n updatePost(postId: $postId, post: $post) {\n id\n title\n }\n}"): (typeof documents)["mutation UpdatePost($postId: Int!, $post: UpdatePostInput!) {\n updatePost(postId: $postId, post: $post) {\n id\n title\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: "query UserById($userByIdId: Int!) {\n userById(id: $userByIdId) {\n id\n name\n email\n }\n}\n\nquery Posts($userId: Int, $first: Int) {\n posts(userId: $userId, first: $first) {\n id\n ...PostDetail\n }\n}"): (typeof documents)["query UserById($userByIdId: Int!) {\n userById(id: $userByIdId) {\n id\n name\n email\n }\n}\n\nquery Posts($userId: Int, $first: Int) {\n posts(userId: $userId, first: $first) {\n id\n ...PostDetail\n }\n}"]; - -export function graphql(source: string) { - return (documents as any)[source] ?? {}; -} - -export type DocumentType> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never; \ No newline at end of file diff --git a/packages/operations/src/codegen/graphql.ts b/packages/operations/src/codegen/graphql.ts deleted file mode 100644 index 4a096f6..0000000 --- a/packages/operations/src/codegen/graphql.ts +++ /dev/null @@ -1,247 +0,0 @@ -/* eslint-disable */ -import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -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; } -}; - -export type Address = { - __typename?: 'Address'; - city?: Maybe; - geo?: Maybe; - street?: Maybe; - suite?: Maybe; - zipcode?: Maybe; -}; - -export type Album = { - __typename?: 'Album'; - id: Scalars['Int']['output']; - photos?: Maybe>>; - title?: Maybe; - user?: Maybe; -}; - - -export type AlbumPhotosArgs = { - first?: InputMaybe; -}; - -export type Comment = { - __typename?: 'Comment'; - body?: Maybe; - email?: Maybe; - id: Scalars['Int']['output']; - name?: Maybe; - post?: Maybe; -}; - -export type Company = { - __typename?: 'Company'; - bs?: Maybe; - catchPhrase?: Maybe; - name?: Maybe; -}; - -export type CreatePostInput = { - body: Scalars['String']['input']; - title: Scalars['String']['input']; - userId: Scalars['Int']['input']; -}; - -export type Geo = { - __typename?: 'Geo'; - lat?: Maybe; - lng?: Maybe; -}; - -export type Mutation = { - __typename?: 'Mutation'; - createPost?: Maybe; - deletePost?: Maybe; - updatePost?: Maybe; -}; - - -export type MutationCreatePostArgs = { - post: CreatePostInput; -}; - - -export type MutationDeletePostArgs = { - postId: Scalars['Int']['input']; -}; - - -export type MutationUpdatePostArgs = { - post: UpdatePostInput; - postId: Scalars['Int']['input']; -}; - -export type Photo = { - __typename?: 'Photo'; - album?: Maybe; - id: Scalars['Int']['output']; - thumbnailUrl?: Maybe; - title?: Maybe; - url?: Maybe; -}; - -export type Post = { - __typename?: 'Post'; - body?: Maybe; - comments?: Maybe>>; - id: Scalars['Int']['output']; - title?: Maybe; - user?: Maybe; -}; - - -export type PostCommentsArgs = { - first?: InputMaybe; -}; - -export type Query = { - __typename?: 'Query'; - albums?: Maybe>>; - comments?: Maybe>>; - photos?: Maybe>>; - posts?: Maybe>>; - todos?: Maybe>>; - userById?: Maybe; - users?: Maybe>>; -}; - - -export type QueryAlbumsArgs = { - albumId?: InputMaybe; - first?: InputMaybe; - userId?: InputMaybe; -}; - - -export type QueryCommentsArgs = { - commentId?: InputMaybe; - first?: InputMaybe; - postId?: InputMaybe; -}; - - -export type QueryPhotosArgs = { - albumId?: InputMaybe; - first?: InputMaybe; - photoId?: InputMaybe; -}; - - -export type QueryPostsArgs = { - first?: InputMaybe; - postId?: InputMaybe; - userId?: InputMaybe; -}; - - -export type QueryTodosArgs = { - first?: InputMaybe; - todoId?: InputMaybe; - userId?: InputMaybe; -}; - - -export type QueryUserByIdArgs = { - id: Scalars['Int']['input']; -}; - - -export type QueryUsersArgs = { - first?: InputMaybe; - userId?: InputMaybe; -}; - -export type Todo = { - __typename?: 'Todo'; - completed?: Maybe; - id: Scalars['Int']['output']; - title?: Maybe; - user?: Maybe; -}; - -export type UpdatePostInput = { - body?: InputMaybe; - title?: InputMaybe; - userId?: InputMaybe; -}; - -export type User = { - __typename?: 'User'; - address?: Maybe
; - albums?: Maybe>>; - company?: Maybe; - email?: Maybe; - id: Scalars['Int']['output']; - name?: Maybe; - phone?: Maybe; - posts?: Maybe>>; - todos?: Maybe>>; - username?: Maybe; - website?: Maybe; -}; - - -export type UserAlbumsArgs = { - first?: InputMaybe; -}; - - -export type UserPostsArgs = { - first?: InputMaybe; -}; - - -export type UserTodosArgs = { - first?: InputMaybe; -}; - -export type PostDetailFragment = { __typename?: 'Post', id: number, title?: string | null, body?: string | null } & { ' $fragmentName'?: 'PostDetailFragment' }; - -export type UpdatePostMutationVariables = Exact<{ - postId: Scalars['Int']['input']; - post: UpdatePostInput; -}>; - - -export type UpdatePostMutation = { __typename?: 'Mutation', updatePost?: { __typename?: 'Post', id: number, title?: string | null } | null }; - -export type UserByIdQueryVariables = Exact<{ - userByIdId: Scalars['Int']['input']; -}>; - - -export type UserByIdQuery = { __typename?: 'Query', userById?: { __typename?: 'User', id: number, name?: string | null, email?: string | null } | null }; - -export type PostsQueryVariables = Exact<{ - userId?: InputMaybe; - first?: InputMaybe; -}>; - - -export type PostsQuery = { __typename?: 'Query', posts?: Array<( - { __typename?: 'Post', id: number } - & { ' $fragmentRefs'?: { 'PostDetailFragment': PostDetailFragment } } - ) | null> | null }; - -export const PostDetailFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"PostDetail"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Post"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}}]}}]} as unknown as DocumentNode; -export const UpdatePostDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdatePost"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"postId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"post"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdatePostInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updatePost"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"postId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"postId"}}},{"kind":"Argument","name":{"kind":"Name","value":"post"},"value":{"kind":"Variable","name":{"kind":"Name","value":"post"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}}]}}]}}]} as unknown as DocumentNode; -export const UserByIdDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"UserById"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"userByIdId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userById"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"userByIdId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}}]}}]} as unknown as DocumentNode; -export const PostsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Posts"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"userId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"posts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"userId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"userId"}}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"PostDetail"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"PostDetail"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Post"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/packages/operations/src/codegen/index.ts b/packages/operations/src/codegen/index.ts deleted file mode 100644 index af78399..0000000 --- a/packages/operations/src/codegen/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./gql"; \ No newline at end of file