Unique directive now available

Unique directive now available

The Grafbase Database is deprecated. Use connectors to federate your existing data sources.

We're extremely happy to announce the release of the @unique directive.

You can now mark fields in your models as unique, preventing duplicate entries in your collections.

All that's needed to make this work is to provide the @unique directive inside of your @model definition:

type Post @model { slug: String! @unique body: String! }

If you try to use a value for a field that has been marked as unique, you'll get the following error:

{ "data": null, "errors": [ { "locations": [{ "column": 3, "line": 2 }], "message": "The value \"foo\" is already taken on field \"slug\"", "path": ["postCreate"] } ] }

Please note that unique fields are currently case sensitive.

  • We changed the format of IDs of data returned from your project. This means TodoList#123 will now be returned as todolist_123.
  • The Playground inside of your project dashboard has had some minor styling improvements.
  • Grafbase CLI 0.4.0 has been released to include all of the above. You'll want to delete the .grafbase folder if you have an existing database.

We'd love to hear your feedback and ideas, so join us on Discord.