Skip to content

Commit 461af8e

Browse files
committed
FIX loading example data
1 parent 52a4b7c commit 461af8e

9 files changed

Lines changed: 247 additions & 249 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/bazel-out
1010

1111
# generated files
12-
example-data.json
12+
example-data.ts
1313
/metrics
1414
feature-table.json
1515

projects/aws/tsconfig.app.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"outDir": "../../out-tsc/app",
55
"types": [
66
"node"
7-
],
8-
"resolveJsonModule": true,
7+
]
98
},
109
"angularCompilerOptions": {
1110
"fullTemplateTypeCheck": false
@@ -18,6 +17,5 @@
1817
"src/**/*.ts",
1918
"src/**/*.d.ts"
2019
],
21-
"exclude": [
22-
]
20+
"exclude": []
2321
}

projects/firebase/src/import-example-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
export type Database = Firestore;
1919
export type Collection = CollectionReference;
2020

21-
import exampleData from '../../../example-data.json';
21+
import { exampleData } from '../../../example-data';
2222

2323
async function importExampleDataset(db: Firestore) {
2424

projects/pouchdb/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import PouchReplicationPlugin from 'pouchdb-replication';
99
import PouchdbAdapterHttp from 'pouchdb-adapter-http';
1010
import { COUCHDB_PATH, normalToPouchDoc } from './app/shared';
1111

12-
import exampleData from '../../../example-data.json';
12+
import { exampleData } from '../../../example-data';
1313

1414
const PouchDB: any = PouchDBModule;
1515
PouchDB.plugin(PouchDbFindModule);

projects/rxdb-base/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Message, User } from 'src/shared/types';
2626
import { RxUsersSchema } from './src/app/schemas/user.schema';
2727
import { RxMessagesSchema } from './src/app/schemas/message.schema';
2828

29-
import exampleData from '../../example-data.json';
29+
import { exampleData } from '../../example-data';
3030

3131
function log(msg: any) {
3232
const prefix = '# GraphQL Server: ';

projects/rxdb-base/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { RxUsersSchema } from './app/schemas/user.schema';
2727
import { RxMessagesSchema } from './app/schemas/message.schema';
2828
import { lastOfArray } from 'rxdb';
2929

30-
import exampleData from '../../../example-data.json';
30+
import { exampleData } from '../../../example-data';
3131

3232
function log(msg: any) {
3333
const prefix = '# GraphQL Server: ';

scripts/generate-example-data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as path from 'path';
2222
const EXAMPLE_DATA_PATH = path.join(
2323
__dirname,
2424
'../',
25-
'example-data.json'
25+
'example-data.ts'
2626
);
2727

2828
/**
@@ -54,7 +54,7 @@ let lastUserId = 0;
5454
function randUser(): User {
5555
lastUserId++;
5656
return {
57-
id: FakerName.firstName().toLowerCase(),
57+
id: FakerName.firstName().toLowerCase() + lastUserId,
5858
createdAt: unixInSeconds()
5959
};
6060
}
@@ -114,7 +114,7 @@ async function run() {
114114
const data = getExampleDataset();
115115
fs.writeFileSync(
116116
EXAMPLE_DATA_PATH,
117-
JSON.stringify(data, null, 4)
117+
'export const exampleData = ' + JSON.stringify(data, null, 4) + ' as const;'
118118
);
119119
}
120120
run();

src/shared/data-generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from './types';
55

66

7-
import * as exampleData from '../../example-data.json';
7+
import { exampleData } from '../../example-data';
88

99
/**
1010
* returns a complete set of users with messages
@@ -13,5 +13,5 @@ export function getExampleDataset(): {
1313
messages: Message[];
1414
users: User[];
1515
} {
16-
return exampleData;
16+
return exampleData as any;
1717
}

0 commit comments

Comments
 (0)