From 566be912065df1f949f8dff0a5085e278e28cfeb Mon Sep 17 00:00:00 2001 From: dan13ram Date: Wed, 16 Dec 2020 07:12:58 +0530 Subject: [PATCH] updated backend to read 3box collectiblesFavorite (#221) * updated backend to read 3box collectiblesFavorite * removed unneccesary '?' --- .../resolvers/getBoxProfile/resolver.ts | 15 ++++++++++++++- .../src/handlers/remote-schemas/typeDefs.ts | 6 ++++++ packages/codegen/schema.graphql | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/handlers/remote-schemas/resolvers/getBoxProfile/resolver.ts b/packages/backend/src/handlers/remote-schemas/resolvers/getBoxProfile/resolver.ts index 09bcd52a..34868d51 100644 --- a/packages/backend/src/handlers/remote-schemas/resolvers/getBoxProfile/resolver.ts +++ b/packages/backend/src/handlers/remote-schemas/resolvers/getBoxProfile/resolver.ts @@ -1,4 +1,4 @@ -import Box, { Image } from '3box'; +import Box, { CollectiblesFavorite, Image } from '3box'; import { CONFIG } from '../../../../config'; import { @@ -34,6 +34,9 @@ export const getBoxProfile: QueryResolvers['getBoxProfile'] = async ( height: 300, }), website: boxProfile.website, + collectiblesFavorites: getCollectiblesFavourites( + boxProfile.collectiblesFavorites, + ), }; }; @@ -47,3 +50,13 @@ function getImage( } return ''; } + +function getCollectiblesFavourites( + collectiblesFavorites: Array | null | undefined, +) { + if (!collectiblesFavorites) return []; + return collectiblesFavorites.map(({ address, token_id }) => ({ + address, + tokenId: token_id, + })); +} diff --git a/packages/backend/src/handlers/remote-schemas/typeDefs.ts b/packages/backend/src/handlers/remote-schemas/typeDefs.ts index 8146529c..319ff60d 100644 --- a/packages/backend/src/handlers/remote-schemas/typeDefs.ts +++ b/packages/backend/src/handlers/remote-schemas/typeDefs.ts @@ -16,6 +16,12 @@ export const typeDefs = gql` imageUrl: String coverImageUrl: String website: String + collectiblesFavorites: [CollectiblesFavorites!] + } + + type CollectiblesFavorites { + address: String + tokenId: String } type Moloch { diff --git a/packages/codegen/schema.graphql b/packages/codegen/schema.graphql index fc118083..3cbda0d4 100644 --- a/packages/codegen/schema.graphql +++ b/packages/codegen/schema.graphql @@ -358,6 +358,7 @@ enum AccountType_update_column { } type BoxProfile { + collectiblesFavorites: [CollectiblesFavorites!] coverImageUrl: String description: String emoji: String @@ -369,6 +370,11 @@ type BoxProfile { website: String } +type CollectiblesFavorites { + address: String + tokenId: String +} + """ columns and relationships of "EnneagramType" """