Skip to content

Commit ac22e36

Browse files
authored
feat: graph-ts docs (graphprotocol#549)
* feat: integrate graph-ts docs * restrcuture * redirects * lockfile * copy change
1 parent 2626590 commit ac22e36

File tree

11 files changed

+117
-26
lines changed

11 files changed

+117
-26
lines changed

nginx.conf

+3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ http {
9090
rewrite ^/docs/([a-zA-Z][a-zA-Z])/cookbook/quick-start/$ $scheme://$http_host/docs/$1/quick-start/ permanent;
9191
rewrite ^/docs/en/substreams/(?!index\.).+$ https://substreams.streamingfast.io permanent;
9292
rewrite ^/docs/en/firehose/(?!index\.).+$ https://firehose.streamingfast.io permanent;
93+
rewrite ^/docs/([a-zA-Z][a-zA-Z])/developer/assemblyscript-api/$ $scheme://$http_host/docs/$1/developing/graph-ts/api/ permanent;
94+
rewrite ^/docs/([a-zA-Z][a-zA-Z])/developing/assemblyscript-api/$ $scheme://$http_host/docs/$1/developing/graph-ts/api/ permanent;
9395

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

97100
location / {
98101
try_files $uri $uri.html $uri/index.html =404;

website/next.config.js

+15
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ export default withNextra({
6161
destination: '/en/querying/graph-client/README/',
6262
permanent: false,
6363
},
64+
{
65+
source: '/en/developing/graph-ts/',
66+
destination: '/en/developing/graph-ts/README/',
67+
permanent: false,
68+
},
69+
{
70+
source: '/en/developer/assemblyscript-api/',
71+
destination: '/en/developing/graph-ts/api/',
72+
permanent: true,
73+
},
74+
{
75+
source: '/en/developing/assemblyscript-api/',
76+
destination: '/en/developing/graph-ts/api/',
77+
permanent: true,
78+
},
6479
],
6580
images: {
6681
unoptimized: true,

website/pages/en/developing/_meta.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default {
22
'supported-networks': '',
33
'creating-a-subgraph': '',
4-
'assemblyscript-api': '',
4+
'graph-ts': 'AssemblyScript API',
55
'unit-testing-framework': '',
66
'developer-faqs': '',
77
'substreams-powered-subgraphs-faq': '',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { RemoteContent } from 'nextra/data'
2+
import { buildDynamicMDX } from 'nextra/remote'
3+
import { getPageMap } from '@/src/getPageMap'
4+
import { remarkReplaceLinks } from '@/src/remarkReplaceLinks'
5+
import { Mermaid } from 'nextra/components'
6+
import { visit } from 'unist-util-visit'
7+
import json from '@/remote-files/graph-ts.json'
8+
9+
export const getStaticPaths = () => ({
10+
fallback: false,
11+
paths: json.filePaths.map((filePath) => ({
12+
params: {
13+
slug: filePath.replace(/\.mdx?/, '').split('/'),
14+
},
15+
})),
16+
})
17+
18+
export async function getStaticProps({ params }) {
19+
const { filePaths, user, repo, branch, docsPath } = json
20+
const paths = params?.slug?.join('/')
21+
const foundPath = filePaths.find((filePath) => filePath.startsWith(paths))
22+
const baseURL = `https://raw.githubusercontent.com/${user}/${repo}/${branch}/${docsPath}${foundPath}`
23+
const response = await fetch(baseURL)
24+
const content = await response.text()
25+
const mdx = await buildDynamicMDX(content, {
26+
mdxOptions: {
27+
format: 'md',
28+
remarkPlugins: [
29+
() => (tree, _file, done) => {
30+
visit(tree, 'link', (node) => {
31+
if (node.url.startsWith('../')) {
32+
node.url = node.url.replace('../', `https://github.com/${user}/${repo}/tree/${branch}/`)
33+
}
34+
})
35+
done()
36+
},
37+
[remarkReplaceLinks, { foundPath, basePath: '/developing/graph-ts/' }],
38+
],
39+
},
40+
codeHighlight: false,
41+
})
42+
return {
43+
props: {
44+
...mdx,
45+
__nextra_pageMap: await getPageMap('en'),
46+
hideLocaleSwitcher: true,
47+
remoteFilePath: `https://github.com/${user}/${repo}/tree/${branch}/${docsPath}${foundPath}`,
48+
},
49+
}
50+
}
51+
52+
<RemoteContent components={{ Mermaid }} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createCatchAllMeta } from 'nextra/catch-all'
2+
3+
import json from '../../../../remote-files/graph-ts.json' assert { type: 'json' }
4+
5+
export default () =>
6+
createCatchAllMeta(json.filePaths, {
7+
README: 'Introduction',
8+
api: 'API Reference',
9+
'common-issues': 'Common Issues',
10+
})

website/pages/en/developing/assemblyscript-api.mdx renamed to website/pages/en/developing/graph-ts/api.mdx

-23
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@ This page documents what built-in APIs can be used when writing subgraph mapping
1111

1212
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.
1313

14-
## Installation
15-
16-
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:
17-
18-
```sh
19-
yarn install # Yarn
20-
npm install # NPM
21-
```
22-
23-
If the subgraph was created from scratch, one of the following two commands will install the Graph TypeScript library as a dependency:
24-
25-
```sh
26-
yarn add --dev @graphprotocol/graph-ts # Yarn
27-
npm install --save-dev @graphprotocol/graph-ts # NPM
28-
```
29-
3014
## API Reference
3115

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

864848
This context is then accessible in your subgraph mapping files, enabling more dynamic and configurable subgraphs.
865-
866-
### Common AssemblyScript Issues
867-
868-
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:
869-
870-
- `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.
871-
- 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).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Common AssemblyScript Issues
3+
---
4+
5+
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:
6+
7+
- `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.
8+
- 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).

website/remote-files/firehose.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"references/indexing.md",
3636
"references/naming-conventions.md",
3737
"references/protobuf-schemas.md",
38-
"references/repositories.md"
38+
"references/repositories.md",
39+
"release-notes/change-logs/README.md",
40+
"release-notes/change-logs/nov-8th-2023-polygon-update.md"
3941
]
4042
}

website/remote-files/graph-ts.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"user": "graphprotocol",
3+
"repo": "graph-tooling",
4+
"branch": "main",
5+
"docsPath": "packages/ts/",
6+
"filePaths": [
7+
"CHANGELOG.md",
8+
"README.md"
9+
]
10+
}

