Skip to content

Commit 167fad8

Browse files
committed
New option onlyOperationTypes for typescript and flow
1 parent a360782 commit 167fad8

File tree

7 files changed

+427
-0
lines changed

7 files changed

+427
-0
lines changed

dev-test/codegen.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ generates:
8585
plugins:
8686
- typescript
8787
- typescript-operations
88+
./dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts:
89+
schema: ./dev-test/githunt/schema.json
90+
documents: ./dev-test/githunt/**/*.graphql
91+
config:
92+
preResolveTypes: true
93+
onlyOperationTypes: true
94+
plugins:
95+
- typescript
96+
- typescript-operations
8897
./dev-test/githunt/types.flatten.preResolveTypes.ts:
8998
schema: ./dev-test/githunt/schema.json
9099
documents: ./dev-test/githunt/**/*.graphql
@@ -227,6 +236,15 @@ generates:
227236
plugins:
228237
- typescript
229238
- typescript-operations
239+
./dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts:
240+
schema: ./dev-test/star-wars/schema.json
241+
documents: ./dev-test/star-wars/**/*.graphql
242+
config:
243+
preResolveTypes: true
244+
onlyOperationTypes: true
245+
plugins:
246+
- typescript
247+
- typescript-operations
230248
./dev-test/test-schema/types.preResolveTypes.ts:
231249
schema: ./dev-test/test-schema/schema.graphql
232250
documents:
@@ -236,6 +254,16 @@ generates:
236254
plugins:
237255
- typescript
238256
- typescript-operations
257+
./dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts:
258+
schema: ./dev-test/test-schema/schema.graphql
259+
documents:
260+
- 'query test { testArr1 testArr2 testArr3 }'
261+
config:
262+
preResolveTypes: true
263+
onlyOperationTypes: true
264+
plugins:
265+
- typescript
266+
- typescript-operations
239267
./dev-test/star-wars/types.d.ts:
240268
schema: ./dev-test/star-wars/schema.json
241269
config:
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
export type Maybe<T> = T | null;
2+
/** All built-in and custom scalars, mapped to their actual values */
3+
export type Scalars = {
4+
ID: string;
5+
String: string;
6+
Boolean: boolean;
7+
Int: number;
8+
Float: number;
9+
};
10+
11+
/** A list of options for the sort order of the feed */
12+
export enum FeedType {
13+
/** Sort by a combination of freshness and score, using Reddit's algorithm */
14+
Hot = 'HOT',
15+
/** Newest entries first */
16+
New = 'NEW',
17+
/** Highest score entries first */
18+
Top = 'TOP',
19+
}
20+
21+
/** The type of vote to record, when submitting a vote */
22+
export enum VoteType {
23+
Up = 'UP',
24+
Down = 'DOWN',
25+
Cancel = 'CANCEL',
26+
}
27+
28+
export type OnCommentAddedSubscriptionVariables = {
29+
repoFullName: Scalars['String'];
30+
};
31+
32+
export type OnCommentAddedSubscription = {
33+
__typename?: 'Subscription';
34+
commentAdded?: Maybe<{
35+
__typename?: 'Comment';
36+
id: number;
37+
createdAt: number;
38+
content: string;
39+
postedBy: { __typename?: 'User'; login: string; html_url: string };
40+
}>;
41+
};
42+
43+
export type CommentQueryVariables = {
44+
repoFullName: Scalars['String'];
45+
limit?: Maybe<Scalars['Int']>;
46+
offset?: Maybe<Scalars['Int']>;
47+
};
48+
49+
export type CommentQuery = {
50+
__typename?: 'Query';
51+
currentUser?: Maybe<{ __typename?: 'User'; login: string; html_url: string }>;
52+
entry?: Maybe<{
53+
__typename?: 'Entry';
54+
id: number;
55+
createdAt: number;
56+
commentCount: number;
57+
postedBy: { __typename?: 'User'; login: string; html_url: string };
58+
comments: Array<Maybe<{ __typename?: 'Comment' } & CommentsPageCommentFragment>>;
59+
repository: {
60+
__typename?: 'Repository';
61+
description?: Maybe<string>;
62+
open_issues_count?: Maybe<number>;
63+
stargazers_count: number;
64+
full_name: string;
65+
html_url: string;
66+
};
67+
}>;
68+
};
69+
70+
export type CommentsPageCommentFragment = {
71+
__typename?: 'Comment';
72+
id: number;
73+
createdAt: number;
74+
content: string;
75+
postedBy: { __typename?: 'User'; login: string; html_url: string };
76+
};
77+
78+
export type CurrentUserForProfileQueryVariables = {};
79+
80+
export type CurrentUserForProfileQuery = {
81+
__typename?: 'Query';
82+
currentUser?: Maybe<{ __typename?: 'User'; login: string; avatar_url: string }>;
83+
};
84+
85+
export type FeedEntryFragment = {
86+
__typename?: 'Entry';
87+
id: number;
88+
commentCount: number;
89+
repository: {
90+
__typename?: 'Repository';
91+
full_name: string;
92+
html_url: string;
93+
owner?: Maybe<{ __typename?: 'User'; avatar_url: string }>;
94+
};
95+
} & VoteButtonsFragment &
96+
RepoInfoFragment;
97+
98+
export type FeedQueryVariables = {
99+
type: FeedType;
100+
offset?: Maybe<Scalars['Int']>;
101+
limit?: Maybe<Scalars['Int']>;
102+
};
103+
104+
export type FeedQuery = {
105+
__typename?: 'Query';
106+
currentUser?: Maybe<{ __typename?: 'User'; login: string }>;
107+
feed?: Maybe<Array<Maybe<{ __typename?: 'Entry' } & FeedEntryFragment>>>;
108+
};
109+
110+
export type SubmitRepositoryMutationVariables = {
111+
repoFullName: Scalars['String'];
112+
};
113+
114+
export type SubmitRepositoryMutation = {
115+
__typename?: 'Mutation';
116+
submitRepository?: Maybe<{ __typename?: 'Entry'; createdAt: number }>;
117+
};
118+
119+
export type RepoInfoFragment = {
120+
__typename?: 'Entry';
121+
createdAt: number;
122+
repository: {
123+
__typename?: 'Repository';
124+
description?: Maybe<string>;
125+
stargazers_count: number;
126+
open_issues_count?: Maybe<number>;
127+
};
128+
postedBy: { __typename?: 'User'; html_url: string; login: string };
129+
};
130+
131+
export type SubmitCommentMutationVariables = {
132+
repoFullName: Scalars['String'];
133+
commentContent: Scalars['String'];
134+
};
135+
136+
export type SubmitCommentMutation = {
137+
__typename?: 'Mutation';
138+
submitComment?: Maybe<{ __typename?: 'Comment' } & CommentsPageCommentFragment>;
139+
};
140+
141+
export type VoteButtonsFragment = {
142+
__typename?: 'Entry';
143+
score: number;
144+
vote: { __typename?: 'Vote'; vote_value: number };
145+
};
146+
147+
export type VoteMutationVariables = {
148+
repoFullName: Scalars['String'];
149+
type: VoteType;
150+
};
151+
152+
export type VoteMutation = {
153+
__typename?: 'Mutation';
154+
vote?: Maybe<{ __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } }>;
155+
};
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
export type Maybe<T> = T | null;
2+
/** All built-in and custom scalars, mapped to their actual values */
3+
export type Scalars = {
4+
ID: string;
5+
String: string;
6+
Boolean: boolean;
7+
Int: number;
8+
Float: number;
9+
};
10+
11+
/** The episodes in the Star Wars trilogy */
12+
export enum Episode {
13+
/** Star Wars Episode IV: A New Hope, released in 1977. */
14+
Newhope = 'NEWHOPE',
15+
/** Star Wars Episode V: The Empire Strikes Back, released in 1980. */
16+
Empire = 'EMPIRE',
17+
/** Star Wars Episode VI: Return of the Jedi, released in 1983. */
18+
Jedi = 'JEDI',
19+
}
20+
21+
/** Units of height */
22+
export enum LengthUnit {
23+
/** The standard unit around the world */
24+
Meter = 'METER',
25+
/** Primarily used in the United States */
26+
Foot = 'FOOT',
27+
}
28+
29+
export type CreateReviewForEpisodeMutationVariables = {
30+
episode: Episode;
31+
review: ReviewInput;
32+
};
33+
34+
export type CreateReviewForEpisodeMutation = {
35+
__typename?: 'Mutation';
36+
createReview?: Maybe<{ __typename?: 'Review'; stars: number; commentary?: Maybe<string> }>;
37+
};
38+
39+
export type HeroAndFriendsNamesQueryVariables = {
40+
episode?: Maybe<Episode>;
41+
};
42+
43+
export type HeroAndFriendsNamesQuery = {
44+
__typename?: 'Query';
45+
hero?: Maybe<
46+
| {
47+
__typename?: 'Human';
48+
name: string;
49+
friends?: Maybe<Array<Maybe<{ __typename?: 'Human'; name: string } | { __typename?: 'Droid'; name: string }>>>;
50+
}
51+
| {
52+
__typename?: 'Droid';
53+
name: string;
54+
friends?: Maybe<Array<Maybe<{ __typename?: 'Human'; name: string } | { __typename?: 'Droid'; name: string }>>>;
55+
}
56+
>;
57+
};
58+
59+
export type HeroAppearsInQueryVariables = {};
60+
61+
export type HeroAppearsInQuery = {
62+
__typename?: 'Query';
63+
hero?: Maybe<
64+
| { __typename?: 'Human'; name: string; appearsIn: Array<Maybe<Episode>> }
65+
| { __typename?: 'Droid'; name: string; appearsIn: Array<Maybe<Episode>> }
66+
>;
67+
};
68+
69+
export type HeroDetailsQueryVariables = {
70+
episode?: Maybe<Episode>;
71+
};
72+
73+
export type HeroDetailsQuery = {
74+
__typename?: 'Query';
75+
hero?: Maybe<
76+
| { __typename?: 'Human'; height?: Maybe<number>; name: string }
77+
| { __typename?: 'Droid'; primaryFunction?: Maybe<string>; name: string }
78+
>;
79+
};
80+
81+
type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: Maybe<number>; name: string };
82+
83+
type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: Maybe<string>; name: string };
84+
85+
export type HeroDetailsFragment = HeroDetails_Human_Fragment | HeroDetails_Droid_Fragment;
86+
87+
export type HeroDetailsWithFragmentQueryVariables = {
88+
episode?: Maybe<Episode>;
89+
};
90+
91+
export type HeroDetailsWithFragmentQuery = {
92+
__typename?: 'Query';
93+
hero?: Maybe<
94+
({ __typename?: 'Human' } & HeroDetails_Human_Fragment) | ({ __typename?: 'Droid' } & HeroDetails_Droid_Fragment)
95+
>;
96+
};
97+
98+
export type HeroNameQueryVariables = {
99+
episode?: Maybe<Episode>;
100+
};
101+
102+
export type HeroNameQuery = {
103+
__typename?: 'Query';
104+
hero?: Maybe<{ __typename?: 'Human'; name: string } | { __typename?: 'Droid'; name: string }>;
105+
};
106+
107+
export type HeroNameConditionalInclusionQueryVariables = {
108+
episode?: Maybe<Episode>;
109+
includeName: Scalars['Boolean'];
110+
};
111+
112+
export type HeroNameConditionalInclusionQuery = {
113+
__typename?: 'Query';
114+
hero?: Maybe<{ __typename?: 'Human'; name: string } | { __typename?: 'Droid'; name: string }>;
115+
};
116+
117+
export type HeroNameConditionalExclusionQueryVariables = {
118+
episode?: Maybe<Episode>;
119+
skipName: Scalars['Boolean'];
120+
};
121+
122+
export type HeroNameConditionalExclusionQuery = {
123+
__typename?: 'Query';
124+
hero?: Maybe<{ __typename?: 'Human'; name: string } | { __typename?: 'Droid'; name: string }>;
125+
};
126+
127+
export type HeroParentTypeDependentFieldQueryVariables = {
128+
episode?: Maybe<Episode>;
129+
};
130+
131+
export type HeroParentTypeDependentFieldQuery = {
132+
__typename?: 'Query';
133+
hero?: Maybe<
134+
| {
135+
__typename?: 'Human';
136+
name: string;
137+
friends?: Maybe<
138+
Array<
139+
Maybe<
140+
{ __typename?: 'Human'; height?: Maybe<number>; name: string } | { __typename?: 'Droid'; name: string }
141+
>
142+
>
143+
>;
144+
}
145+
| {
146+
__typename?: 'Droid';
147+
name: string;
148+
friends?: Maybe<
149+
Array<
150+
Maybe<
151+
{ __typename?: 'Human'; height?: Maybe<number>; name: string } | { __typename?: 'Droid'; name: string }
152+
>
153+
>
154+
>;
155+
}
156+
>;
157+
};
158+
159+
export type HeroTypeDependentAliasedFieldQueryVariables = {
160+
episode?: Maybe<Episode>;
161+
};
162+
163+
export type HeroTypeDependentAliasedFieldQuery = {
164+
__typename?: 'Query';
165+
hero?: Maybe<{ __typename?: 'Human'; property?: Maybe<string> } | { __typename?: 'Droid'; property?: Maybe<string> }>;
166+
};
167+
168+
export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: Maybe<number> };
169+
170+
export type HumanWithNullHeightQueryVariables = {};
171+
172+
export type HumanWithNullHeightQuery = {
173+
__typename?: 'Query';
174+
human?: Maybe<{ __typename?: 'Human' } & HumanFieldsFragment>;
175+
};
176+
177+
export type TwoHeroesQueryVariables = {};
178+
179+
export type TwoHeroesQuery = {
180+
__typename?: 'Query';
181+
r2?: Maybe<{ __typename?: 'Human'; name: string } | { __typename?: 'Droid'; name: string }>;
182+
luke?: Maybe<{ __typename?: 'Human'; name: string } | { __typename?: 'Droid'; name: string }>;
183+
};

0 commit comments

Comments
 (0)