From e64f92b91c629d2da64bbb8fdd9fd3cae9a73003 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 30 Aug 2023 11:56:59 -0400 Subject: [PATCH] Fix doc tests --- docs/src/SUMMARY.md | 10 ++-- docs/src/database/index.md | 2 +- docs/src/database/types.md | 60 ------------------- .../starting-the-fuel-indexer.md | 1 + .../src/graphql/{queries => }/full-example.md | 0 docs/src/graphql/index.md | 6 +- docs/src/graphql/{queries => }/pagination.md | 0 .../graphql/{queries/index.md => queries.md} | 6 +- docs/src/graphql/relationships.md | 4 -- docs/src/graphql/scalars.md | 2 +- .../graphql/{queries => }/search-filtering.md | 0 docs/src/project-components/index.md | 2 +- docs/src/project-components/schema.md | 2 +- 13 files changed, 16 insertions(+), 79 deletions(-) delete mode 100644 docs/src/database/types.md rename docs/src/graphql/{queries => }/full-example.md (100%) rename docs/src/graphql/{queries => }/pagination.md (100%) rename docs/src/graphql/{queries/index.md => queries.md} (78%) rename docs/src/graphql/{queries => }/search-filtering.md (100%) diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 999ae4c92..77d67c718 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -37,10 +37,10 @@ - [Relationships](./graphql/relationships.md) - [API Server](./graphql/api-server.md) - [Playground](./graphql/playground.md) - - [Queries](./graphql/queries/index.md) - - [Search and Filtering](./graphql/queries/search-filtering.md) - - [Pagination](./graphql/queries/pagination.md) - - [A Full Example](./graphql/queries/full-example.md) + - [Basic Queries](./graphql/queries.md) + - [Search and Filtering](./graphql/search-filtering.md) + - [Pagination](./graphql/pagination.md) + - [A Full Example](./graphql/full-example.md) - [Storing Info in a Database](./database/index.md) - [forc index](./forc-index/index.md) - [new](./forc-index/new.md) @@ -57,7 +57,7 @@ - [start](./forc-postgres/start.md) - [stop](./forc-postgres/stop.md) - [drop](./forc-postgres/drop.md) -- [Authentication](./authentication/index.md) --> +- [Authentication](./authentication/index.md) # For Contributors diff --git a/docs/src/database/index.md b/docs/src/database/index.md index 07ed8ae0f..b4a2c5ab2 100644 --- a/docs/src/database/index.md +++ b/docs/src/database/index.md @@ -7,7 +7,7 @@ The Fuel indexer uses [PostgreSQL](https://github.com/docker-library/postgres/bl Below is a mapping of GraphQL schema types to their Sway and database equivalents. Note that an empty cell denotes that there is no direct equivalent for the type in the corresponding domain. | GraphQL Scalar | Sway Type | Postgres Type | ---- | --- | --- +--- | --- | --- | Address | `b256` | varchar(64) | | AssetId | `u8[32]` | varchar(64) | | Blob | `str[]` | varchar(10485760) | diff --git a/docs/src/database/types.md b/docs/src/database/types.md deleted file mode 100644 index 2dca9a3d3..000000000 --- a/docs/src/database/types.md +++ /dev/null @@ -1,60 +0,0 @@ -# Types - -Below is a mapping of GraphQL schema types to their Sway and database equivalents. - -| Sway Type | GraphQL Schema Type | Postgres Type | -|------|----------|----------| -| b256 | Address | varchar(64) | -| b256 | ContractId | varchar(64) | -| bool | Boolean | bool | -| i64 | Timestamp | timestamp | -| str[] | Blob | bytes | -| str[4] | Bytes4 | varchar(16) | -| str[8] | Bytes8 | varchar(64) | -| str[32] | Bytes32 | varchar(64) | -| str[32] | AssetId | varchar(64) | -| str[32] | MessageId | varchar(64) | -| str[32] | Salt | varchar(64) | -| u32 | UInt4 | integer | -| u64 | ID | bigint primary key | -| u64 | UInt8 | bigint | -| | Json | json | -| | Charfield | varchar(255) | -| | Blob | varchar(10485760) | - -## Example - -Let's define an `Event` struct in a Sway contract: - -```sway -struct Event { - id: u64, - address: Address, - block_height: u64, -} -``` - -The corresponding GraphQL schema to mirror this `Event` struct would resemble: - -```graphql -type Event @entity { - id: ID! - account: Address! - block_height: UInt8! -} -``` - -And finally, this GraphQL schema will generate the following Postgres schema: - -```text - Table "schema.event" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------------+-------------+-----------+----------+---------+----------+-------------+--------------+------------- - id | bigint | | not null | | plain | | | - block_height | bigint | | not null | | plain | | | - address | varchar(64) | | not null | | plain | | | - object | bytea | | not null | | extended | | | -Indexes: - "event_pkey" PRIMARY KEY, btree (id) -Access method: heap -``` diff --git a/docs/src/getting-started/starting-the-fuel-indexer.md b/docs/src/getting-started/starting-the-fuel-indexer.md index c467037c3..5be3d7150 100644 --- a/docs/src/getting-started/starting-the-fuel-indexer.md +++ b/docs/src/getting-started/starting-the-fuel-indexer.md @@ -17,6 +17,7 @@ The Fuel indexer service will connect to any Fuel node, which means you can run | Indexer Service Web API | localhost | 29987 | `--web-api-host` / `--web-api-port` | | ## Starting the Fuel indexer + ### Using CLI options ```text diff --git a/docs/src/graphql/queries/full-example.md b/docs/src/graphql/full-example.md similarity index 100% rename from docs/src/graphql/queries/full-example.md rename to docs/src/graphql/full-example.md diff --git a/docs/src/graphql/index.md b/docs/src/graphql/index.md index 640d43933..2a3a3e3b9 100644 --- a/docs/src/graphql/index.md +++ b/docs/src/graphql/index.md @@ -5,7 +5,7 @@ The Fuel indexer uses GraphQL to in order to allow users to query for indexed da - [Directives](./directives.md) - [GraphQL API Server](./api-server.md) - [Playground](./playground.md) -- [Queries](../queries/index.md) +- [Queries](./queries.md) ## Supported Functionality @@ -19,12 +19,12 @@ While we do our best to maintain compliance with the GraphQL specification and p | Functionality | Status | Notes | |------|----------|-------| -| Arguments | ✅ | [read the Search and Filtering section](../queries/search-filtering.md) | +| Arguments | ✅ | [read the Search and Filtering section](./search-filtering.md) | | Aliases | ✅ | | | Fragments | ✅ | inline fragments are currently not supported | | Introspection | ✅ | | | GraphQL Playground | ✅ | [read the Playground section](./playground.md) | -| Pagination | ✅ | [read the Pagination section](../queries/pagination.md) | +| Pagination | ✅ | [read the Pagination section](./pagination.md) | | Directives | 🚧 | [read the Directives section](./directives.md) | | List Types | 🚧 | | | Union Types | 🚧 | | diff --git a/docs/src/graphql/queries/pagination.md b/docs/src/graphql/pagination.md similarity index 100% rename from docs/src/graphql/queries/pagination.md rename to docs/src/graphql/pagination.md diff --git a/docs/src/graphql/queries/index.md b/docs/src/graphql/queries.md similarity index 78% rename from docs/src/graphql/queries/index.md rename to docs/src/graphql/queries.md index e9828c703..cd77d3db6 100644 --- a/docs/src/graphql/queries/index.md +++ b/docs/src/graphql/queries.md @@ -1,6 +1,6 @@ # Queries -Once data has been persisted into your storage backend, you can retrieve it by querying the [GraphQL API server](../graphql/api-server.md). By default, the API server can be reached at `http://localhost:29987/api/graph/:namespace/:identifier`, where `:namespace` and `:identifier` are the values for the respective fields in your indexer's manifest. If you've changed the `WEB_API_HOST` or `WEB_API_PORT` values of your configuration, then you'll need to adjust the URL accordingly. +Once data has been persisted into your storage backend, you can retrieve it by querying the [GraphQL API server](./api-server.md). By default, the API server can be reached at `http://localhost:29987/api/graph/:namespace/:identifier`, where `:namespace` and `:identifier` are the values for the respective fields in your indexer's manifest. If you've changed the `WEB_API_HOST` or `WEB_API_PORT` values of your configuration, then you'll need to adjust the URL accordingly. ## Basic Query @@ -63,7 +63,7 @@ We're requesting the ID, height, and timestamp for each block stored in the back ## Nested Query -The Fuel indexer supports [foreign keys](../database/foreign-keys.md) on entity types; thus, you can also ask for information about a referenced entity inside of your query. A nested query has the following general structure: +The Fuel indexer supports [foreign keys](./relationships.md) on entity types; thus, you can also ask for information about a referenced entity inside of your query. A nested query has the following general structure: ```graphql query { @@ -112,7 +112,7 @@ type Character @entity { } ``` -This schema uses implicit foreign keys to reference other entities; for more information on implicit and explicit foreign keys, please refer to the [Foreign Keys](../database/foreign-keys.md) section of the book. In this contrived example, we're storing information about characters that are found in books which are stored in libraries that can be found in cities. This will be the query that we use to retrieve the aforementioned data: +This schema uses implicit foreign keys to reference other entities; for more information on implicit and explicit foreign keys, please refer to the [Relationships](./relationships.md) section of the book. In this contrived example, we're storing information about characters that are found in books which are stored in libraries that can be found in cities. This will be the query that we use to retrieve the aforementioned data: ```graphql query { diff --git a/docs/src/graphql/relationships.md b/docs/src/graphql/relationships.md index 6298d8ec7..dba3efbd3 100644 --- a/docs/src/graphql/relationships.md +++ b/docs/src/graphql/relationships.md @@ -28,8 +28,6 @@ type Library @entity { } ``` -#### Implicit foreign keys - Given the above schema, two entities will be created: a `Book` entity, and a `Library` entity. As you can see, we add the `Book` entity as an attribute on the `Library` entity, thus conveying that we want a one-to-many or one-to-one relationship between `Library` and `Book`. This means that for a given `Library`, we may also fetch one or many `Book` entities. It also means that the column `library.book` will be an integer type that references `book.id`. ### Explicit foreign keys @@ -46,6 +44,4 @@ type Library @entity { } ``` -#### Explicit foreign keys - For the most part, this works the same way as implicit foreign key usage. However, as you can see, instead of implicitly using `book.id` as the reference column for our `Book` object, we're _explicitly_ specifying that we want `book.name` to serve as our foreign key. Also, please note that since we're using `book.name` in our foreign key constraint, that column is required to be unique (via the `@unique` directive). diff --git a/docs/src/graphql/scalars.md b/docs/src/graphql/scalars.md index d2ce0424b..d026af518 100644 --- a/docs/src/graphql/scalars.md +++ b/docs/src/graphql/scalars.md @@ -3,7 +3,7 @@ The Fuel indexer has a collection of GraphQL scalars that cover virtually any value type in use on the Fuel network. The following list contains each GraphQL scalar type along with its equivalent Rust type. | GraphQL Scalar | Rust Type | Notes | ---- | --- | --- +--- | --- | --- | Address | `u8[32]` | | AssetId | `u8[32]` | | Blob | `Vec` | Byte blob of arbitary size | diff --git a/docs/src/graphql/queries/search-filtering.md b/docs/src/graphql/search-filtering.md similarity index 100% rename from docs/src/graphql/queries/search-filtering.md rename to docs/src/graphql/search-filtering.md diff --git a/docs/src/project-components/index.md b/docs/src/project-components/index.md index ce5e0a2c2..2997f5712 100644 --- a/docs/src/project-components/index.md +++ b/docs/src/project-components/index.md @@ -12,7 +12,7 @@ We'll describe these three different implementations below. ### As tooling for compiling indexers -The Fuel indexer provides functionality to make it easy to build and compile abitrary indexers by using [`forc index`](../forc-index/index.md). For info on how to use indexer tooling to compile arbitrary indexers, check out our [Quickstart](../getting-started/quickstart.md) and [Hello World](../getting-started/hello-world.md) examples for a more in-depth exploration of how to compile indexers. +The Fuel indexer provides functionality to make it easy to build and compile abitrary indexers by using [`forc index`](../forc-index/index.md). For info on how to use indexer tooling to compile arbitrary indexers, check out our [Quickstart](../getting-started/quickstart.md) example for a more in-depth exploration of how to compile indexers. ### As a standalone service diff --git a/docs/src/project-components/schema.md b/docs/src/project-components/schema.md index ba3f1faa9..e8c00ab2a 100644 --- a/docs/src/project-components/schema.md +++ b/docs/src/project-components/schema.md @@ -18,7 +18,7 @@ type SecondThing @entity { ``` The types you see above (e.g., `ID`, `UInt8`, etc) are Fuel abstractions that were created to more seamlessly integrate with the Fuel VM and are not native to GraphQL. A deeper explanation on these -types can be found in [the Types section](../data-types/types.md). +types can be found in [the Types section](../database/index.md). > Important: It is up to developers to manage their own unique IDs for each type, meaning that a data structure's `ID` field needs to be manually generated prior to saving it to the database. This generation can be as simple or complex as you want in order to fit your particular situation; the only requirement is that the developer implement their own custom generation.