Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "feat: reduce code output of client preset"" #10197

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .changeset/famous-spoons-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@graphql-codegen/client-preset': major
---

BREAKING CHANGE: Avoid generating unused types

Previously client preset was generating a lot of types not used by the preset itself. This usually adds 100% more generated code than what's needed. This behaviour gets worse for bigger codebases. This version removes these unused types.

For users who have used these types (e.g. testing, generating mocks, etc.), it is recommended to generate another file for non client preset purposes:

```ts
const config: CodegenConfig = {
generates: {
"src/graphql/": {
preset: 'client',
// ... other config
},
"src/graphql/types.generated.ts": { // Use this file for non client preset purposes
plugins: ['typescript']
}
}
}
```
89 changes: 0 additions & 89 deletions dev-test/gql-tag-operations-masking/gql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,95 +18,6 @@ export type Scalars = {
Url: { input: any; output: any };
};

export type Meta = {
__typename?: 'Meta';
count?: Maybe<Scalars['Int']['output']>;
};

export type Mutation = {
__typename?: 'Mutation';
createTweet?: Maybe<Tweet>;
deleteTweet?: Maybe<Tweet>;
markTweetRead?: Maybe<Scalars['Boolean']['output']>;
};

export type MutationCreateTweetArgs = {
body?: InputMaybe<Scalars['String']['input']>;
};

export type MutationDeleteTweetArgs = {
id: Scalars['ID']['input'];
};

export type MutationMarkTweetReadArgs = {
id: Scalars['ID']['input'];
};

export type Notification = {
__typename?: 'Notification';
date?: Maybe<Scalars['Date']['output']>;
id?: Maybe<Scalars['ID']['output']>;
type?: Maybe<Scalars['String']['output']>;
};

export type Query = {
__typename?: 'Query';
Notifications?: Maybe<Array<Maybe<Notification>>>;
NotificationsMeta?: Maybe<Meta>;
Tweet?: Maybe<Tweet>;
Tweets?: Maybe<Array<Tweet>>;
TweetsMeta?: Maybe<Meta>;
User?: Maybe<User>;
};

export type QueryNotificationsArgs = {
limit?: InputMaybe<Scalars['Int']['input']>;
};

export type QueryTweetArgs = {
id: Scalars['ID']['input'];
};

export type QueryTweetsArgs = {
limit?: InputMaybe<Scalars['Int']['input']>;
skip?: InputMaybe<Scalars['Int']['input']>;
sort_field?: InputMaybe<Scalars['String']['input']>;
sort_order?: InputMaybe<Scalars['String']['input']>;
};

export type QueryUserArgs = {
id: Scalars['ID']['input'];
};

export type Stat = {
__typename?: 'Stat';
likes?: Maybe<Scalars['Int']['output']>;
responses?: Maybe<Scalars['Int']['output']>;
retweets?: Maybe<Scalars['Int']['output']>;
views?: Maybe<Scalars['Int']['output']>;
};

export type Tweet = {
__typename?: 'Tweet';
Stats?: Maybe<Stat>;
author: User;
body: Scalars['String']['output'];
date?: Maybe<Scalars['Date']['output']>;
id: Scalars['ID']['output'];
};

export type User = {
__typename?: 'User';
avatar_url?: Maybe<Scalars['Url']['output']>;
first_name?: Maybe<Scalars['String']['output']>;
full_name?: Maybe<Scalars['String']['output']>;
id: Scalars['ID']['output'];
last_name?: Maybe<Scalars['String']['output']>;
/** @deprecated Field no longer supported */
name?: Maybe<Scalars['String']['output']>;
username?: Maybe<Scalars['String']['output']>;
};

export type TweetFragmentFragment = ({ __typename?: 'Tweet'; id: string; body: string } & {
' $fragmentRefs'?: { TweetAuthorFragmentFragment: TweetAuthorFragmentFragment };
}) & { ' $fragmentName'?: 'TweetFragmentFragment' };
Expand Down
89 changes: 0 additions & 89 deletions dev-test/gql-tag-operations-urql/gql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,95 +18,6 @@ export type Scalars = {
Url: { input: any; output: any };
};

export type Meta = {
__typename?: 'Meta';
count?: Maybe<Scalars['Int']['output']>;
};

export type Mutation = {
__typename?: 'Mutation';
createTweet?: Maybe<Tweet>;
deleteTweet?: Maybe<Tweet>;
markTweetRead?: Maybe<Scalars['Boolean']['output']>;
};

export type MutationCreateTweetArgs = {
body?: InputMaybe<Scalars['String']['input']>;
};

export type MutationDeleteTweetArgs = {
id: Scalars['ID']['input'];
};

export type MutationMarkTweetReadArgs = {
id: Scalars['ID']['input'];
};

export type Notification = {
__typename?: 'Notification';
date?: Maybe<Scalars['Date']['output']>;
id?: Maybe<Scalars['ID']['output']>;
type?: Maybe<Scalars['String']['output']>;
};

export type Query = {
__typename?: 'Query';
Notifications?: Maybe<Array<Maybe<Notification>>>;
NotificationsMeta?: Maybe<Meta>;
Tweet?: Maybe<Tweet>;
Tweets?: Maybe<Array<Maybe<Tweet>>>;
TweetsMeta?: Maybe<Meta>;
User?: Maybe<User>;
};

