From 531439fd154c079e3bb2594d7083963e4dd0d1e0 Mon Sep 17 00:00:00 2001 From: Cesare Naldi Date: Thu, 26 Dec 2024 15:08:17 +0100 Subject: [PATCH] fix: default context value for custom fragments --- examples/custom-fragments/index.ts | 8 +------- packages/client/src/context.ts | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/custom-fragments/index.ts b/examples/custom-fragments/index.ts index 0d9f3b3e2..5d516eb87 100644 --- a/examples/custom-fragments/index.ts +++ b/examples/custom-fragments/index.ts @@ -22,7 +22,6 @@ const MyAccountFragment = graphql( picture } }`, - [], ); type MyAccount = FragmentOf; @@ -34,12 +33,7 @@ const client = PublicClient.create({ const account: MyAccount | null = await fetchAccount(client, { address: evmAddress('0x57b62a1571F4F09CDB4C3d93dA542bfe142D9F81'), -}).match( - (account) => account, - (error) => { - throw error; - }, -); +}).unwrapOr(null); export default [ `

${account?.username?.value}

`, diff --git a/packages/client/src/context.ts b/packages/client/src/context.ts index 2765caa29..7c0623a56 100644 --- a/packages/client/src/context.ts +++ b/packages/client/src/context.ts @@ -1,5 +1,5 @@ import type { EnvironmentConfig } from '@lens-protocol/env'; -import type { Account } from '@lens-protocol/graphql'; +import { type Account, AccountFragment } from '@lens-protocol/graphql'; import type { FragmentDocumentFor } from '@lens-protocol/graphql'; import { type IStorageProvider, InMemoryStorageProvider } from '@lens-protocol/storage'; import type { ClientConfig } from './config'; @@ -35,6 +35,6 @@ export function configureContext( debug: from.debug ?? false, origin: from.origin, storage: from.storage ?? new InMemoryStorageProvider(), - accountFragment: from.accountFragment, + accountFragment: from.accountFragment ?? AccountFragment, } as ContextFrom; }