Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Added featuredEvent property to community type #41

Merged
merged 2 commits into from
Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/community/communityFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ const communityType = new GraphQLObjectType({
type: GraphQLString,
description: 'The title of the community mailing list',
},
featuredEvent: {
type: EventType,
description: 'The community\'s featured event',
resolve(community) {
if (community) {
const id = pathOr('', ['document', 'id'], community.featuredEvent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default to empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or null?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense to me.

return getDocumentById(id, 'event', sanitizeEventAndNews);
}
return {};
},
},
events: {
type: new GraphQLList(EventType),
description: 'The community\'s events',
Expand Down
1 change: 1 addition & 0 deletions lib/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function sanitizeCommunity(json) {
summary: get('community.summary'),
mailingListTitle: get('community.mailingListTitle'),
events: get('community.events'),
featuredEvent: get('community.featuredEvent'),
};
}

Expand Down
2 changes: 2 additions & 0 deletions lib/fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe('sanitizeCommunity', () => {
'community.summary': { value: 'aaa' },
'community.title': { value: 'example title' },
'community.mailingListTitle': { value: 'bbb' },
'community.featuredEvent': { value: 'example event' },
'community.events': { value: [{ event: 'exampleEvent' }] },
},
};
Expand All @@ -115,6 +116,7 @@ describe('sanitizeCommunity', () => {
mailingListTitle: 'bbb',
id: 'exampleId',
title: 'example title',
featuredEvent: 'example event',
events: [
{
event: 'exampleEvent',
Expand Down
9 changes: 9 additions & 0 deletions prismic/custom-types/community.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
"label" : "Mailing List Summary"
}
},
"featuredEvent" : {
"type" : "Link",
"fieldset" : "Featured Event",
"config" : {
"select" : "document",
"customtypes" : [ "event" ],
"placeholder" : "Link to a event"
}
},
"events" : {
"type" : "Group",
"fieldset" : "Community Events",
Expand Down