Skip to content

Commit

Permalink
Merge pull request #5611 from artsy/DIA-513-expose-followed-profiles-…
Browse files Browse the repository at this point in the history
…count-in-me-counts

feat(me): exposes followed profiles count
  • Loading branch information
dzucconi committed Mar 6, 2024
2 parents afe4836 + 919857f commit fe81a68
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _schemaV2.graphql
Expand Up @@ -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!
}
Expand Down
21 changes: 21 additions & 0 deletions src/schema/v2/me/index.ts
Expand Up @@ -250,6 +250,27 @@ export const meType = new GraphQLObjectType<any, ResolverContext>({
}
},
},
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 }) => {
Expand Down

0 comments on commit fe81a68

Please sign in to comment.