From 14eca964079c1f937fcff9824ea8605b8c4c64fb Mon Sep 17 00:00:00 2001 From: Matthew Zikherman Date: Mon, 11 Jul 2016 11:30:50 -0400 Subject: [PATCH 1/2] Schema for followed artists filter --- .../aggregations/filter_artworks_aggregation.js | 3 +++ schema/filter_artworks.js | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/schema/aggregations/filter_artworks_aggregation.js b/schema/aggregations/filter_artworks_aggregation.js index d8109064bc..f06ca5d5df 100644 --- a/schema/aggregations/filter_artworks_aggregation.js +++ b/schema/aggregations/filter_artworks_aggregation.js @@ -39,6 +39,9 @@ export const ArtworksAggregation = new GraphQLEnumType({ TOTAL: { value: 'total', }, + FOLLOWED_ARTISTS: { + value: 'followed_artists', + }, }, }); diff --git a/schema/filter_artworks.js b/schema/filter_artworks.js index 7b7c8993c1..e2334cba06 100644 --- a/schema/filter_artworks.js +++ b/schema/filter_artworks.js @@ -23,10 +23,14 @@ export const FilterArtworksType = new GraphQLObjectType({ type: GraphQLInt, resolve: ({ aggregations }) => aggregations.total.value, }, + followed_artists_total: { + type: GraphQLInt, + resolve: ({ aggregations }) => aggregations.followed_artists.value, + }, aggregations: { type: new GraphQLList(ArtworksAggregationResultsType), resolve: ({ aggregations }) => - map(omit(aggregations, ['total']), (counts, slice) => ({ slice, counts })), + map(omit(aggregations, ['total', 'followed_artists']), (counts, slice) => ({ slice, counts })), }, }), }); @@ -53,6 +57,9 @@ const FilterArtworks = { extra_aggregation_gene_ids: { type: new GraphQLList(GraphQLString), }, + include_artworks_by_followed_artists: { + type: GraphQLBoolean, + }, for_sale: { type: GraphQLBoolean, }, @@ -96,7 +103,12 @@ const FilterArtworks = { type: GraphQLString, }, }, - resolve: (root, options) => gravity('filter/artworks', options), + resolve: (root, options, { rootValue: { accessToken } }) => { + if (accessToken) { + return gravity.with(accessToken)('filter/artworks', options); + } + return gravity('filter/artworks', options); + }, }; export default FilterArtworks; From fabff6689a7bf0799b0c0891ed09c0a8a0ee6002 Mon Sep 17 00:00:00 2001 From: Matthew Zikherman Date: Mon, 11 Jul 2016 16:35:14 -0400 Subject: [PATCH 2/2] Appease the linter --- schema/filter_artworks.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/schema/filter_artworks.js b/schema/filter_artworks.js index e2334cba06..8075da0f9e 100644 --- a/schema/filter_artworks.js +++ b/schema/filter_artworks.js @@ -17,6 +17,7 @@ export const FilterArtworksType = new GraphQLObjectType({ name: 'FilterArtworks', fields: () => ({ hits: { + description: 'Artwork results.', type: new GraphQLList(Artwork.type), }, total: { @@ -28,9 +29,12 @@ export const FilterArtworksType = new GraphQLObjectType({ resolve: ({ aggregations }) => aggregations.followed_artists.value, }, aggregations: { + description: 'Returns aggregation counts for the given filter query.', type: new GraphQLList(ArtworksAggregationResultsType), - resolve: ({ aggregations }) => - map(omit(aggregations, ['total', 'followed_artists']), (counts, slice) => ({ slice, counts })), + resolve: ({ aggregations }) => { + const whitelistedAggregations = omit(aggregations, ['total', 'followed_artists']); + return map(whitelistedAggregations, (counts, slice) => ({ slice, counts })); + }, }, }), });