directus / directus

The flexible backend for all your projects 🐰 Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.
https://directus.io
Other
28.32k stars 3.95k forks source link

Unable to query custom types in combination with built-in SDK types #21250

Open maxbec opened 10 months ago

maxbec commented 10 months ago

Describe the Bug

We are unable to deep-query the fields of a custom type collection which uses the built-in DirectusUser type.

Query-Code:

export const festivityQueryFields = [
  'id',
  {
    assignee: ['*'],
    calendar_events: ['*'],
  },
] satisfies Query<DirectusTypes, Festivities>['fields'];

export default async function getFestivities() {
  return await directusRequest({
    restCommand: readItems('festivities', {
      fields: festivityQueryFields,
    }),
    loggingStatement: 'Fetching Festivities',
  });

Screenshot 2024-01-30 at 15 58 11

Type:

import { DirectusUser } from '@directus/sdk';

export type Festivities = {
  assignee?: string | DirectusUser<DirectusTypes> | null;
  calendar_events: any[] | CalendarEvents[];
};

To Reproduce

Create a type and link a field with a built-in SDK collection. Then try to query this field with a M2M query.

Directus Version

latest

Hosting Strategy

Self-Hosted (Docker Image)

br41nslug commented 10 months ago

Likely either related or has the same root cause as https://github.com/directus/directus/issues/19815

maxbec commented 10 months ago

Adding a directus collection to the root schema helped and fixed the issue.

directus_files: object;