Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
enhancement/breaking: update directive usage (#1202)
Browse files Browse the repository at this point in the history
* enhancement: update directive usage

* clippy

* rebase origin/develop

---------

Co-authored-by: Rashad Alston <[email protected]>
Co-authored-by: Rashad Alston <[email protected]>
  • Loading branch information
3 people authored Aug 7, 2023
1 parent b0f8aed commit 4504d91
Show file tree
Hide file tree
Showing 20 changed files with 409 additions and 386 deletions.
2 changes: 1 addition & 1 deletion docs/src/data-types/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Event {
The corresponding GraphQL schema to mirror this `Event` struct would resemble:

```graphql
type Event {
type Event @entity {
id: ID!
account: Address!
block_height: UInt8!
Expand Down
8 changes: 4 additions & 4 deletions docs/src/database/foreign-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Let's learn how to use each foreign key type by looking at some GraphQL schema e
### Implicit foreign keys

```graphql
type Book {
type Book @entity {
id: ID!
name: Bytes8!
}

type Library {
type Library @entity {
id: ID!
book: Book!
}
Expand All @@ -36,12 +36,12 @@ Given the above schema, two entities will be created: a `Book` entity, and a `Li
### Explicit foreign keys

```graphql
type Book {
type Book @entity {
id: ID!
name: Bytes8! @unique
}

type Library {
type Library @entity {
id: ID!
book: Book! @join(on:name)
}
Expand Down
16 changes: 8 additions & 8 deletions docs/src/graphql/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ As of this writing, the list of supported Fuel GraphQL schema directives include
The `@indexed` directive adds a [database index](https://www.postgresql.org/docs/current/indexes-intro.html) to the underlying column for the indicated field of that type. Generally, a database index is a data structure that allows you to quickly locate data without having to search each row in a database table.

```graphql
type Book {
type Book @entity {
id: ID!
name: Bytes8! @indexed
}

type Library {
type Library @entity {
id: ID!
book: Book!
}
Expand All @@ -34,12 +34,12 @@ In this example, a single `BTREE INDEX` constraint will be created on the `book`
The `@unique` directive adds a `UNIQUE` database constraint to the underlying database column for the indicated field of that type. A constraint specifies a rule for the data in a table and can be used to limit the type of data that can be placed in the table. In the case of a column with a `UNIQUE` constraint, all values in the column must be different.

```graphql
type Book {
type Book @entity {
id: ID!
name: Bytes8! @unique
}

type Library {
type Library @entity {
id: ID!
book: Book!
}
Expand All @@ -54,12 +54,12 @@ A `UNIQUE` constraint will be created on the `book` table's `name` column, ensur
The `@join` directive is used to relate a field in one type to others by referencing fields in another type. You can think of it as a link between two tables in your database. The field in the referenced type is called a _foreign key_ and it is **required** to be unique.

```graphql
type Book {
type Book @entity {
id: ID!
name: Charfield! @unique
}

type Library {
type Library @entity {
id: ID!
book: Book! @join(on:name)
}
Expand All @@ -72,11 +72,11 @@ A foreign key constraint will be created on `library.book` that references `book
The `@virtual` directive instructs the indexer's SQL schema builder to _not_ build SQL tables from types that include this directive on any field.

```graphql
type Title {
type Title @entity {
name: CharField! @virtual
}

type Book {
type Book @entity {
id: ID!
title: Title!
}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/project-components/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ The GraphQL schema is a required component of the Fuel indexer. When data is ind
In its most basic form, a Fuel indexer GraphQL schema should have a `schema` definition that contains a defined query root. The rest of the implementation is up to you. Here's an example of a well-formed schema:

```graphql
type FirstThing {
type FirstThing @entity {
id: ID!
value: UInt8!
}

type SecondThing {
type SecondThing @entity {
id: ID!
optional_value: UInt8
timestamp: Timestamp!
Expand Down
8 changes: 4 additions & 4 deletions docs/src/queries/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,24 @@ Essentially, it's the same as the basic query example with an added sub-block to
We'll start with the following example schema:

```graphql
type City {
type City @entity {
id: ID!
name: Charfield!
}

type Library {
type Library @entity {
id: ID!
name: Charfield!
city: City!
}

type Book {
type Book @entity {
id: ID!
title: Charfield!
library: Library!
}

type Character {
type Character @entity {
id: ID!
name: Charfield!
book: Book!
Expand Down
Loading

0 comments on commit 4504d91

Please sign in to comment.