export type QueryNotificationsArgs = {
limit?: InputMaybe<Scalars['Int']['input']>;
};

export type QueryTweetArgs = {
id: Scalars['ID']['input'];
};

export type QueryTweetsArgs = {
limit?: InputMaybe<Scalars['Int']['input']>;
skip?: InputMaybe<Scalars['Int']['input']>;
sort_field?: InputMaybe<Scalars['String']['input']>;
sort_order?: InputMaybe<Scalars['String']['input']>;
};

export type QueryUserArgs = {
id: Scalars['ID']['input'];
};

export type Stat = {
__typename?: 'Stat';
likes?: Maybe<Scalars['Int']['output']>;
responses?: Maybe<Scalars['Int']['output']>;
retweets?: Maybe<Scalars['Int']['output']>;
views?: Maybe<Scalars['Int']['output']>;
};

export type Tweet = {
__typename?: 'Tweet';
Author?: Maybe<User>;
Stats?: Maybe<Stat>;
body?: Maybe<Scalars['String']['output']>;
date?: Maybe<Scalars['Date']['output']>;
id: Scalars['ID']['output'];
};

export type User = {
__typename?: 'User';
avatar_url?: Maybe<Scalars['Url']['output']>;
first_name?: Maybe<Scalars['String']['output']>;
full_name?: Maybe<Scalars['String']['output']>;
id: Scalars['ID']['output'];
last_name?: Maybe<Scalars['String']['output']>;
/** @deprecated Field no longer supported */
name?: Maybe<Scalars['String']['output']>;
username?: Maybe<Scalars['String']['output']>;
};

export type FooQueryVariables = Exact<{ [key: string]: never }>;

export type FooQuery = { __typename?: 'Query'; Tweets?: Array<{ __typename?: 'Tweet'; id: string } | null> | null };
Expand Down
89 changes: 0 additions & 89 deletions dev-test/gql-tag-operations/gql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,95 +18,6 @@ export type Scalars = {
Url: { input: any; output: any };
};

export type Meta = {
__typename?: 'Meta';
count?: Maybe<Scalars['Int']['output']>;
};

export type Mutation = {
__typename?: 'Mutation';
createTweet?: Maybe<Tweet>;
deleteTweet?: Maybe<Tweet>;
markTweetRead?: Maybe<Scalars['Boolean']['output']>;
};

export type MutationCreateTweetArgs = {
body?: InputMaybe<Scalars['String']['input']>;
};

export type MutationDeleteTweetArgs = {
id: Scalars['ID']['input'];
};

export type MutationMarkTweetReadArgs = {
id: Scalars['ID']['input'];
};

export type Notification = {
__typename?: 'Notification';
date?: Maybe<Scalars['Date']['output']>;
id?: Maybe<Scalars['ID']['output']>;
type?: Maybe<Scalars['String']['output']>;
};

export type Query = {
__typename?: 'Query';
Notifications?: Maybe<Array<Maybe<Notification>>>;
NotificationsMeta?: Maybe<Meta>;
Tweet?: Maybe<Tweet>;
Tweets?: Maybe<Array<Maybe<Tweet>>>;
TweetsMeta?: Maybe<Meta>;
User?: Maybe<User>;
};

export type QueryNotificationsArgs = {
limit?: InputMaybe<Scalars['Int']['input']>;
};

export type QueryTweetArgs = {
id: Scalars['ID']['input'];
};

export type QueryTweetsArgs = {
limit?: InputMaybe<Scalars['Int']['input']>;
skip?: InputMaybe<Scalars['Int']['input']>;
sort_field?: InputMaybe<Scalars['String']['input']>;
sort_order?: InputMaybe<Scalars['String']['input']>;
};

export type QueryUserArgs = {
id: Scalars['ID']['input'];
};

export type Stat = {
__typename?: 'Stat';
likes?: Maybe<Scalars['Int']['output']>;
responses?: Maybe<Scalars['Int']['output']>;
retweets?: Maybe<Scalars['Int']['output']>;
views?: Maybe<Scalars['Int']['output']>;
};

export type Tweet = {
__typename?: 'Tweet';
Author?: Maybe<User>;
Stats?: Maybe<Stat>;
body?: Maybe<Scalars['String']['output']>;
date?: Maybe<Scalars['Date']['output']>;
id: Scalars['ID']['output'];
};

export type User = {
__typename?: 'User';
avatar_url?: Maybe<Scalars['Url']['output']>;
first_name?: Maybe<Scalars['String']['output']>;
full_name?: Maybe<Scalars['String']['output']>;
id: Scalars['ID']['output'];
last_name?: Maybe<Scalars['String']['output']>;
/** @deprecated Field no longer supported */
name?: Maybe<Scalars['String']['output']>;
username?: Maybe<Scalars['String']['output']>;
};

export type FooQueryVariables = Exact<{ [key: string]: never }>;

export type FooQuery = { __typename?: 'Query'; Tweets?: Array<{ __typename?: 'Tweet'; id: string } | null> | null };
Expand Down
Loading
Loading