website/route-lockfile.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,15 @@
184184
/en/deploying/hosted-service/
185185
/en/deploying/subgraph-studio-faqs/
186186
/en/deploying/subgraph-studio/
187-
/en/developing/assemblyscript-api/
187+
/en/developer/assemblyscript-api/ -> /en/developing/graph-ts/api/
188+
/en/developing/assemblyscript-api/ -> /en/developing/graph-ts/api/
188189
/en/developing/creating-a-subgraph/
189190
/en/developing/developer-faqs/
191+
/en/developing/graph-ts/ -> /en/developing/graph-ts/README/
192+
/en/developing/graph-ts/CHANGELOG/
193+
/en/developing/graph-ts/README/
194+
/en/developing/graph-ts/api/
195+
/en/developing/graph-ts/common-issues/
190196
/en/developing/substreams-powered-subgraphs-faq/
191197
/en/developing/supported-networks/
192198
/en/developing/unit-testing-framework/

website/scripts/fetch-remote-filepaths.ts

+8
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,11 @@ await fetchRemoteFilePaths({
8686
docsPath: 'docs/',
8787
outputPath: path.join(process.cwd(), 'remote-files', 'graph-client.json'),
8888
})
89+
90+
await fetchRemoteFilePaths({
91+
user: 'graphprotocol',
92+
repo: 'graph-tooling',
93+
branch: 'main',
94+
docsPath: 'packages/ts/',
95+
outputPath: path.join(process.cwd(), 'remote-files', 'graph-ts.json'),
96+
})

0 commit comments

Comments
 (0)