File tree Expand file tree Collapse file tree 8 files changed +23
-14
lines changed Expand file tree Collapse file tree 8 files changed +23
-14
lines changed Original file line number Diff line number Diff line change 44.*/node_modules/flow-bin/.*
55.*/node_modules/fbjs/.*
66
7+ .*/node_modules/graphql/subscription/mapAsyncIterator.js.flow
8+
79[include]
810
911[libs]
Original file line number Diff line number Diff line change 7373 "eslint" : " ^5.16.0" ,
7474 "eslint-plugin-babel" : " 5.3.0" ,
7575 "eslint-plugin-prettier" : " ^3.1.0" ,
76- "flow-bin" : " ^0.69 .0" ,
76+ "flow-bin" : " 0.121 .0" ,
7777 "isomorphic-fetch" : " 2.2.1" ,
7878 "isparta" : " ^4.1.1" ,
7979 "mocha" : " ^6.1.4" ,
Original file line number Diff line number Diff line change 11/**
2- * Copyright (c) 2015-present, Facebook, Inc.
2+ * Copyright (c) 2020, GraphQL Contributors
33 * All rights reserved.
44 *
55 * This source code is licensed under the license found in the
66 * LICENSE-examples file in the root directory of this source tree.
7+ *
78 */
89
910import { URL } from 'url' ;
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ const localUrlLoader = new DataLoader(urls =>
2020 * Objects returned from SWAPI don't have an ID field, so add one.
2121 */
2222function objectWithId ( obj : Object ) : Object {
23- obj . id = parseInt ( obj . url . split ( '/' ) [ 5 ] , 10 ) ;
23+ obj . id = obj . pk ;
2424 return obj ;
2525}
2626
@@ -52,18 +52,21 @@ type ObjectsByType = {
5252 */
5353export async function getObjectsByType ( type : string ) : Promise < ObjectsByType > {
5454 let objects = [ ] ;
55- let nextUrl = `https://swapi.co/api/ ${ type } / ` ;
55+ let nextUrl = `https://raw.githubusercontent.com/johnlindquist/swapi-json-server/master/ ${ type } .json ` ;
5656 while ( nextUrl ) {
5757 // eslint-disable-next-line no-await-in-loop
5858 const pageData = await localUrlLoader . load ( nextUrl ) ;
59- objects = objects . concat ( pageData . results . map ( objectWithId ) ) ;
59+
60+ objects = objects . concat ( pageData . map ( objectWithId ) . map ( d => d . fields ) ) ;
61+
6062 nextUrl = pageData . next ;
6163 }
6264 objects = sortObjectsById ( objects ) ;
6365 return { objects, totalCount : objects . length } ;
6466}
6567
6668export async function getObjectsFromUrls ( urls : string [ ] ) : Promise < Object [ ] > {
69+ console. log ( { urls } ) ;
6770 const array = await Promise . all ( urls . map ( getObjectFromUrl ) ) ;
6871 return sortObjectsById ( array ) ;
6972}
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ function rootFieldByID(idName, swapiType) {
6565 * Creates a connection that will return all objects of the given
6666 * `swapiType`; the connection will be named using `name`.
6767 */
68- function rootConnection ( name , swapiType ) {
68+ function rootConnection ( name : string , swapiType : string ) {
6969 const graphqlType = swapiTypeToGraphQLType ( swapiType ) ;
7070 const { connectionType } = connectionDefinitions ( {
7171 name,
@@ -79,6 +79,7 @@ This allows a client to fetch the first five objects by passing "5" as the
7979argument to "first", then fetch the total count so it could display "5 of 83",
8080for example.` ,
8181 } ,
82+ // $FlowFixMe
8283 [ swapiType ] : {
8384 type : new GraphQLList ( graphqlType ) ,
8485 resolve : conn => conn . edges . map ( edge => edge . node ) ,
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export function swapiTypeToGraphQLType(swapiType: string): GraphQLObjectType {
4343 }
4444}
4545
46+ // $FlowFixMe
4647const { nodeInterface, nodeField } = nodeDefinitions (
4748 globalId => {
4849 const { type, id } = fromGlobalId ( globalId ) ;
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ person does not have hair.`,
8989 species : {
9090 type : SpeciesType ,
9191 resolve : person => {
92+ console . log ( person ) ;
9293 if ( ! person . species || person . species . length === 0 ) {
9394 return null ;
9495 }
Original file line number Diff line number Diff line change @@ -2995,10 +2995,10 @@ flatted@^2.0.0:
29952995 resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.0.tgz#55122b6536ea496b4b44893ee2608141d10d9916"
29962996 integrity sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==
29972997
2998- flow-bin@^0.69 .0 :
2999- version "0.69 .0"
3000- resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.69 .0.tgz#053159a684a6051fcbf0b71a2eb19a9679082da6 "
3001- integrity sha512-SC5kiOiMk+8o1N2ZQ1mBfi0qBDYM+r6ZFQS7s+zXtyKrkbtCP+6JRTVvO3KXOnv568SK1G+Kg8/LlJwgyR+8Ug ==
2998+ flow-bin@0.121 .0 :
2999+ version "0.121 .0"
3000+ resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.121 .0.tgz#e206bdc3d510277f9a847920540f72c49e87c130 "
3001+ integrity sha512-QYRMs+AoMLj/OTaSo9+8c3kzM/u8YgvfrInp0qzhtzC02Sc2jb3BV/QZWZGjPo+XK3twyyqXrcI3s8MuL1UQRg ==
30023002
30033003flush-write-stream@^1.0.0 :
30043004 version "1.1.1"
@@ -3239,7 +3239,7 @@ graphql-relay@0.6.0:
32393239
32403240graphql@14.5.8 :
32413241 version "14.5.8"
3242- resolved "https://registry.npmjs.org /graphql/-/graphql-14.5.8.tgz#504f3d3114cb9a0a3f359bbbcf38d9e5bf6a6b3c"
3242+ resolved "https://registry.yarnpkg.com /graphql/-/graphql-14.5.8.tgz#504f3d3114cb9a0a3f359bbbcf38d9e5bf6a6b3c"
32433243 integrity sha512-MMwmi0zlVLQKLdGiMfWkgQD7dY/TUKt4L+zgJ/aR0Howebod3aNgP5JkgvAULiR2HPVZaP2VEElqtdidHweLkg==
32443244 dependencies :
32453245 iterall "^1.2.2"
@@ -3786,9 +3786,9 @@ istanbul@0.4.5:
37863786 wordwrap "^1.0.0"
37873787
37883788iterall@^1.2.2 :
3789- version "1.2.2 "
3790- resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.2.2 .tgz#92d70deb8028e0c39ff3164fdbf4d8b088130cd7 "
3791- integrity sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA ==
3789+ version "1.3.0 "
3790+ resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.3.0 .tgz#afcb08492e2915cbd8a0884eb93a8c94d0d72fea "
3791+ integrity sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg ==
37923792
37933793js-levenshtein@^1.1.3 :
37943794 version "1.1.6"
You can’t perform that action at this time.
0 commit comments