-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enables custom AccountFragment
- fix: type-fest dep - feat: adds test coverage before refactoring - fix: client generic type and extra aliased field - feat: renames Post fragment into PostFragment - feat: renames PaginatedResultInfo into PaginatedResultInfoFragment - feat: injects AccountFragment into notifications query
- Loading branch information
1 parent
c6dcb3e
commit 8a0c40b
Showing
25 changed files
with
408 additions
and
217 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { testnet } from '@lens-protocol/env'; | ||
import { assertOk, evmAddress } from '@lens-protocol/types'; | ||
import { describe, it } from 'vitest'; | ||
|
||
import { FullAccountFragment } from '@lens-protocol/graphql'; | ||
import { PublicClient } from '../clients'; | ||
import { fetchAccount } from './account'; | ||
|
||
describe('Given the Account query actions', () => { | ||
const client = PublicClient.create({ | ||
environment: testnet, | ||
origin: 'http://example.com', | ||
accountFragment: FullAccountFragment, | ||
}); | ||
|
||
describe(`When invoking the '${fetchAccount.name}' action`, () => { | ||
it('Then it should not fail w/ a GQL BadRequest error', async () => { | ||
const result = await fetchAccount(client, { | ||
address: evmAddress(import.meta.env.TEST_ACCOUNT), | ||
}); | ||
|
||
assertOk(result); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { assertOk } from '@lens-protocol/types'; | ||
import { describe, it } from 'vitest'; | ||
|
||
import { loginAsAccountOwner } from '../../testing-utils'; | ||
import { fetchNotifications } from './notifications'; | ||
|
||
describe(`Given the '${fetchNotifications.name}' action`, () => { | ||
describe('When invoked', () => { | ||
it('Then it should not fail w/ a GQL BadRequest error', async () => { | ||
const result = await loginAsAccountOwner().andThen(fetchNotifications); | ||
|
||
assertOk(result); | ||
}); | ||
}); | ||
}); |
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
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>), | ||
}; | ||
} |
Oops, something went wrong.