The `QueryResultGettersFactory` that is called on every query return to was called only on the first level of relations because recursivity wasn't implemented. In this PR I implement recursivity and add some typing for the possible forms a GraphQL query field can take. This PR will fix any issue we have with pictures that were losing their token (here for person.avatarUrl) Fixes https://github.com/twentyhq/twenty/issues/8425 Fixes https://github.com/twentyhq/twenty/issues/8498 --------- Co-authored-by: Weiko <corentin@twenty.com>
20 lines
632 B
TypeScript
20 lines
632 B
TypeScript
import { REACT_APP_SERVER_BASE_URL } from '@ui/utilities/config';
|
|
|
|
// TODO: this is a code smell trying to guess whether it's a relative path or not
|
|
// We should instead put the meaning onto our variables and parameters
|
|
// imageUrl should be either imageAbsoluteURL or imageRelativeServerPath
|
|
// But we need to refactor the chain of calls to this function
|
|
export const getImageAbsoluteURI = (imageUrl?: string | null) => {
|
|
if (!imageUrl) {
|
|
return null;
|
|
}
|
|
|
|
if (imageUrl?.startsWith('http')) {
|
|
return imageUrl;
|
|
}
|
|
|
|
const serverFilesUrl = REACT_APP_SERVER_BASE_URL;
|
|
|
|
return `${serverFilesUrl}/files/${imageUrl}`;
|
|
};
|