Skip to content

Commit 9082588

Browse files
committed
add clearEvents to region
1 parent 3da0c77 commit 9082588

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

src/remotes/clear.js

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function getConnectionTypes(prefix) {
1313
}
1414
1515
extend type ${prefix}EventGroup {
16-
cmsEventGroup: CmsEvent
16+
cmsEventGroup: CmsEventCollection
1717
}
1818
1919
extend type ${prefix}PublicPerson {
@@ -68,35 +68,17 @@ function getConnectionResolvers(prefix, schemas) {
6868
selectionSet: "{ contentfulId }",
6969
async resolve(parent, args, context, info) {
7070
if (!parent.contentfulId) return null;
71-
return batchDelegateToSchema({
71+
return delegateToSchema({
7272
schema: schemas.cms,
7373
operation: "query",
74-
fieldName: "eventCollection",
75-
key: parent.contentfulId,
76-
argsFromKeys: (id) => ({ where: { id } }),
74+
fieldName: 'eventCollection',
7775
context,
7876
info,
79-
valuesFromResults: (results, keys) =>
80-
keys?.map((key) =>
81-
results.find((result) => result?.id === key)
82-
),
83-
transforms: [
84-
new AddFieldToRequestTransform(schemas.cms, "Event", "id"),
85-
new TransformQuery({
86-
path: ['eventCollection'],
87-
queryTransformer: (subtree) => ({
88-
kind: Kind.SELECTION_SET,
89-
selections: [
90-
{
91-
kind: Kind.FIELD,
92-
name: { kind: Kind.NAME, value: 'items' },
93-
selectionSet: subtree,
94-
},
95-
],
96-
}),
97-
resultTransformer: (result) => (result?.items || [])
98-
}),
99-
],
77+
args: {
78+
where: {
79+
id: parent.contentfulId,
80+
},
81+
},
10082
});
10183
},
10284
},

src/remotes/contentful.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function getConnectionTypes(prefix) {
1313
}
1414
extend type ${prefix}Region {
1515
pastPhotos(where: ShowcasePhotosWhere, orderBy: ShowcasePhotoOrderByArg, take: Float, skip: Float): [ShowcasePhoto!]!
16+
clearEvents: [ClearEvent!]!
1617
}
1718
`;
1819
}
@@ -62,6 +63,25 @@ function getConnectionResolvers(prefix, schemas) {
6263
});
6364
},
6465
},
66+
67+
clearEvents: {
68+
selectionSet: '{ webname }',
69+
async resolve(parent, args, context, info) {
70+
return delegateToSchema({
71+
schema: schemas.clear,
72+
operation: 'query',
73+
fieldName: 'events',
74+
args: {
75+
where: {
76+
contentfulWebname: { equals: parent.webname },
77+
},
78+
orderBy: [{ startDate: 'desc' }],
79+
},
80+
context,
81+
info,
82+
});
83+
},
84+
},
6585
},
6686

6787
[`${prefix}Asset`]: {

0 commit comments

Comments
 (0)