Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ http {
rewrite ^/docs/([a-zA-Z][a-zA-Z])/cookbook/quick-start/$ $scheme://$http_host/docs/$1/quick-start/ permanent;
rewrite ^/docs/en/substreams/(?!index\.).+$ https://substreams.streamingfast.io permanent;
rewrite ^/docs/en/firehose/(?!index\.).+$ https://firehose.streamingfast.io permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/developer/assemblyscript-api/$ $scheme://$http_host/docs/$1/developing/graph-ts/api/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/developing/assemblyscript-api/$ $scheme://$http_host/docs/$1/developing/graph-ts/api/ permanent;

# Temporary redirects (302)
rewrite ^/docs/en/querying/graph-client/$ $scheme://$http_host/docs/en/querying/graph-client/README/ redirect;
rewrite ^/docs/en/developing/graph-ts/$ $scheme://$http_host/docs/en/developing/graph-ts/README/ redirect;

location / {
try_files $uri $uri.html $uri/index.html =404;
Expand Down
15 changes: 15 additions & 0 deletions website/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ export default withNextra({
destination: '/en/querying/graph-client/README/',
permanent: false,
},
{
source: '/en/developing/graph-ts/',
destination: '/en/developing/graph-ts/README/',
permanent: false,
},
{
source: '/en/developer/assemblyscript-api/',
destination: '/en/developing/graph-ts/api/',
permanent: true,
},
{
source: '/en/developing/assemblyscript-api/',
destination: '/en/developing/graph-ts/api/',
permanent: true,
},
Comment on lines +64 to +78
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for setting these up!

],
images: {
unoptimized: true,
Expand Down
52 changes: 52 additions & 0 deletions website/pages/en/developing/graph-ts/[[...slug]].mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { RemoteContent } from 'nextra/data'
import { buildDynamicMDX } from 'nextra/remote'
import { getPageMap } from '@/src/getPageMap'
import { remarkReplaceLinks } from '@/src/remarkReplaceLinks'
import { Mermaid } from 'nextra/components'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧜‍♀️

import { visit } from 'unist-util-visit'
import json from '@/remote-files/graph-ts.json'

export const getStaticPaths = () => ({
fallback: false,
paths: json.filePaths.map((filePath) => ({
params: {
slug: filePath.replace(/\.mdx?/, '').split('/'),
},
})),
})

export async function getStaticProps({ params }) {
const { filePaths, user, repo, branch, docsPath } = json
const paths = params?.slug?.join('/')
const foundPath = filePaths.find((filePath) => filePath.startsWith(paths))
const baseURL = `https://raw.githubusercontent.com/${user}/${repo}/${branch}/${docsPath}${foundPath}`
const response = await fetch(baseURL)
const content = await response.text()
const mdx = await buildDynamicMDX(content, {
mdxOptions: {
format: 'md',
remarkPlugins: [
() => (tree, _file, done) => {
visit(tree, 'link', (node) => {
if (node.url.startsWith('../')) {
node.url = node.url.replace('../', `https://github.com/${user}/${repo}/tree/${branch}/`)
}
})
done()
},
[remarkReplaceLinks, { foundPath, basePath: '/developing/graph-ts/' }],
],
},
codeHighlight: false,
})
return {
props: {
...mdx,
__nextra_pageMap: await getPageMap('en'),
hideLocaleSwitcher: true,
remoteFilePath: `https://github.com/${user}/${repo}/tree/${branch}/${docsPath}${foundPath}`,
},
}
}

<RemoteContent components={{ Mermaid }} />
10 changes: 10 additions & 0 deletions website/pages/en/developing/graph-ts/_meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createCatchAllMeta } from 'nextra/catch-all'

import json from '../../../../remote-files/graph-ts.json' assert { type: 'json' }

export default () =>
createCatchAllMeta(json.filePaths, {
README: 'Introduction',
api: 'API Reference',
'common-issues': 'Common Issues',
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ This page documents what built-in APIs can be used when writing subgraph mapping

It is also possible to add other libraries as dependencies, as long as they are compatible with [AssemblyScript](https://github.com/AssemblyScript/assemblyscript). Since this is the language mappings are written in, the [AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) is a good source for language and standard library features.

## Installation

Subgraphs created with [`graph init`](/developing/creating-a-subgraph) come with preconfigured dependencies. All that is required to install these dependencies is to run one of the following commands:

```sh
yarn install # Yarn
npm install # NPM
```

If the subgraph was created from scratch, one of the following two commands will install the Graph TypeScript library as a dependency:

```sh
yarn add --dev @graphprotocol/graph-ts # Yarn
npm install --save-dev @graphprotocol/graph-ts # NPM
```

## API Reference

The `@graphprotocol/graph-ts` library provides the following APIs:
Expand Down Expand Up @@ -862,10 +846,3 @@ dataSources:
- `BigInt`: Specifies a large integer value. Must be quoted due to its large size.

This context is then accessible in your subgraph mapping files, enabling more dynamic and configurable subgraphs.

### Common AssemblyScript Issues

There are certain [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) issues that are common to run into during subgraph development. They range in debug difficulty, however, being aware of them may help. The following is a non-exhaustive list of these issues:

- `Private` class variables are not enforced in [AssembyScript](https://www.assemblyscript.org/status.html#language-features). There is no way to protect class variables from being directly changed from the class object.
- Scope is not inherited into [closure functions](https://www.assemblyscript.org/status.html#on-closures), i.e. variables declared outside of closure functions cannot be used. Explanation in [Developer Highlights #3](https://www.youtube.com/watch?v=1-8AW-lVfrA&t=3243s).
8 changes: 8 additions & 0 deletions website/pages/en/developing/graph-ts/common-issues.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Common AssemblyScript Issues
---

There are certain [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) issues that are common to run into during subgraph development. They range in debug difficulty, however, being aware of them may help. The following is a non-exhaustive list of these issues:

- `Private` class variables are not enforced in [AssembyScript](https://www.assemblyscript.org/status.html#language-features). There is no way to protect class variables from being directly changed from the class object.
- Scope is not inherited into [closure functions](https://www.assemblyscript.org/status.html#on-closures), i.e. variables declared outside of closure functions cannot be used. Explanation in [Developer Highlights #3](https://www.youtube.com/watch?v=1-8AW-lVfrA&t=3243s).
4 changes: 3 additions & 1 deletion website/remote-files/firehose.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"references/indexing.md",
"references/naming-conventions.md",
"references/protobuf-schemas.md",
"references/repositories.md"
"references/repositories.md",
"release-notes/change-logs/README.md",
"release-notes/change-logs/nov-8th-2023-polygon-update.md"
]
}
10 changes: 10 additions & 0 deletions website/remote-files/graph-ts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"user": "graphprotocol",
"repo": "graph-tooling",
"branch": "main",
"docsPath": "packages/ts/",
"filePaths": [
"CHANGELOG.md",
"README.md"
]
}
8 changes: 7 additions & 1 deletion website/route-lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,15 @@
/en/deploying/hosted-service/
/en/deploying/subgraph-studio-faqs/
/en/deploying/subgraph-studio/
/en/developing/assemblyscript-api/
/en/developer/assemblyscript-api/ -> /en/developing/graph-ts/api/
/en/developing/assemblyscript-api/ -> /en/developing/graph-ts/api/
/en/developing/creating-a-subgraph/
/en/developing/developer-faqs/
/en/developing/graph-ts/ -> /en/developing/graph-ts/README/
/en/developing/graph-ts/CHANGELOG/
/en/developing/graph-ts/README/
/en/developing/graph-ts/api/
/en/developing/graph-ts/common-issues/
/en/developing/substreams-powered-subgraphs-faq/
/en/developing/supported-networks/
/en/developing/unit-testing-framework/
Expand Down
8 changes: 8 additions & 0 deletions website/scripts/fetch-remote-filepaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ await fetchRemoteFilePaths({
docsPath: 'docs/',
outputPath: path.join(process.cwd(), 'remote-files', 'graph-client.json'),
})

await fetchRemoteFilePaths({
user: 'graphprotocol',
repo: 'graph-tooling',
branch: 'main',
docsPath: 'packages/ts/',
outputPath: path.join(process.cwd(), 'remote-files', 'graph-ts.json'),
})