-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #568 from lens-protocol/fix/simplify-parametrized-…
…edges fix: simplifies parametrized edges
- Loading branch information
Showing
55 changed files
with
1,297 additions
and
1,111 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
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,11 +1,16 @@ | ||
import { ApolloCache, InMemoryCache, NormalizedCacheObject } from '@apollo/client'; | ||
|
||
import generatedIntrospection from '../../lens/graphql/generated'; | ||
import { QueryParams } from './createQueryParamsLocalFields'; | ||
import { createTypePolicies } from './createTypePolicies'; | ||
|
||
export function createLensCache(): ApolloCache<NormalizedCacheObject> { | ||
export type { QueryParams }; | ||
|
||
export { defaultQueryParams } from './createQueryParamsLocalFields'; | ||
|
||
export function createLensCache(options?: QueryParams): ApolloCache<NormalizedCacheObject> { | ||
return new InMemoryCache({ | ||
possibleTypes: generatedIntrospection.possibleTypes, | ||
typePolicies: createTypePolicies(), | ||
typePolicies: createTypePolicies(options), | ||
}); | ||
} |
103 changes: 103 additions & 0 deletions
103
packages/api-bindings/src/apollo/cache/createQueryParamsLocalFields.ts
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,103 @@ | ||
import { FieldReadFunction } from '@apollo/client'; | ||
|
||
import { ImageSizeTransform, ImageTransform, SupportedFiatType } from '../../lens'; | ||
|
||
/** | ||
* The common query parameters used across any query. | ||
*/ | ||
export type QueryParams = { | ||
image: { | ||
/** | ||
* The size of the small publication image | ||
*/ | ||
small: ImageTransform; | ||
/** | ||
* The size of the medium publication image | ||
*/ | ||
medium: ImageTransform; | ||
}; | ||
profile: { | ||
/** | ||
* The size of optimized profile image | ||
*/ | ||
thumbnail: ImageTransform; | ||
/** | ||
* The size of the cover image | ||
*/ | ||
cover: ImageTransform; | ||
}; | ||
/** | ||
* The fiat currency to use for the fx rate | ||
*/ | ||
fxRateFor: SupportedFiatType; | ||
}; | ||
|
||
function buildImageTransform( | ||
width: ImageSizeTransform, | ||
height: ImageSizeTransform = 'auto', | ||
): ImageTransform { | ||
return { | ||
width, | ||
height, | ||
keepAspectRatio: true, | ||
}; | ||
} | ||
|
||
/** | ||
* The default query parameters. | ||
*/ | ||
export const defaultQueryParams: QueryParams = { | ||
image: { | ||
small: buildImageTransform('400px'), | ||
medium: buildImageTransform('700px'), | ||
}, | ||
profile: { | ||
thumbnail: buildImageTransform('256px'), | ||
cover: buildImageTransform('1100px'), | ||
}, | ||
fxRateFor: SupportedFiatType.Usd, | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export type LocalOnlyFieldPolicies = { | ||
fxRateFor: FieldReadFunction<SupportedFiatType>; | ||
|
||
profileCoverSize: FieldReadFunction<ImageTransform>; | ||
|
||
profilePictureSize: FieldReadFunction<ImageTransform>; | ||
|
||
imageSmallSize: FieldReadFunction<ImageTransform>; | ||
|
||
imageMediumSize: FieldReadFunction<ImageTransform>; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function createQueryParamsLocalFields( | ||
params: QueryParams = defaultQueryParams, | ||
): LocalOnlyFieldPolicies { | ||
return { | ||
fxRateFor() { | ||
return params.fxRateFor; | ||
}, | ||
|
||
profileCoverSize() { | ||
return params.profile.cover; | ||
}, | ||
|
||
profilePictureSize() { | ||
return params.profile.thumbnail; | ||
}, | ||
|
||
imageSmallSize() { | ||
return params.image.small; | ||
}, | ||
|
||
imageMediumSize() { | ||
return params.image.medium; | ||
}, | ||
}; | ||
} |
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
Oops, something went wrong.