Skip to content

Commit b5a7f08

Browse files
committed
Revert "fix: get it mostly working again with new datasource"
This reverts commit 70e56d1.
1 parent 70e56d1 commit b5a7f08

File tree

8 files changed

+14
-23
lines changed

8 files changed

+14
-23
lines changed

.flowconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
.*/node_modules/flow-bin/.*
55
.*/node_modules/fbjs/.*
66

7-
.*/node_modules/graphql/subscription/mapAsyncIterator.js.flow
8-
97
[include]
108

119
[libs]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"eslint": "^5.16.0",
7474
"eslint-plugin-babel": "5.3.0",
7575
"eslint-plugin-prettier": "^3.1.0",
76-
"flow-bin": "0.121.0",
76+
"flow-bin": "^0.69.0",
7777
"isomorphic-fetch": "2.2.1",
7878
"isparta": "^4.1.1",
7979
"mocha": "^6.1.4",

scripts/download.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/**
2-
* Copyright (c) 2020, GraphQL Contributors
2+
* Copyright (c) 2015-present, Facebook, Inc.
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-
*
87
*/
98

109
import { URL } from 'url';

src/schema/apiHelper.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff 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
*/
2222
function objectWithId(obj: Object): Object {
23-
obj.id = obj.pk;
23+
obj.id = parseInt(obj.url.split('/')[5], 10);
2424
return obj;
2525
}
2626

@@ -52,21 +52,18 @@ type ObjectsByType = {
5252
*/
5353
export async function getObjectsByType(type: string): Promise<ObjectsByType> {
5454
let objects = [];
55-
let nextUrl = `https://raw.githubusercontent.com/johnlindquist/swapi-json-server/master/${type}.json`;
55+
let nextUrl = `https://swapi.co/api/${type}/`;
5656
while (nextUrl) {
5757
// eslint-disable-next-line no-await-in-loop
5858
const pageData = await localUrlLoader.load(nextUrl);
59-
60-
objects = objects.concat(pageData.map(objectWithId).map(d => d.fields));
61-
59+
objects = objects.concat(pageData.results.map(objectWithId));
6260
nextUrl = pageData.next;
6361
}
6462
objects = sortObjectsById(objects);
6563
return { objects, totalCount: objects.length };
6664
}
6765

6866
export async function getObjectsFromUrls(urls: string[]): Promise<Object[]> {
69-
console.log({ urls });
7067
const array = await Promise.all(urls.map(getObjectFromUrl));
7168
return sortObjectsById(array);
7269
}

src/schema/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff 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: string, swapiType: string) {
68+
function rootConnection(name, swapiType) {
6969
const graphqlType = swapiTypeToGraphQLType(swapiType);
7070
const { connectionType } = connectionDefinitions({
7171
name,
@@ -79,7 +79,6 @@ This allows a client to fetch the first five objects by passing "5" as the
7979
argument to "first", then fetch the total count so it could display "5 of 83",
8080
for example.`,
8181
},
82-
// $FlowFixMe
8382
[swapiType]: {
8483
type: new GraphQLList(graphqlType),
8584
resolve: conn => conn.edges.map(edge => edge.node),

src/schema/relayNode.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export function swapiTypeToGraphQLType(swapiType: string): GraphQLObjectType {
4343
}
4444
}
4545

46-
// $FlowFixMe
4746
const { nodeInterface, nodeField } = nodeDefinitions(
4847
globalId => {
4948
const { type, id } = fromGlobalId(globalId);

src/schema/types/person.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ person does not have hair.`,
8989
species: {
9090
type: SpeciesType,
9191
resolve: person => {
92-
console.log(person);
9392
if (!person.species || person.species.length === 0) {
9493
return null;
9594
}

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff 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.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==
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==
30023002

30033003
flush-write-stream@^1.0.0:
30043004
version "1.1.1"
@@ -3239,7 +3239,7 @@ [email protected]:
32393239

32403240
32413241
version "14.5.8"
3242-
resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.5.8.tgz#504f3d3114cb9a0a3f359bbbcf38d9e5bf6a6b3c"
3242+
resolved "https://registry.npmjs.org/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 @@ [email protected]:
37863786
wordwrap "^1.0.0"
37873787

37883788
iterall@^1.2.2:
3789-
version "1.3.0"
3790-
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.3.0.tgz#afcb08492e2915cbd8a0884eb93a8c94d0d72fea"
3791-
integrity sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg==
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==
37923792

37933793
js-levenshtein@^1.1.3:
37943794
version "1.1.6"

0 commit comments

Comments
 (0)