Skip to content

Commit 4e68e3b

Browse files
committed
Updated composition examples datasource types
1 parent c582e57 commit 4e68e3b

6 files changed

Lines changed: 9 additions & 9 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
'use strict';
1+
import { DataSourceDefinition, ComponentContext } from '../../../src';
22

33
const propertiesDB = {
44
1: { id: 1, geo: ['41.40338', '2.17403']},
55
2: { id: 2, geo: ['111.1111', '222.2222']}
66
}
77

8-
export default class PropertyDataSource {
8+
export default class PropertyDataSource implements DataSourceDefinition<PropertyDataSource> {
99
name = 'PropertyDataSource';
1010

11-
getPropertyById(context, id) {
11+
getPropertyById(context: ComponentContext, id: string) {
1212
return propertiesDB[id];
1313
}
1414
}

examples/composition/property-component/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
import { types } from "./types";
44
import GraphQLComponent from "../../../src";

examples/composition/property-component/resolvers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
export const resolvers = {
44
Query: {
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
'use strict';
22

3+
import { ComponentContext, DataSourceDefinition } from "../../../src";
4+
35
// reviews indexed by property id
46
const reviewsDB = {
57
1: [ { id: 'rev-id-1-a', content: 'this property was great'}, { id: 'rev-id-1-b', content: 'this property was terrible'}],
68
2: [ { id: 'rev-id-2-a', content: 'This property was amazing for our extended family'}, { id: 'rev-id-2-b', content: 'I loved the proximity to the beach'}, { id: 'rev-id-2-c', content: 'The bed was not comfortable at all'}]
79
}
810

9-
export default class ReviewsDataSource {
11+
export default class ReviewsDataSource implements DataSourceDefinition<ReviewsDataSource> {
1012
name = 'ReviewsDataSource';
1113

12-
getReviewsByPropertyId(context, propertyId) {
14+
getReviewsByPropertyId(context: ComponentContext, propertyId: string) {
1315
return reviewsDB[propertyId]
1416
}
1517
};

examples/composition/reviews-component/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21

32
import { types } from "./types";
43
import GraphQLComponent from "../../../src";

examples/composition/reviews-component/resolvers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21

32
export const resolvers = {
43
Query: {

0 commit comments

Comments
 (0)