@khanacademy/graphql-flow 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +6 -0
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +10 -0
- package/.flowconfig +13 -0
- package/.github/actions/filter-files/action.yml +37 -0
- package/.github/actions/full-or-limited/action.yml +27 -0
- package/.github/actions/json-args/action.yml +32 -0
- package/.github/actions/setup/action.yml +28 -0
- package/.github/workflows/changeset-release.yml +80 -0
- package/.github/workflows/pr-checks.yml +64 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +14 -0
- package/Readme.md +172 -0
- package/build-copy-source.js +28 -0
- package/dist/enums.js +57 -0
- package/dist/enums.js.flow +69 -0
- package/dist/generateResponseType.js +267 -0
- package/dist/generateResponseType.js.flow +419 -0
- package/dist/generateVariablesType.js +132 -0
- package/dist/generateVariablesType.js.flow +153 -0
- package/dist/index.js +88 -0
- package/dist/index.js.flow +93 -0
- package/dist/jest-mock-graphql-tag.js +169 -0
- package/dist/jest-mock-graphql-tag.js.flow +191 -0
- package/dist/schemaFromIntrospectionData.js +69 -0
- package/dist/schemaFromIntrospectionData.js.flow +68 -0
- package/dist/types.js +1 -0
- package/dist/types.js.flow +54 -0
- package/dist/utils.js +53 -0
- package/dist/utils.js.flow +50 -0
- package/flow-typed/npm/@babel/types_vx.x.x.js +5317 -0
- package/flow-typed/npm/jest_v23.x.x.js +1155 -0
- package/flow-typed/overrides.js +435 -0
- package/package.json +41 -0
- package/src/__test__/example-schema.graphql +65 -0
- package/src/__test__/graphql-flow.test.js +364 -0
- package/src/__test__/jest-mock-graphql-tag.test.js +51 -0
- package/src/enums.js +69 -0
- package/src/generateResponseType.js +419 -0
- package/src/generateVariablesType.js +153 -0
- package/src/index.js +93 -0
- package/src/jest-mock-graphql-tag.js +191 -0
- package/src/schemaFromIntrospectionData.js +68 -0
- package/src/types.js +54 -0
- package/src/utils.js +50 -0
- package/tools/find-files-with-gql.js +40 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
// This file seletively brings in some lines from
|
|
3
|
+
// node_modules/react-native/Libraries/react-native/react-native-interface.js
|
|
4
|
+
// If we use the entire "lib" in our `.flowconfig` it erases the flowtypes
|
|
5
|
+
// for `fetch`.
|
|
6
|
+
|
|
7
|
+
declare var __DEV__: boolean;
|
|
8
|
+
|
|
9
|
+
// Copied from webapp: javascript/shared-package/learning-time/types.js
|
|
10
|
+
// Marks all properties of an object optional.
|
|
11
|
+
//
|
|
12
|
+
// We use this instead of $Shape<T> because spreading $Shape<$Exact<T>> ends up
|
|
13
|
+
// spreading $Exact<T> instead, losing the optionality of keys.
|
|
14
|
+
// https://github.com/facebook/flow/issues/6906#issuecomment-453439922
|
|
15
|
+
export type Partial<T> = $ReadOnly<$Rest<T, {}>>;
|
|
16
|
+
|
|
17
|
+
type GlobalHandler = (error: Error, isFatal: boolean) => void;
|
|
18
|
+
declare var ErrorUtils: ?{
|
|
19
|
+
getGlobalHandler: ?() => GlobalHandler,
|
|
20
|
+
_globalHandler: GlobalHandler,
|
|
21
|
+
setGlobalHandler: GlobalHandler => void,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
declare module debounce {
|
|
25
|
+
declare export default function debounce<A: Function>(
|
|
26
|
+
f: A,
|
|
27
|
+
interval?: number,
|
|
28
|
+
immediate?: boolean,
|
|
29
|
+
): A & {clear(): void} & {flush(): void};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare module 'comma-number' {
|
|
33
|
+
declare export default function commas(
|
|
34
|
+
number: number,
|
|
35
|
+
separator: string,
|
|
36
|
+
decimalChar: string,
|
|
37
|
+
): string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare module 'graphql' {
|
|
41
|
+
declare module.exports: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare module 'graphql/language/printer' {
|
|
45
|
+
declare module.exports: any;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare module 'metro-bundler/src/lib/TerminalReporter' {
|
|
49
|
+
declare module.exports: any;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare module 'metro-bundler' {
|
|
53
|
+
declare module.exports: any;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare module '../../local-cli/bundle/assetPathUtils' {
|
|
57
|
+
declare module.exports: any;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare module 'InteractionManager' {
|
|
61
|
+
declare module.exports: any;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Ported from TypeScript definitions for oauth-1.0a v2.2.3
|
|
65
|
+
declare module 'oauth-1.0a' {
|
|
66
|
+
/**
|
|
67
|
+
* OAuth data, including the signature.
|
|
68
|
+
*/
|
|
69
|
+
declare interface Authorization extends Data {
|
|
70
|
+
oauth_signature: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Method used to generate the body hash.
|
|
75
|
+
*
|
|
76
|
+
* Note: the key is used for implementation HMAC algorithms for the body hash,
|
|
77
|
+
* but typically it should return SHA1 hash of base_string.
|
|
78
|
+
*/
|
|
79
|
+
declare function BodyHashFunction(base_string: string, key: string): string;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* OAuth key/secret pair.
|
|
83
|
+
*/
|
|
84
|
+
declare interface Consumer {
|
|
85
|
+
key: string;
|
|
86
|
+
secret: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* OAuth data, excluding the signature.
|
|
91
|
+
*/
|
|
92
|
+
declare interface Data {
|
|
93
|
+
oauth_consumer_key: string;
|
|
94
|
+
oauth_nonce: string;
|
|
95
|
+
oauth_signature_method: string;
|
|
96
|
+
oauth_timestamp: number;
|
|
97
|
+
oauth_version: string;
|
|
98
|
+
oauth_token?: string;
|
|
99
|
+
oauth_body_hash?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Method used to hash the the OAuth and form/querystring data.
|
|
104
|
+
*/
|
|
105
|
+
declare function HashFunction(base_string: string, key: string): string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Authorization header.
|
|
109
|
+
*/
|
|
110
|
+
declare interface Header {
|
|
111
|
+
Authorization: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* OAuth options.
|
|
116
|
+
*/
|
|
117
|
+
declare interface Options {
|
|
118
|
+
body_hash_function?: typeof BodyHashFunction;
|
|
119
|
+
consumer: Consumer;
|
|
120
|
+
hash_function?: typeof HashFunction;
|
|
121
|
+
last_ampersand?: boolean;
|
|
122
|
+
nonce_length?: number;
|
|
123
|
+
parameter_seperator?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Realm is excluded from headers if missing here
|
|
126
|
+
*/
|
|
127
|
+
realm?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Defaults to 'PLAINTEXT'
|
|
130
|
+
*/
|
|
131
|
+
signature_method?: string;
|
|
132
|
+
version?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Extra data.
|
|
137
|
+
*/
|
|
138
|
+
declare interface Param {
|
|
139
|
+
[key: string]: string | string[];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Request options.
|
|
144
|
+
*/
|
|
145
|
+
declare interface RequestOptions {
|
|
146
|
+
url: string;
|
|
147
|
+
method: string;
|
|
148
|
+
data?: any;
|
|
149
|
+
includeBodyHash?: boolean;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* OAuth token key/secret pair.
|
|
154
|
+
*/
|
|
155
|
+
declare export interface Token {
|
|
156
|
+
key: string;
|
|
157
|
+
secret: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare export default class OAuth {
|
|
161
|
+
body_hash_function: typeof BodyHashFunction;
|
|
162
|
+
consumer: Consumer;
|
|
163
|
+
hash_function: typeof HashFunction;
|
|
164
|
+
last_ampersand: boolean;
|
|
165
|
+
nonce_length: number;
|
|
166
|
+
parameter_seperator: string;
|
|
167
|
+
realm?: string;
|
|
168
|
+
signature_method: string;
|
|
169
|
+
version: string;
|
|
170
|
+
|
|
171
|
+
constructor(opts?: Options): OAuth;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sign a request.
|
|
175
|
+
*/
|
|
176
|
+
authorize(request: RequestOptions, token?: ?Token): Authorization;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Generate the oauth signature (i.e. oauth_signature).
|
|
180
|
+
*/
|
|
181
|
+
getSignature(
|
|
182
|
+
request: RequestOptions,
|
|
183
|
+
token_secret?: string,
|
|
184
|
+
oauth_data: Data,
|
|
185
|
+
): string;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Generate the body signature (i.e. oauth_body_hash).
|
|
189
|
+
*/
|
|
190
|
+
getBodyHash(request: RequestOptions, token_secret?: string): string;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Encode the request attributes.
|
|
194
|
+
*
|
|
195
|
+
* Base String = "<Method>&<Base Url>&<ParameterString>"
|
|
196
|
+
*/
|
|
197
|
+
getBaseString(request: RequestOptions, oauth_data: Data): string;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Encode the oauth data and the request parameter,
|
|
201
|
+
*/
|
|
202
|
+
getParameterString(request: RequestOptions, oauth_data: Data): string;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Generate the signing key.
|
|
206
|
+
*
|
|
207
|
+
* Key = "<Consumer Key>&<Token Key or an empty string>"
|
|
208
|
+
*/
|
|
209
|
+
getSigningKey(token_secret?: string): string;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Return the the URL without its querystring.
|
|
213
|
+
*/
|
|
214
|
+
getBaseUrl(url: string): string;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Parse querystring / form data.
|
|
218
|
+
*/
|
|
219
|
+
deParam(str: string): Param;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Parse querystring from an url
|
|
223
|
+
*/
|
|
224
|
+
deParamUrl(url: string): Param;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Form data encoding.
|
|
228
|
+
*/
|
|
229
|
+
percentEncode(str: string): string;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Convert OAuth authorization data to an http header.
|
|
233
|
+
*/
|
|
234
|
+
toHeader(data: Authorization): Header;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Generate a random nonce.
|
|
238
|
+
*/
|
|
239
|
+
getNonce(): string;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Generate a current timestamp in second.
|
|
243
|
+
*/
|
|
244
|
+
getTimeStamp(): number;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Merge two object into a new one.
|
|
248
|
+
*/
|
|
249
|
+
mergeObject<T, U>(obj1: T, obj2: U): T & U;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Sort an object properties by keys.
|
|
253
|
+
*/
|
|
254
|
+
// NOTE (jeremy): Couldn't figure out the equivalent syntax in Flow yet!
|
|
255
|
+
// sortObject<O extends {[k: string]: any}, K extends string>(obj: O): Array<{key: keyof O, value: O[K]}>;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// These typings are based on the v4 types in flow-typed and updated
|
|
260
|
+
// using the TypeScript types in the project.
|
|
261
|
+
declare module '@react-native-community/netinfo' {
|
|
262
|
+
declare export type UnknownStateType =
|
|
263
|
+
// No network connection is active
|
|
264
|
+
// Platforms: Android, iOS, Windows, Web
|
|
265
|
+
| 'none'
|
|
266
|
+
// The network state could not or has yet to be be determined
|
|
267
|
+
// Platforms: Android, iOS, Windows, Web
|
|
268
|
+
| 'unknown';
|
|
269
|
+
|
|
270
|
+
declare export type CellularStateType =
|
|
271
|
+
// Active network over cellular
|
|
272
|
+
// Platforms: Android, iOS, Windows, Web
|
|
273
|
+
'cellular';
|
|
274
|
+
|
|
275
|
+
declare export type WifiStateType =
|
|
276
|
+
// Active network over Wifi
|
|
277
|
+
// Platforms: Android, iOS, Windows, Web
|
|
278
|
+
'wifi';
|
|
279
|
+
|
|
280
|
+
declare export type OtherStateType =
|
|
281
|
+
// Active network over Bluetooth
|
|
282
|
+
// Platforms: Android, Web
|
|
283
|
+
| 'bluetooth'
|
|
284
|
+
// Active network over wired ethernet
|
|
285
|
+
// Platforms: Android, Windows, Web
|
|
286
|
+
| 'ethernet'
|
|
287
|
+
// Active network over WiMax
|
|
288
|
+
// Platforms: Android, Web
|
|
289
|
+
| 'wimax'
|
|
290
|
+
// Active network over VPN
|
|
291
|
+
// Platforms: Android
|
|
292
|
+
| 'vpn'
|
|
293
|
+
// Active network over another type of network
|
|
294
|
+
// Platforms: Android, iOS, Windows, Web
|
|
295
|
+
| 'other';
|
|
296
|
+
|
|
297
|
+
declare export type CellularGeneration =
|
|
298
|
+
| null // Either we are not currently connected to a cellular network or type could not be determined
|
|
299
|
+
| '2g' // Currently connected to a 2G cellular network. Includes CDMA, EDGE, GPRS, and IDEN type connections
|
|
300
|
+
| '3g' // Currently connected to a 3G cellular network. Includes EHRPD, EVDO, HSPA, HSUPA, HSDPA, and UTMS type connections
|
|
301
|
+
| '4g'; // Currently connected to a 4G cellular network. Includes HSPAP and LTE type connections
|
|
302
|
+
|
|
303
|
+
declare type StateType =
|
|
304
|
+
| UnknownStateType
|
|
305
|
+
| CellularStateType
|
|
306
|
+
| WifiStateType
|
|
307
|
+
| OtherStateType;
|
|
308
|
+
|
|
309
|
+
declare type NetInfoStateDetailsWifi = {|
|
|
310
|
+
// If the network connection is considered "expensive". This could be
|
|
311
|
+
// in either energy or monetary terms. Platforms: Android, iOS,
|
|
312
|
+
// Windows, Web
|
|
313
|
+
+isConnectionExpensive: boolean,
|
|
314
|
+
// The SSID of the network. May not be present, null, or an empty
|
|
315
|
+
// string if it cannot be determined. On iOS, make sure your app
|
|
316
|
+
// meets at least one of the following requirements. On Android, you
|
|
317
|
+
// need to have the ACCESS_FINE_LOCATION permission in your
|
|
318
|
+
// AndroidManifest.xml and accepted by the user.
|
|
319
|
+
// Platforms: Android, iOS (not tvOS)
|
|
320
|
+
+ssid: string,
|
|
321
|
+
// An integer number from 0 to 5 for the signal strength. May not be
|
|
322
|
+
// present if the signal strength cannot be determined.
|
|
323
|
+
// Platforms: Android, iOS (not tvOS)
|
|
324
|
+
+strength: number,
|
|
325
|
+
// The external IP address. Can be in IPv4 or IPv6 format. May not be
|
|
326
|
+
// present if it cannot be determined.
|
|
327
|
+
// Platforms: Android, iOS
|
|
328
|
+
+ipAddress: string,
|
|
329
|
+
// The subnet mask in IPv4 format. May not be present if it cannot be
|
|
330
|
+
// determined.
|
|
331
|
+
// Platforms: Android, iOS
|
|
332
|
+
+subnet: string,
|
|
333
|
+
|};
|
|
334
|
+
|
|
335
|
+
declare type NetInfoStateDetailsCellular = {|
|
|
336
|
+
// If the network connection is considered "expensive". This could be
|
|
337
|
+
// in either energy or monetary terms.
|
|
338
|
+
// Platforms: Android, iOS, Windows, Web
|
|
339
|
+
+isConnectionExpensive: boolean,
|
|
340
|
+
// The generation of the cell network the user is connected to. This
|
|
341
|
+
// can give an indication of speed, but no guarantees. Platforms:
|
|
342
|
+
// Android, iOS,
|
|
343
|
+
// Windows
|
|
344
|
+
+cellularGeneration: CellularGeneration,
|
|
345
|
+
// The network carrier name. May not be present or may be empty if
|
|
346
|
+
// none can be determined.
|
|
347
|
+
// Platforms:Android, iOS
|
|
348
|
+
+carrier: string,
|
|
349
|
+
|};
|
|
350
|
+
|
|
351
|
+
declare type NetInfoStateDetailsOther = {|
|
|
352
|
+
// If the network connection is considered "expensive". This could be
|
|
353
|
+
// in either energy or monetary terms.
|
|
354
|
+
// Platforms: Android, iOS, Windows, Web
|
|
355
|
+
+isConnectionExpensive: boolean,
|
|
356
|
+
|};
|
|
357
|
+
|
|
358
|
+
declare export type NetInfoStateDescriptor<T, D> = $ReadOnly<{|
|
|
359
|
+
// The type of the current connection.
|
|
360
|
+
type: T,
|
|
361
|
+
// If there is an active network connection. Note that this DOES NOT
|
|
362
|
+
// mean that internet is reachable.
|
|
363
|
+
isConnected: boolean,
|
|
364
|
+
// If the internet is reachable with the currently active network
|
|
365
|
+
// connection.
|
|
366
|
+
isInternetReachable: boolean,
|
|
367
|
+
// (Android only) Whether the device's WiFi is ON or OFF.
|
|
368
|
+
isWifiEnabled: boolean,
|
|
369
|
+
// The value depends on the type value. See below.
|
|
370
|
+
details: D,
|
|
371
|
+
|}>;
|
|
372
|
+
|
|
373
|
+
declare export type NetInfoState =
|
|
374
|
+
| NetInfoStateDescriptor<UnknownStateType, null>
|
|
375
|
+
| NetInfoStateDescriptor<CellularStateType, NetInfoStateDetailsCellular>
|
|
376
|
+
| NetInfoStateDescriptor<WifiStateType, NetInfoStateDetailsWifi>
|
|
377
|
+
| NetInfoStateDescriptor<OtherStateType, NetInfoStateDetailsOther>;
|
|
378
|
+
|
|
379
|
+
declare export type NetInfoConfiguration = {|
|
|
380
|
+
// The URL to call to test if the internet is reachable. Only used on
|
|
381
|
+
// platforms which do not supply internet reachability natively.
|
|
382
|
+
reachabilityUrl: string,
|
|
383
|
+
// A function which is passed the Response from calling the
|
|
384
|
+
// reachability URL. It should return true if the response indicates
|
|
385
|
+
// that the internet is reachable. Only used on platforms which do
|
|
386
|
+
// not supply internet reachability natively.
|
|
387
|
+
reachabilityTest: (response: Response) => boolean,
|
|
388
|
+
// The number of milliseconds between internet reachability checks
|
|
389
|
+
// when the internet was not previously detected. Only used on
|
|
390
|
+
// platforms which do not supply internet reachability natively.
|
|
391
|
+
reachabilityShortTimeout: number,
|
|
392
|
+
// The number of milliseconds between internet reachability checks
|
|
393
|
+
// when the internet was previously detected. Only used on platforms
|
|
394
|
+
// which do not supply internet reachability natively.
|
|
395
|
+
reachabilityLongTimeout: number,
|
|
396
|
+
// The number of milliseconds that a reachability check is allowed to
|
|
397
|
+
// take before failing. Only used on platforms which do not supply
|
|
398
|
+
// internet reachability natively.
|
|
399
|
+
reachabilityRequestTimeout: number,
|
|
400
|
+
|};
|
|
401
|
+
|
|
402
|
+
declare export var NetInfoStateType: $ReadOnly<{|
|
|
403
|
+
none: 'none',
|
|
404
|
+
unknown: 'unknown',
|
|
405
|
+
cellular: 'cellular',
|
|
406
|
+
wifi: 'wifi',
|
|
407
|
+
bluetooth: 'bluetooth',
|
|
408
|
+
ethernet: 'ethernet',
|
|
409
|
+
wimax: 'wimax',
|
|
410
|
+
vpn: 'vpn',
|
|
411
|
+
other: 'other',
|
|
412
|
+
|}>;
|
|
413
|
+
|
|
414
|
+
declare export var NetInfoCellularGeneration: $ReadOnly<{|
|
|
415
|
+
'2g': '2g',
|
|
416
|
+
'3g': '3g',
|
|
417
|
+
'4g': '4g',
|
|
418
|
+
|}>;
|
|
419
|
+
|
|
420
|
+
declare export type NetInfoStateCallback = (state: NetInfoState) => void;
|
|
421
|
+
declare export type NetInfoSubscription = () => void;
|
|
422
|
+
declare export var reportConnected: () => void;
|
|
423
|
+
|
|
424
|
+
declare export default class NetInfo {
|
|
425
|
+
static configure: (
|
|
426
|
+
configuration: Partial<NetInfoConfiguration>,
|
|
427
|
+
) => void;
|
|
428
|
+
static addEventListener: (NetInfoStateCallback) => NetInfoSubscription;
|
|
429
|
+
static fetch: (iface?: StateType) => Promise<NetInfoState>;
|
|
430
|
+
|
|
431
|
+
static useNetInfo: (
|
|
432
|
+
configuration: NetInfoConfiguration,
|
|
433
|
+
) => NetInfoState;
|
|
434
|
+
}
|
|
435
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@khanacademy/graphql-flow",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"test": "jest",
|
|
6
|
+
"publish:ci": "yarn run build && yarn run copy-flow && changeset publish",
|
|
7
|
+
"build": "babel src --out-dir dist --ignore 'src/**/*.spec.js','src/**/*.test.js'",
|
|
8
|
+
"copy-flow": "node ./build-copy-source.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@babel/cli": "^7.17.6",
|
|
13
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
14
|
+
"@changesets/cli": "^2.21.1",
|
|
15
|
+
"@khanacademy/eslint-config": "^0.1.0",
|
|
16
|
+
"eslint": "8.7.0",
|
|
17
|
+
"eslint-config-prettier": "7.0.0",
|
|
18
|
+
"eslint-plugin-flowtype-errors": "^4.5.0",
|
|
19
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
20
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
21
|
+
"eslint-plugin-react": "^7.29.2",
|
|
22
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
23
|
+
"flow-bin": "^0.172.0",
|
|
24
|
+
"jest": "^27.5.1"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@babel/core": "^7.6.2",
|
|
28
|
+
"@babel/generator": "^7.17.3",
|
|
29
|
+
"@babel/polyfill": "^7.0.0",
|
|
30
|
+
"@babel/preset-env": "^7.16.11",
|
|
31
|
+
"@babel/preset-flow": "^7.16.7",
|
|
32
|
+
"@babel/types": "^7.17.0",
|
|
33
|
+
"apollo-utilities": "^1.3.4",
|
|
34
|
+
"babel-jest": "23.4.2",
|
|
35
|
+
"eslint-plugin-flowtype": "^8.0.3",
|
|
36
|
+
"graphql": "14.2.1",
|
|
37
|
+
"graphql-tag": "2.10.1",
|
|
38
|
+
"prettier": "^2.5.1",
|
|
39
|
+
"prettier-eslint": "^13.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
scalar PositiveNumber
|
|
2
|
+
|
|
3
|
+
enum Episode { NEW_HOPE, EMPIRE, JEDI }
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
A movie character
|
|
7
|
+
"""
|
|
8
|
+
interface Character {
|
|
9
|
+
id: String!
|
|
10
|
+
name: String
|
|
11
|
+
friends: [Character]
|
|
12
|
+
appearsIn: [Episode]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
A human character
|
|
17
|
+
"""
|
|
18
|
+
type Human implements Character {
|
|
19
|
+
id: String!
|
|
20
|
+
"""The person's name"""
|
|
21
|
+
name: String
|
|
22
|
+
friends: [Character]
|
|
23
|
+
appearsIn: [Episode]
|
|
24
|
+
homePlanet: String
|
|
25
|
+
alive: Boolean
|
|
26
|
+
hands: PositiveNumber
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
A robot character
|
|
31
|
+
"""
|
|
32
|
+
type Droid implements Character {
|
|
33
|
+
id: String!
|
|
34
|
+
name: String
|
|
35
|
+
friends: [Character]
|
|
36
|
+
appearsIn: [Episode]
|
|
37
|
+
"""The robot's primary function"""
|
|
38
|
+
primaryFunction: String
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type Animal {
|
|
42
|
+
name: String
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
union Friendable = Human | Droid | Animal
|
|
46
|
+
|
|
47
|
+
type Query {
|
|
48
|
+
hero(episode: Episode): Character
|
|
49
|
+
human(id: String!): Human
|
|
50
|
+
droid(id: String!): Droid
|
|
51
|
+
friend(id: String!): Friendable
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
"""A character to add"""
|
|
55
|
+
input CharacterInput {
|
|
56
|
+
"""The new character's name"""
|
|
57
|
+
name: String!
|
|
58
|
+
"""The character's friends"""
|
|
59
|
+
friends: [ID!]
|
|
60
|
+
appearsIn: [Episode!]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type Mutation {
|
|
64
|
+
addCharacter(character: CharacterInput!): Character
|
|
65
|
+
}
|