Skip to content

Commit

Permalink
Add region resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
tylermenezes committed Nov 8, 2021
1 parent 650e859 commit 2ae468f
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/remotes/showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function getConnectionTypes(prefix) {
extend type ${prefix}Project {
eventGroup: CmsEvent
program: CmsProgram
region: CmsRegion
}
extend type ${prefix}Award {
Expand Down Expand Up @@ -86,6 +87,7 @@ function getConnectionResolvers(prefix, schemas) {
program: {
selectionSet: '{ programId }',
async resolve(parent, args, context, info) {
if (!parent.programId) return null;
return delegateToSchema({
schema: schemas.cms,
operation: 'query',
Expand Down Expand Up @@ -120,9 +122,11 @@ function getConnectionResolvers(prefix, schemas) {
});
},
},

eventGroup: {
selectionSet: '{ eventGroupId }',
async resolve(parent, args, context, info) {
if (!parent.eventGroupId) return null;
return delegateToSchema({
schema: schemas.cms,
operation: 'query',
Expand Down Expand Up @@ -157,6 +161,45 @@ function getConnectionResolvers(prefix, schemas) {
});
},
},

region: {
selectionSet: '{ regionId }',
async resolve(parent, args, context, info) {
if (!parent.regionId) return null;
return delegateToSchema({
schema: schemas.cms,
operation: 'query',
fieldName: 'regionCollection',
args: {
where: {
webname: parent.regionId,
},
limit: 1,
},
context,
info,
transforms: [
new TransformQuery({
path: ['regionCollection'],
queryTransformer: (subtree) => ({
kind: Kind.SELECTION_SET,
selections: [
{
kind: Kind.FIELD,
name: {
kind: Kind.NAME,
value: 'items',
},
selectionSet: subtree,
},
],
}),
resultTransformer: (r) => r?.items[0],
}),
],
});
},
},
}
};
}
Expand Down

0 comments on commit 2ae468f

Please sign in to comment.