Skip to content

Commit

Permalink
react: enable profile field policy
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysu committed Apr 11, 2024
1 parent 0734bef commit 02967d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-horses-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lens-protocol/api-bindings": patch
---

**feat:** enabled profile field policy
4 changes: 2 additions & 2 deletions packages/api-bindings/src/apollo/cache/createTypePolicies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
createFollowingFieldPolicy,
createMutualFollowersFieldPolicy,
createProfileActionHistoryFieldPolicy,
createProfileFieldPolicy,
createProfileRecommendationsFieldPolicy,
createProfilesFieldPolicy,
createPublicationFieldPolicy,
Expand Down Expand Up @@ -68,8 +69,7 @@ export function createTypePolicies(): StrictTypedTypePolicies & InheritedTypePol
mutualFollowers: createMutualFollowersFieldPolicy(),
profileActionHistory: createProfileActionHistoryFieldPolicy(),
profileRecommendations: createProfileRecommendationsFieldPolicy(),
// TODO: investigate correct usage of cache redirect
// profile: createProfileFieldPolicy() as FieldPolicy<unknown>,
profile: createProfileFieldPolicy() as FieldPolicy<unknown>,
profiles: createProfilesFieldPolicy(),
publication: createPublicationFieldPolicy() as FieldPolicy<unknown>,
publications: createPublicationsFieldPolicy(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { FieldFunctionOptions, FieldPolicy, Reference } from '@apollo/client';

import { Profile, ProfileRequest } from '../../../lens';
import { ProfileRequest } from '../../../lens';

// this function is not in use
// TODO: investigate correct usage of cache redirect
export function createProfileFieldPolicy(): FieldPolicy<
Profile,
Profile,
Reference,
Reference,
Reference,
FieldFunctionOptions<{ request: ProfileRequest }>
> {
return {
read(_, { args, toReference, canRead }) {
read(existing, { args, toReference, canRead }) {
if (existing) {
return existing;
}

if (!args) {
return undefined;
}
Expand Down

0 comments on commit 02967d1

Please sign in to comment.