The Grafbase Database is deprecated. Use connectors to federate your existing data sources.
Database models have the @unique
directive to set which fields are to be treated as unique but there's been no way to scope these to other fields in the model, until today.
You can now extend the @unique
directive to include additional fields to be used when checking for uniqueness.
type User @model {
name: String
provider: String! @unique(fields: ["providerAccountId"])
providerAccountId: String!
}
This also means that multiple User
entries can have entries with the same values for provider
and providerAccountId
but not used in more than one entry.
Grafbase will automatically generate a new GraphQL input type that can be used to query data by the combined unique fields:
query {
user(
by: {
providerAndProviderAccountId: {
provider: "github"
providerAccountId: "notrab"
}
}
) {
name
}
}
We'd love to hear your feedback and ideas, so join us on Discord.