subgraphs > Cookbook > Safe Subgraph Code Generator

Safe Subgraph Code Generator

Reading time: 2 min

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.

Why integrate with Subgraph Uncrashable?

Link to this section
  • 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.

  • 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.

  • 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.

Key Features

  • 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.

  • 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.

  • Warning logs are recorded as logs indicating where there is a breach of subgraph logic to help patch the issue to ensure data accuracy.

Subgraph Uncrashable can be run as an optional flag using the Graph CLI codegen command.

graph codegen -u [options] [<subgraph-manifest>]

Visit the subgraph uncrashable documentation or watch this video tutorial to learn more and to get started with developing safer subgraphs.

Edit page

Previous
Replace a Contract and Keep its History With Grafting
Next
Substreams-powered subgraphs
Edit page