Skip to content

Commit

Permalink
fix: default context value for custom fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarenaldi committed Jan 6, 2025
1 parent 7b878fc commit 531439f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions examples/custom-fragments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const MyAccountFragment = graphql(
picture
}
}`,
[],
);

type MyAccount = FragmentOf<typeof MyAccountFragment>;
Expand All @@ -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 [
`<h2>${account?.username?.value}</h2>`,
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/context.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -35,6 +35,6 @@ export function configureContext<TConfig extends ClientConfig>(
debug: from.debug ?? false,
origin: from.origin,
storage: from.storage ?? new InMemoryStorageProvider(),
accountFragment: from.accountFragment,
accountFragment: from.accountFragment ?? AccountFragment,
} as ContextFrom<TConfig>;
}

0 comments on commit 531439f

Please sign in to comment.