* Handled new url v2 type * Fixed refetch queries * wip * Ok delete but views bug * Fix lint --------- Co-authored-by: Charles Bochet <charles@twenty.com>
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import { gql } from '@apollo/client';
|
|
|
|
import { FieldType } from '@/ui/data/field/types/FieldType';
|
|
|
|
import { MetadataObject } from '../types/MetadataObject';
|
|
|
|
export const generateFindManyCustomObjectsQuery = ({
|
|
metadataObject,
|
|
_fromCursor,
|
|
}: {
|
|
metadataObject: MetadataObject;
|
|
_fromCursor?: string;
|
|
}) => {
|
|
return gql`
|
|
query FindMany${metadataObject.namePlural} {
|
|
${metadataObject.namePlural}{
|
|
edges {
|
|
node {
|
|
id
|
|
${metadataObject.fields
|
|
.map((field) => {
|
|
// TODO: parse
|
|
const fieldType = field.type as FieldType;
|
|
|
|
if (fieldType === 'text') {
|
|
return field.name;
|
|
} else if (fieldType === 'url') {
|
|
return `
|
|
${field.name}
|
|
{
|
|
text
|
|
link
|
|
}
|
|
`;
|
|
}
|
|
})
|
|
.join('\n')}
|
|
}
|
|
cursor
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
};
|