Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK] Expected response type of item query unequals SDK response type #20652

Open
sensedrive opened this issue Dec 6, 2023 · 0 comments · May be fixed by #22310
Open

[SDK] Expected response type of item query unequals SDK response type #20652

sensedrive opened this issue Dec 6, 2023 · 0 comments · May be fixed by #22310
Assignees

Comments

@sensedrive
Copy link
Contributor

Describe the Bug

I took the example of #19815 to describe the issue. Unless I have no information about, if this is expected behaviour of the SDK, I open this issue ...

To Reproduce

TS is complaining in line 24

const result: ExpectedResponse[] = await directus.request(

For me, queriing a field (in this case "related") of a reference should not respond with the type of the Relation, but with (in this case) "string | null".

Please close, if I am wrong ...

import { createDirectus, rest, readFiles, readItems } from "@directus/sdk";

interface ExpectedResponse {
    id: string;
    related: string | null
}

interface Example {
    id: string;
    related: string | Relational[] | null
}

interface Relational {
    id: number;
}

interface Schema {
    example: Example[];
    relational: Relational[]
}

const directus = createDirectus<Schema>("http://0.0.0.0:8055").with(rest());

const result: ExpectedResponse[] = await directus.request(
    readItems( 'example', {
        fields: ['id', 'related'],
    })
);

Directus Version

v10.7.2

Hosting Strategy

Self-Hosted (Docker Image)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

3 participants