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

fix: types for model API with compound unique and findOne #1318

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

jonbretman
Copy link
Member

This fixes the generation of the unique conditions interface for relationship fields.

As an example the following schema:

model Profile {
    fields {
        name Text
    }
}

model Follow {
    fields {
        from Profile
        to Profile
    }

    @unique([from, to])
}

Currently produces a unique conditions interface for Follow that looks like this. Both not grouping the from and to fields into one object, but also using the whole Profile model as the type.

export type FollowUniqueConditions = 
    | {from: Profile}
    | {to: Profile}
    | {id: string};

With this fix the unique conditions interface is now this, which correctly groups the fields and uses the id's rather than the whole model.

export type FollowUniqueConditions = 
    | {fromId: string, toId: string}
    | {id: string};

@jonbretman jonbretman requested a review from a team November 30, 2023 14:18
@jonbretman jonbretman merged commit 10a90c4 into main Nov 30, 2023
10 checks passed
@jonbretman jonbretman deleted the model-api-types-fix branch November 30, 2023 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant