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

chore: update fuel-ui, remove beta-3 refs #24

Merged
merged 19 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
NEXT_PUBLIC_ALGOLIA_APP_ID=
NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY=
NEXT_PUBLIC_APP_URL=
NEXT_PUBLIC_WALLET_DOWNLOAD_URL=
NEXT_PUBLIC_STORYBOOK_URL=
NEXT_PUBLIC_PREVIEW=
NEXT_PUBLIC_URL=
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
*.js
*.html
dist
.eslintrc.js
.next
docs
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["plugin:@fuels/next"],
"rules": {
"import/no-unresolved": "off"
}
}
7 changes: 7 additions & 0 deletions .eslintrc.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["plugin:@fuels/next"],
"rules": {
"import/no-unresolved": "off",
"import/order": "off"
}
}
33 changes: 33 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,36 @@ jobs:
with:
doc-folder-path: 'docs'
src-folder-path: 'src'

lint-code:
name: Lint Code
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Run lint
run: |
npm install
npm run check:prod

lint-docs:
name: Lint Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
# RUN LINT CHECK
- name: Lint Check
run: |
npm install
npm run lint:docs:check


11 changes: 11 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Links

on:
deployment_status

jobs:
check-links:
uses: FuelLabs/github-actions/.github/workflows/next-links.yml@master
with:
status: ${{ github.event.deployment_status.state }}
preview-url: ${{ github.event.deployment_status.environment_url }}
5 changes: 5 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'default': true # Default state for all rules
'MD013': false # Disable rule for line length
'MD033': false # Disable rule banning inline HTML
'MD034': false # Disable rule banning bare urls
'MD025': { 'front_matter_title': '' } # Without this, the title and h1 are considered two h1s
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github
node_modules
package-lock.json
.next
docs
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@fuels/prettier-config"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Fuel GraphQL API Documentation

The Fuel GraphQL API allows you to query the Fuel blockchain for a wide range of on-chain data. It can be used to query transactions, balances, block information, and more. You can also use it to simulate and submit transactions on the Fuel network.
The Fuel GraphQL API allows you to query the Fuel blockchain for a wide range of on-chain data. It can be used to query transactions, balances, block information, and more. You can also use it to simulate and submit transactions on the Fuel network.
4 changes: 2 additions & 2 deletions docs/how-to-use-graphql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ category: How To Use GraphQL

# How To Use GraphQL

This section covers the fundamentals for how to use a GraphQL API.
This section covers the fundamentals for how to use a GraphQL API.

For further documentation and resources about GraphQL, check out the offical GraphQL Documenation at [graphql.org](https://graphql.org/).
For further documentation and resources about GraphQL, check out the offical GraphQL Documenation at [graphql.org](https://graphql.org/).
52 changes: 32 additions & 20 deletions docs/how-to-use-graphql/apis-explained.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,34 @@ category: How To Use GraphQL
---

# Schema & Type System

Unlike traditional REST APIs, GraphQL comes with a strong type system to describe your API. A GraphQL schema describes the data you can query using the API endpoint by defining a set of types and fields that are mapped to those types.

Read along to learn about various GraphQL types.

## Object Types

Object types in GraphQL describe an object with underlying fields that can be queried from your API endpoint.

As an example, an object type can be defined as shown below:

```graphql
type actors {
name: String!
appearsIn: [movie!]!
name: String!
appearsIn: [movie!]!
}
```

Here,`actors` is an object type and `name` and `appearsIn` are fields mapped to type `actors`.

## Scalar Types

>From The GraphQL Documentation:
> From The GraphQL Documentation:

In the example for object types above, field `name` is of type `String`. String in GraphQL is by default a scalar type. This means that it resolves to a definite value and cannot have further sub-fields while querying. Scalar types represent the leaves of a query.

GraphQL comes with a set of default scalar types out-of-the-box such as below:

- `Int`: A signed 32‐bit integer.
- `Float`: A signed double-precision floating-point value.
- `String`: A UTF‐8 character sequence.
Expand All @@ -37,12 +42,11 @@ Fields can also be of types that are not scalar by default, but resolve to scala

```graphql
{
hero {
name
appearsIn
}
hero {
name
appearsIn
}
}

```

This is because in the schema, `name` and `appearIn` do not have further queryable sub-fields as described below:
Expand All @@ -64,15 +68,16 @@ This is because in the schema, `name` and `appearIn` do not have further queryab

## Lists and Non-nulls

>From the GraphQL documentation:
> From the GraphQL documentation:

Object types, scalars, and enums are the only kinds of types you can define in GraphQL. But when you use the types in other parts of the schema, or in your query variable declarations, you can apply additional type modifiers that affect validation of those values.
Object types, scalars, and enums are the only kinds of types you can define in GraphQL. But when you use the types in other parts of the schema, or in your query variable declarations, you can apply additional type modifiers that affect validation of those values.

Let's look at an example:

```graphql
type Character {
name: String!
appearsIn: [Episode]!
name: String!
appearsIn: [Episode]!
}
```

Expand Down Expand Up @@ -122,7 +127,8 @@ myField: ['a', null, 'b'] // error
```

## Union types
When a query returns a union type, you can use `... on` to specify the query fields for a certain return type. These are also called inline fragments. For example, the `hero` query below returns a union type of either `Droid` or `Human`.

When a query returns a union type, you can use `... on` to specify the query fields for a certain return type. These are also called inline fragments. For example, the `hero` query below returns a union type of either `Droid` or `Human`.

```graphql
query HeroForEpisode($ep: Episode!) {
Expand All @@ -139,16 +145,20 @@ query HeroForEpisode($ep: Episode!) {
```

## Connections

Connections are a type of response used whenever you are expecting multiple results that may require pagination. Each query return type that ends in "Connection" will include the following return fields:

```graphql
pageInfo: PageInfo!
edges: [SomethingEdge!]!
nodes: [Something!]!
```
##### PageInfo

### PageInfo

`pageInfo` returns an object that includes information about the returned page of results:

`hasPreviousPage: Boolean!`
`hasPreviousPage: Boolean!`
Whether or not the result has a previous page.

`hasNextPage: Boolean!`
Expand All @@ -160,14 +170,16 @@ The starting cursor that identifies the first page.
`endCursor: String`
The end cursor that identifies the last page.

##### Edges
### Edges

`edges` returns an array of edge objects, which includes the cursor and first node for that page. You can use this data to help with pagination.

##### Nodes
### Nodes

`nodes` returns an array of whichever type you are expecting paginated results for.

`nodes` returns an array of whichever type you are expecting paginated results for.
### Arguments

##### Arguments
Each of these queries also accepts the following arguments:
`first: Int`
`after: String`
Expand All @@ -178,4 +190,4 @@ Each of these queries also accepts the following arguments:

`after` and `before` both accept a cursor, which you can use to request different pages. These are both optional arguments.

You can learn more about the connection model and pagination in the official GraphQL docs here: https://graphql.org/learn/pagination/
You can learn more about the connection model and pagination in the official GraphQL docs here: https://graphql.org/learn/pagination/
35 changes: 20 additions & 15 deletions docs/how-to-use-graphql/what-is-graphql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
title: What is GraphQL?
category: How To Use GraphQL
---

# What is GraphQL?

### HTTP and APIs Explained
## HTTP and APIs Explained

HTTP is a protocol, or a definite set of rules, for accessing resources on the web. Resources could mean anything from HTML files to data from a database, photos, text, and so on.

These resources are made available to us via an Application Programming Interface (API) and we make requests to these APIs via the HTTP protocol. It is the mechanism that allows developers to request resources.

Read more about HTTP methods, client-server architecture, and why you need APIs [here](https://www.freecodecamp.org/news/http-request-methods-explained/).

### How does GraphQL work?
## How does GraphQL work?

>Note: This section goes over how GraphQL works under the hood, but it is not necessary to know this as a developer building on Fuel. Schema definition, resolver logic, etc. are all written and maintained by the contributors at Fuel Labs.
> Note: This section goes over how GraphQL works under the hood, but it is not necessary to know this as a developer building on Fuel. Schema definition, resolver logic, etc. are all written and maintained by the contributors at Fuel Labs.

GraphQL is a query language and specification that describes how you can communicate with your API. GraphQL is not constrained by programming languages, backend frameworks, and databases. GraphQL uses the HTTP protocol under the hood, so you can map GraphQL operations back to simple `GET`, `POST`, `PUT`, or `DELETE` operations. You can view the GraphQL documentation here: https://graphql.org/.

Expand All @@ -24,42 +25,46 @@ For example, as an API developer you could define a type, `Car` and define the p

```graphql
type Car {
id: ID
color: String
year: Int
isNew: Boolean
id: ID
color: String
year: Int
isNew: Boolean
}
```
Fuel Labs created a GraphQL API endpoint for the Fuel Network, allowing developers to make complex queries for data on the blockchain. You can leverage these queries to populate a frontend application with details that your users might be interested in like the history of their transactions, their balance of a specific token, etc.

Fuel Labs created a GraphQL API endpoint for the Fuel Network, allowing developers to make complex queries for data on the blockchain. You can leverage these queries to populate a frontend application with details that your users might be interested in like the history of their transactions, their balance of a specific token, etc.

### GraphQL Queries

Queries in GraphQL allow you to read data. GraphQL lets you ask for specific data and returns exactly what you asked for. It also lets you request multiple resources in a single query instead of writing a separate 'GET' request for each resource as with REST APIs.

GraphQL also facilitates more complex queries and operations such as pagination, sort, filter, full-text search, and more.

Sample query:

```graphql
query Actor {
actor {
name {
appearIn
}
actor {
name {
appearIn
}
}
}

```

The above query gives you a response with the name of the actor along with the name of the movie(s) they appear in.

### GraphQL Mutations

Mutations in GraphQL are write operations that update the chain's state. In addition to being able to traverse objects and their fields, GraphQL gives developers the ability to pass arguments to fields in order to filter out responses. Every field and nested object can have its own set of arguments.
Mutations in GraphQL are write operations that update the chain's state. In addition to being able to traverse objects and their fields, GraphQL gives developers the ability to pass arguments to fields in order to filter out responses. Every field and nested object can have its own set of arguments.

Sample mutation:

```graphql
mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {
createReview(episode: $ep, review: $review) {
stars
commentary
}
}
```
```
14 changes: 3 additions & 11 deletions docs/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,14 @@ The Fuel GraphQL API allows you to query the Fuel blockchain for a wide range of

## Playground

The playground is an interactive and graphical IDE that includes a reference for queries, mutations, and types. It also provides query validation and context for the underlying GraphQL schema.
The playground is an interactive and graphical IDE that includes a reference for queries, mutations, and types. It also provides query validation and context for the underlying GraphQL schema.

You can test out the Fuel GraphQL API playground here:
You can test out the Fuel GraphQL API playground here:

Beta-4:
https://beta-4.fuel.network/playground

Beta-3: *(deprecated)*:
https://beta-3.fuel.network/playground

You can learn more about the differences between each network [here](https://fuellabs.github.io/fuel-docs/master/networks/networks.html).

## API Endpoints
## API Endpoint

Beta-4:
https://beta-4.fuel.network/graphql

Beta-3: *(deprecated)*:
https://beta-3.fuel.network/graphql
Loading