-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduces accountFragment in client config
- Loading branch information
1 parent
9dcd3b3
commit 31d8364
Showing
10 changed files
with
258 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
import type { EnvironmentConfig } from '@lens-protocol/env'; | ||
import { AccountFragment } from '@lens-protocol/graphql'; | ||
import type { Account, FragmentDocumentFor } from '@lens-protocol/graphql'; | ||
import { type IStorageProvider, InMemoryStorageProvider } from '@lens-protocol/storage'; | ||
import type { ClientConfig } from './config'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export type Context = { | ||
export type Context<TAccount extends Account = Account> = { | ||
environment: EnvironmentConfig; | ||
cache: boolean; | ||
debug: boolean; | ||
origin?: string; | ||
storage: IStorageProvider; | ||
accountFragment: FragmentDocumentFor<TAccount>; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function configureContext(from: ClientConfig): Context { | ||
export function configureContext<TAccount extends Account>( | ||
from: ClientConfig<TAccount>, | ||
): Context<TAccount> { | ||
return { | ||
environment: from.environment, | ||
cache: from.cache ?? false, | ||
debug: from.debug ?? false, | ||
origin: from.origin, | ||
storage: from.storage ?? new InMemoryStorageProvider(), | ||
accountFragment: from.accountFragment ?? (AccountFragment as FragmentDocumentFor<TAccount>), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.