From 919857f2ae4528d400244bd6797b7b346fa1f374 Mon Sep 17 00:00:00 2001 From: dzucconi Date: Wed, 6 Mar 2024 10:02:25 -0500 Subject: [PATCH] feat(me): exposes followed profiles count --- _schemaV2.graphql | 3 +++ src/schema/v2/me/index.ts | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/_schemaV2.graphql b/_schemaV2.graphql index 5e59deca04..62c0d0e8db 100644 --- a/_schemaV2.graphql +++ b/_schemaV2.graphql @@ -12601,6 +12601,9 @@ type Me implements Node { type MeCounts { followedArtists: Int! + + # Returns the total count of followed profiles. There is currently no way to filter this count by `owner_type`. + followedProfiles: Int! savedArtworks: Int! savedSearches: Int! } diff --git a/src/schema/v2/me/index.ts b/src/schema/v2/me/index.ts index 525670be0c..d5c024729d 100644 --- a/src/schema/v2/me/index.ts +++ b/src/schema/v2/me/index.ts @@ -250,6 +250,27 @@ export const meType = new GraphQLObjectType({ } }, }, + followedProfiles: { + type: new GraphQLNonNull(GraphQLInt), + description: + "Returns the total count of followed profiles. There is currently no way to filter this count by `owner_type`.", + resolve: async (_me, { followedPartnersLoader }) => { + if (!followedPartnersLoader) return 0 + + try { + const { headers } = await followedPartnersLoader({ + page: 1, + size: 1, + total_count: true, + }) + + return headers["x-total-count"] ?? 0 + } catch (error) { + console.error(error) + return 0 + } + }, + }, savedArtworks: { type: new GraphQLNonNull(GraphQLInt), resolve: async (_me, _args, { collectionArtworksLoader }) => {