Skip to content

Commit ed1731f

Browse files
committed
codegen updated
1 parent 9f981cb commit ed1731f

8 files changed

+969
-761
lines changed

api/src/generated/graphql-types.ts

+81-82
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
22
import { Context } from './';
33
export type Maybe<T> = T | null;
4+
export type InputMaybe<T> = Maybe<T>;
45
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
6+
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
7+
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
58
export type RequireFields<T, K extends keyof T> = { [X in Exclude<keyof T, K>]?: T[X] } & { [P in K]-?: NonNullable<T[P]> };
69
/** All built-in and custom scalars, mapped to their actual values */
710
export type Scalars = {
@@ -10,47 +13,33 @@ export type Scalars = {
1013
Boolean: boolean;
1114
Int: number;
1215
Float: number;
13-
/** The `Upload` scalar type represents a file upload. */
1416
Upload: any;
1517
};
1618

17-
export type Query = {
18-
__typename?: 'Query';
19-
hello?: Maybe<Scalars['String']>;
20-
nowPlaying?: Maybe<Array<Movie>>;
21-
popular?: Maybe<Array<Movie>>;
22-
movieById?: Maybe<Movie>;
23-
cast?: Maybe<Array<Maybe<Credit>>>;
24-
};
25-
19+
export enum CacheControlScope {
20+
Private = 'PRIVATE',
21+
Public = 'PUBLIC'
22+
}
2623

27-
export type QueryMovieByIdArgs = {
24+
export type Credit = {
25+
__typename?: 'Credit';
26+
character: Scalars['String'];
2827
id: Scalars['ID'];
29-
};
30-
31-
32-
export type QueryCastArgs = {
33-
movieId: Scalars['ID'];
28+
name: Scalars['String'];
29+
profile_path?: Maybe<Scalars['String']>;
3430
};
3531

3632
export type Movie = {
3733
__typename?: 'Movie';
38-
id: Scalars['ID'];
39-
title: Scalars['String'];
40-
overview: Scalars['String'];
4134
backdrop_path?: Maybe<Scalars['String']>;
42-
poster_path: Scalars['String'];
43-
popularity?: Maybe<Scalars['String']>;
44-
favorite?: Maybe<Scalars['Boolean']>;
4535
cast?: Maybe<Array<Credit>>;
46-
};
47-
48-
export type Credit = {
49-
__typename?: 'Credit';
36+
favorite?: Maybe<Scalars['Boolean']>;
5037
id: Scalars['ID'];
51-
name: Scalars['String'];
52-
character: Scalars['String'];
53-
profile_path?: Maybe<Scalars['String']>;
38+
overview: Scalars['String'];
39+
/** @deprecated Use favorite instead. */
40+
popularity?: Maybe<Scalars['String']>;
41+
poster_path: Scalars['String'];
42+
title: Scalars['String'];
5443
};
5544

5645
export type Mutation = {
@@ -63,30 +52,34 @@ export type MutationToggleFavoriteMovieArgs = {
6352
movieId: Scalars['ID'];
6453
};
6554

66-
export enum CacheControlScope {
67-
Public = 'PUBLIC',
68-
Private = 'PRIVATE'
69-
}
55+
export type Query = {
56+
__typename?: 'Query';
57+
cast?: Maybe<Array<Maybe<Credit>>>;
58+
hello?: Maybe<Scalars['String']>;
59+
movieById?: Maybe<Movie>;
60+
nowPlaying?: Maybe<Array<Movie>>;
61+
popular?: Maybe<Array<Movie>>;
62+
};
7063

7164

65+
export type QueryCastArgs = {
66+
movieId: Scalars['ID'];
67+
};
7268

7369

74-
export type ResolverTypeWrapper<T> = Promise<T> | T;
70+
export type QueryMovieByIdArgs = {
71+
id: Scalars['ID'];
72+
};
7573

7674

77-
export type LegacyStitchingResolver<TResult, TParent, TContext, TArgs> = {
78-
fragment: string;
79-
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
80-
};
8175

82-
export type NewStitchingResolver<TResult, TParent, TContext, TArgs> = {
83-
selectionSet: string;
76+
export type ResolverTypeWrapper<T> = Promise<T> | T;
77+
78+
79+
export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
8480
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
8581
};
86-
export type StitchingResolver<TResult, TParent, TContext, TArgs> = LegacyStitchingResolver<TResult, TParent, TContext, TArgs> | NewStitchingResolver<TResult, TParent, TContext, TArgs>;
87-
export type Resolver<TResult, TParent = {}, TContext = {}, TArgs = {}> =
88-
| ResolverFn<TResult, TParent, TContext, TArgs>
89-
| StitchingResolver<TResult, TParent, TContext, TArgs>;
82+
export type Resolver<TResult, TParent = {}, TContext = {}, TArgs = {}> = ResolverFn<TResult, TParent, TContext, TArgs> | ResolverWithResolve<TResult, TParent, TContext, TArgs>;
9083

9184
export type ResolverFn<TResult, TParent, TContext, TArgs> = (
9285
parent: TParent,
@@ -100,7 +93,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
10093
args: TArgs,
10194
context: TContext,
10295
info: GraphQLResolveInfo
103-
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
96+
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;
10497

10598
export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
10699
parent: TParent,
@@ -133,7 +126,7 @@ export type TypeResolveFn<TTypes, TParent = {}, TContext = {}> = (
133126
info: GraphQLResolveInfo
134127
) => Maybe<TTypes> | Promise<Maybe<TTypes>>;
135128

136-
export type IsTypeOfResolverFn<T = {}> = (obj: T, info: GraphQLResolveInfo) => boolean | Promise<boolean>;
129+
export type IsTypeOfResolverFn<T = {}, TContext = {}> = (obj: T, context: TContext, info: GraphQLResolveInfo) => boolean | Promise<boolean>;
137130

138131
export type NextResolverFn<T> = () => Promise<T>;
139132

@@ -147,76 +140,82 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
147140

148141
/** Mapping between all available schema types and the resolvers types */
149142
export type ResolversTypes = {
150-
Query: ResolverTypeWrapper<{}>;
151-
String: ResolverTypeWrapper<any>;
152-
ID: ResolverTypeWrapper<any>;
153-
Movie: ResolverTypeWrapper<any>;
154143
Boolean: ResolverTypeWrapper<any>;
144+
CacheControlScope: ResolverTypeWrapper<any>;
155145
Credit: ResolverTypeWrapper<any>;
146+
ID: ResolverTypeWrapper<any>;
147+
Int: ResolverTypeWrapper<any>;
148+
Movie: ResolverTypeWrapper<any>;
156149
Mutation: ResolverTypeWrapper<{}>;
157-
CacheControlScope: ResolverTypeWrapper<any>;
150+
Query: ResolverTypeWrapper<{}>;
151+
String: ResolverTypeWrapper<any>;
158152
Upload: ResolverTypeWrapper<any>;
159153
};
160154

161155
/** Mapping between all available schema types and the resolvers parents */
162156
export type ResolversParentTypes = {
163-
Query: {};
164-
String: any;
165-
ID: any;
166-
Movie: any;
167157
Boolean: any;
168158
Credit: any;
159+
ID: any;
160+
Int: any;
161+
Movie: any;
169162
Mutation: {};
163+
Query: {};
164+
String: any;
170165
Upload: any;
171166
};
172167

173-
export type QueryResolvers<ContextType = Context, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = {
174-
hello?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
175-
nowPlaying?: Resolver<Maybe<Array<ResolversTypes['Movie']>>, ParentType, ContextType>;
176-
popular?: Resolver<Maybe<Array<ResolversTypes['Movie']>>, ParentType, ContextType>;
177-
movieById?: Resolver<Maybe<ResolversTypes['Movie']>, ParentType, ContextType, RequireFields<QueryMovieByIdArgs, 'id'>>;
178-
cast?: Resolver<Maybe<Array<Maybe<ResolversTypes['Credit']>>>, ParentType, ContextType, RequireFields<QueryCastArgs, 'movieId'>>;
168+
export type CacheControlDirectiveArgs = {
169+
maxAge?: Maybe<Scalars['Int']>;
170+
scope?: Maybe<CacheControlScope>;
179171
};
180172

181-
export type MovieResolvers<ContextType = Context, ParentType extends ResolversParentTypes['Movie'] = ResolversParentTypes['Movie']> = {
182-
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
183-
title?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
184-
overview?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
185-
backdrop_path?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
186-
poster_path?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
187-
popularity?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
188-
favorite?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
189-
cast?: Resolver<Maybe<Array<ResolversTypes['Credit']>>, ParentType, ContextType>;
190-
__isTypeOf?: IsTypeOfResolverFn<ParentType>;
191-
};
173+
export type CacheControlDirectiveResolver<Result, Parent, ContextType = Context, Args = CacheControlDirectiveArgs> = DirectiveResolverFn<Result, Parent, ContextType, Args>;
192174

193175
export type CreditResolvers<ContextType = Context, ParentType extends ResolversParentTypes['Credit'] = ResolversParentTypes['Credit']> = {
176+
character?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
194177
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
195178
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
196-
character?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
197179
profile_path?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
198-
__isTypeOf?: IsTypeOfResolverFn<ParentType>;
180+
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
181+
};
182+
183+
export type MovieResolvers<ContextType = Context, ParentType extends ResolversParentTypes['Movie'] = ResolversParentTypes['Movie']> = {
184+
backdrop_path?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
185+
cast?: Resolver<Maybe<Array<ResolversTypes['Credit']>>, ParentType, ContextType>;
186+
favorite?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
187+
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
188+
overview?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
189+
popularity?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
190+
poster_path?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
191+
title?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
192+
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
199193
};
200194

201195
export type MutationResolvers<ContextType = Context, ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation']> = {
202196
toggleFavoriteMovie?: Resolver<Maybe<ResolversTypes['Movie']>, ParentType, ContextType, RequireFields<MutationToggleFavoriteMovieArgs, 'movieId'>>;
203197
};
204198

199+
export type QueryResolvers<ContextType = Context, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = {
200+
cast?: Resolver<Maybe<Array<Maybe<ResolversTypes['Credit']>>>, ParentType, ContextType, RequireFields<QueryCastArgs, 'movieId'>>;
201+
hello?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
202+
movieById?: Resolver<Maybe<ResolversTypes['Movie']>, ParentType, ContextType, RequireFields<QueryMovieByIdArgs, 'id'>>;
203+
nowPlaying?: Resolver<Maybe<Array<ResolversTypes['Movie']>>, ParentType, ContextType>;
204+
popular?: Resolver<Maybe<Array<ResolversTypes['Movie']>>, ParentType, ContextType>;
205+
};
206+
205207
export interface UploadScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['Upload'], any> {
206208
name: 'Upload';
207209
}
208210

209211
export type Resolvers<ContextType = Context> = {
210-
Query?: QueryResolvers<ContextType>;
211-
Movie?: MovieResolvers<ContextType>;
212212
Credit?: CreditResolvers<ContextType>;
213+
Movie?: MovieResolvers<ContextType>;
213214
Mutation?: MutationResolvers<ContextType>;
215+
Query?: QueryResolvers<ContextType>;
214216
Upload?: GraphQLScalarType;
215217
};
216218

217-
218-
/**
219-
* @deprecated
220-
* Use "Resolvers" root object instead. If you wish to get "IResolvers", add "typesPrefix: I" to your config.
221-
*/
222-
export type IResolvers<ContextType = Context> = Resolvers<ContextType>;
219+
export type DirectiveResolvers<ContextType = Context> = {
220+
cacheControl?: CacheControlDirectiveResolver<any, any, ContextType>;
221+
};

apollo.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
client: {
33
service: {
44
name: 'now playing app',
5-
url: 'http://localhost:4000/graphql',
5+
localSchemaFile: './schema.graphql',
66
},
77
includes: ['./app/src/**/graphql.ts', './app/src/**/*.tsx'], // array of glob patterns
88
excludes: ['./app/**/src/generated/**'],

app/src/context/ApolloProvider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function ApolloProvider({ children }: { children: React.ReactNode }) {
1111
const client = new ApolloClient({
1212
cache,
1313
link: new HttpLink({
14-
uri: '/graphql',
14+
uri: 'http://localhost:4000/graphql',
1515
}),
1616
});
1717

0 commit comments

Comments
 (0)