diff --git a/packages/core/src/fields/types/relationship/views/index.tsx b/packages/core/src/fields/types/relationship/views/index.tsx index 721c17dc5ec..7b9c135817b 100644 --- a/packages/core/src/fields/types/relationship/views/index.tsx +++ b/packages/core/src/fields/types/relationship/views/index.tsx @@ -16,22 +16,21 @@ import { Text } from '@keystar/ui/typography' import { jsx, Stack, useTheme } from '@keystone-ui/core' import { FieldDescription, FieldLegend } from '@keystone-ui/fields' import { DrawerController } from '@keystone-ui/modals' -import { - type CellComponent, - type FieldController, - type FieldControllerConfig, - type FieldProps, - type ListMeta, +import type { + CellComponent, + FieldController, + FieldControllerConfig, + FieldProps, + ListMeta, } from '../../../../types' -import { useKeystone, useList } from '../../../../admin-ui/context' +import { useList } from '../../../../admin-ui/context' import { gql, useQuery } from '../../../../admin-ui/apollo' import { CellContainer, CreateItemDrawer } from '../../../../admin-ui/components' import { RelationshipSelect } from './RelationshipSelect' export function Field (props: FieldProps) { - const { field, value, itemValue, autoFocus, onChange, forceValidation } = props - const keystone = useKeystone() + const { field, value, autoFocus, onChange } = props const foreignList = useList(field.refListKey) const localList = useList(field.listKey) const [isDrawerOpen, setIsDrawerOpen] = useState(false) @@ -139,7 +138,7 @@ function ContextualActionsMenu (props: FieldProps) { const router = useRouter() const foreignList = useList(field.refListKey) const relatedItem = useRelatedItem(props) - + const items = useMemo(() => { let result = [] let allowCreate = !field.hideCreate && onChange !== undefined @@ -519,19 +518,20 @@ export function controller ( function useRelationshipFilterValues ({ value, list }: { value: string, list: ListMeta }) { const foreignIds = getForeignIds(value) - const where = { id: { in: foreignIds } } - const query = gql` + const { data, loading } = useQuery(gql` query FOREIGNLIST_QUERY($where: ${list.graphql.names.whereInputName}!) { items: ${list.graphql.names.listQueryName}(where: $where) { id ${list.labelField} } } - ` - - const { data, loading } = useQuery(query, { + `, { variables: { - where, + where: { + id: { + in: foreignIds + } + } }, })