Skip to content

Commit 496a9f6

Browse files
stwinamejamesbayly
andauthored
Update subgraph migration doc with schema feature changes (#546)
* Update subgraph migration doc with schema feature changes * Update docs/indexer/build/graph-migration.md * Update docs/indexer/build/graph-migration.md --------- Co-authored-by: James Bayly <[email protected]>
1 parent 2072d8e commit 496a9f6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/indexer/build/graph-migration.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Firstly, use the SubQuery CLI tool to migrate an existing SubGraph by using the
4242
- Intialise a new SubQuery project in your chosen directory for the matching target chain
4343
- Copy over basic information like project name and other metadata
4444
- Enable ts strict mode to assist you in identifying potential issues when migrating your project.
45-
- Copy over the existing `schema.graphql` to save you time (you will need to edit this)
45+
- Migrate the `schema.graphql` to be compatible with SubQuery, there is a chance you will need to edit this after migration to fine-tune the migrated code.
4646
- Copy over the existing `project.ts` mapping to save you time (you will need to edit this)
4747

4848
An example of using this tool for the Graph Gravatar project is as follows
@@ -61,16 +61,15 @@ subql migrate -f ~/path/to/subgraph -o ~/path/to/output
6161

6262
Once this is done, follow along and complete the remaining steps:
6363

64-
1. Review and edit the copied `schema.graphql` and replace any `Bytes` and `BigDecimals`. [More info](#graphql-schema).
65-
2. Copy over relevant abi contracts to the `abis` directory and update the `project.manifest`. [More info](#manifest-file).
66-
3. Review and edit the copied data sources in the `project.ts` manifest, specifically the `handlers` (retain the same handler names). [More info](#manifest-file).
67-
4. Perform code generation using the `yarn codegen`, this will generate GraphQL entity types, and generate types from ABIs. [More info](#codegen).
68-
5. Copy over the `mappings` directory, and then go through one by one to migrate them across. The key differences:
64+
1. Review and edit the `schema.graphql`, it will remove any unsupported features and modify relations to work with SubQuery. You may need to change the field parameter in the `@derivedFrom` directive. [More info](#graphql-schema).
65+
2. Review and edit the copied data sources in the `project.ts` manifest, specifically the `handlers` (we suggest that you retain the same handler names). [More info](#manifest-file).
66+
3. Perform code generation using the `yarn codegen`, this will generate GraphQL entity types, and generate types from ABIs. [More info](#codegen).
67+
4. Copy over the `mappings` directory, and then go through one by one to migrate them across. The key differences:
6968
- Imports will need to be updated
7069
- Store operations are asynchronous, e.g. `<entityName>.load(id)` should be replaced by `await <entityName>.get(id)` and `<entityName>.save()` to `await <entityName>.save()` (note the `await`).
7170
- With strict mode, you must construct new entities with all the required properties. You may want to replace `new <entityName>(id)` with `<entityName>.create({ ... })`
7271
- [More info](#mapping).
73-
6. Test and update your clients to follow the GraphQL api differences and take advantage of additional features. [More info](#graphql-query-differences)
72+
5. Test and update your clients to follow the GraphQL api differences and take advantage of additional features. [More info](#graphql-query-differences)
7473

7574
### Differences in the GraphQL Schema
7675

@@ -80,8 +79,9 @@ Visit this [full documentation for `schema.graphql`](./graphql.md). **You can co
8079

8180
Notable differences include:
8281

83-
- SubQuery does not have support for `Bytes` (use `String` instead) and `BigDecimal` (use `Float` instead).
82+
- SubQuery does not have support for `Bytes` (use `String` instead), `BigDecimal` (use `Float` instead) and `Timestamp` (use `Date` instead).
8483
- SubQuery has the additional scalar types of `Float`, `Date`, and `JSON` (see [JSON type](./graphql.md#json-type)).
84+
- SubQuery does relations slightly differently and the `@derivedFrom` directive is needed in more cases.
8585
- Comments are added to SubQuery Project GraphQL files using hashes (`#`).
8686

8787
### Differences in the Manifest File

0 commit comments

Comments
 (0)