Skip to content

Commit a81d6b4

Browse files
SvenMuller95MJYoung114evaporeiWeb3Slimchance
authored
Section safe subgraph generation tool (#249)
* Section safe subgraph generation tool Subgraph Uncrashable is a codegen tool that makes loading and interacting with entities atomic, safe and consistent. Wave 6 successful Grantee contribution (Safe Subgraph Code Generator - Float - $50,000), as part of project closure, it was agreed to push a summary of the tool to the thegraph/com docs. codegen section of the docs seemed most applicable. * grammar correction Co-authored-by: MJYoung114 <[email protected]> * grammar correction Co-authored-by: MJYoung114 <[email protected]> * grammer correction Co-authored-by: Eva Pace <[email protected]> * grammer corrections Co-authored-by: Eva Pace <[email protected]> * grammar corrections Co-authored-by: Eva Pace <[email protected]> * Update creating-a-subgraph.mdx Formatted for better readability Fixed typos * Update navigation.ts Moving Subgraph Uncrashable to its own page in cookbook * Moving Subgraph Uncrashable to its own page in cookbook Moving Subgraph Uncrashable to its own page in cookbook * Moving Subgraph Uncrashable to its own page in cookbook Moving Subgraph Uncrashable to its own page in cookbook --------- Co-authored-by: MJYoung114 <[email protected]> Co-authored-by: Eva Pace <[email protected]> Co-authored-by: Web3Slimchance <[email protected]>
1 parent 00eda6d commit a81d6b4

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

navigation/navigation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ export const navigation = (locale: AppLocale): NavItemDefinition[] => [
178178
{
179179
slug: 'grafting',
180180
},
181+
{
182+
slug: 'subgraph-uncrashable',
183+
},
181184
],
182185
},
183186
{
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Subgraph Uncrashable - a Safe Subgraph Code Generator
3+
---
4+
5+
[Subgraph Uncrashable](https://float-capital.github.io/float-subgraph-uncrashable/) is a code generation tool that generates a set of helper functions from the graphql schema of a project. It ensures that all interactions with entities in your subgraph are completely safe and consistent.
6+
7+
8+
### Why integrate with Subgraph Uncrashable?
9+
10+
- **Continuous Uptime**. Mishandled entities may cause subgraphs to crash, which can be disruptive for projects that are dependent on The Graph. Set up helper functions to make your subgraphs “uncrashable” and ensure business continuity.
11+
12+
- **Completely Safe**. Common problems seen in subgraph development are issues of loading undefined entities, not setting or initializing all values of entities, and race conditions on loading and saving entities. Ensure all interactions with entities are completely atomic.
13+
14+
- **User Configurable** Set default values and configure the level of security checks that suits your individual project's needs. Warning logs are recorded indicating where there is a breach of subgraph logic to help patch the issue to ensure data accuracy.
15+
16+
<br>
17+
18+
**Key Features**
19+
20+
- The code generation tool accommodates **all** subgraph types and is configurable for users to set sane defaults on values. The code generation will use this config to generate helper functions that are to the users specification.
21+
22+
- The framework also includes a way (via the config file) to create custom, but safe, setter functions for groups of entity variables. This way it is impossible for the user to load/use a stale graph entity and it is also impossible to forget to save or set a variable that is required by the function.
23+
24+
- Warning logs are recorded as logs indicating where there is a breach of subgraph logic to help patch the issue to ensure data accuracy. These logs can be viewed in the The Graph's hosted service under the 'Logs' section.
25+
26+
<br>
27+
28+
Subgraph Uncrashable can be run as an optional flag using the Graph CLI codegen command.
29+
30+
```sh
31+
graph codegen -u [options] [<subgraph-manifest>]
32+
```
33+
34+
Visit the [subgraph uncrashable documentation](https://float-capital.github.io/float-subgraph-uncrashable/docs/) or watch this [video tutorial](https://float-capital.github.io/float-subgraph-uncrashable/docs/tutorial) to learn more and to get started with developing safer subgraphs.

pages/en/developing/creating-a-subgraph.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ import { Gravatar } from '../generated/schema'
562562
563563
Code generation does not check your mapping code in `src/mapping.ts`. If you want to check that before trying to deploy your subgraph to the Graph Explorer, you can run `yarn build` and fix any syntax errors that the TypeScript compiler might find.
564564

565+
565566
## Data Source Templates
566567

567568
A common pattern in Ethereum smart contracts is the use of registry or factory contracts, where one contract creates, manages, or references an arbitrary number of other contracts that each have their own state and events. The addresses of these sub-contracts may or may not be known upfront and many of these contracts may be created and/or added over time. This is why, in such cases, defining a single data source or a fixed number of data sources is impossible and a more dynamic approach is needed: _data source templates_.

0 commit comments

Comments
 (0)