# GIP: File data sources

**URL:** <https://forum.thegraph.com/t/gip-file-data-sources/2721>\
**Category:** Graph Improvement Proposals (GIP)\
**Created:** [November 10, 2021, 2:56pm UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721 "2021-11-10T14:56:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamfuller](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@adamfuller](https://forum.thegraph.com/u/adamfuller)\
**Post date:** [November 10, 2021, 2:56pm UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721/1 "2021-11-10T14:56:03Z")

</div>

device: rad:git:hnrkrhnth6afcc6mnmtokbp4h9575fgrhzbay  
branch: adam/drafts

Preview: [File data sources in Graph Node - HackMD](https://hackmd.io/opoO7onKRR-2GwI3zHnNFg?view)

cc @Leo @That3Percent

# Abstract

The current mapping API for IPFS makes the overall indexing output depend on whether or not the index node was able to find a file at the moment ipfs.cat was called. This is not deterministic and therefore not acceptable for the decentralized network. It also is not performant or reliable, as handler processing waits for the file to be found before proceeding. Finally, it creates a data-dependency between the data sourced from the chain, and the data sourced from IPFS, which means any change in file availability would require a full subgraph re-indexing from the block the file was first required.

The proposed solution consists of:

- An **Availability Chain** , which tracks the availability over time of files referenced by Subgraphs.
- Dynamic **“file” data sources** which correspond to content-addressed data (e.g. from IPFS). These are created by blockchain-based data sources, and will respect the availability definition of the Availability Chain. They are isolated, both in terms of being processed asynchronously from the main chain-based process, and in updating a discrete set of entities.

This GIP describes the implementation of file data sources in Graph Node, starting with IPFS as the first type of file data source.

_The planning for the first phase of implemenation (File data sources in Graph Node, without an availability chain) is in progress._

---

<div class="post-metadata">

**Author:** ![schmidsi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/schmidsi/32/592_2.png) [@schmidsi](https://forum.thegraph.com/u/schmidsi)\
**Post date:** [June 14, 2022, 10:55pm UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721/2 "2022-06-14T22:55:40Z")

</div>

One use-case that recently came to my attention is the usage of [IPNS](https://docs.ipfs.io/concepts/ipns/#example-ipns-setup-with-cli): A developer might want to define a file data source pointing to an IPNS address (`file/ipns`), either directly in the subgraph manifest or by instantiate a template after observing an on-chain event. The difference between a IPNS and IPFS hash is that the IPNS content can change.

In order to support such changing data, graph-node needs to be able to know when such a file was changed (basically the IPNS reference changed) and run some logic accordingly. A very naive approach that might be good enough would be to just rerun the handler with the new content (e.g. `handleFile`).

What I do not know at the moment is how to know when such a IPNS pointer changes. Maybe there are some features in IPFS-nodes to listen to those events?

---

<div class="post-metadata">

**Author:** ![adamfuller](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@adamfuller](https://forum.thegraph.com/u/adamfuller)\
**Post date:** [June 15, 2022, 8:33am UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721/3 "2022-06-15T08:33:54Z")

</div>

Thanks @schmidsi - that is an interesting extension. I am not sure that there is an easy way to listen for updates to IPNS pointers across peers, so I expect that the required approach for freshness would be similar to an HTTP endpoint (i.e. polling, or updates triggered somehow). I am also not sure how IPNS names are stored / pinned, and how they propagate (i.e. is it associated with one node, or is there some other registry)?

---

<div class="post-metadata">

**Author:** ![BrainFried](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/brainfried/32/1627_2.png) [@BrainFried](https://forum.thegraph.com/u/BrainFried)\
**Post date:** [October 11, 2022, 5:59pm UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721/4 "2022-10-11T17:59:20Z")

</div>

Is there any update on this that I can follow? Thank you

---

<div class="post-metadata">

**Author:** ![Ethan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/ethan/32/2512_2.png) [@Ethan](https://forum.thegraph.com/u/Ethan)\
**Post date:** [October 13, 2022, 4:34am UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721/5 "2022-10-13T04:34:42Z")

</div>

@BrainFried

Adam gave an update in core devs call #16.

> [@The Graph Core Devs Call #16](https://forum.thegraph.com/t/the-graph-core-devs-call-16/3597/2):
>
> Summary In The Graph’s Core Devs Call #16 we receive a brief update on the MIPs program, listen to progress on File Data Sources and Subgraph Data Pruning, discuss an alternative to GIP-0034 and review upcoming changes to curation on L2. Topics Include: Migration Infrastructure Providers Program Update File Data Sources Update Subgraph Data Pruning Updates on L2 and GIP-0037 Current State of Curation v1.x and Roadmap to 2.0 Detailed notes regarding …

Core Devs #16 - 6:28 (time stamp)

---

<div class="post-metadata">

**Author:** ![nicog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/nicog/32/1734_2.png) [@nicog](https://forum.thegraph.com/u/nicog)\
**Post date:** [December 24, 2022, 4:36pm UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721/6 "2022-12-24T16:36:21Z")

</div>

Hello. Any updates on the possibility to use different File Data Sources in the Graph Node? My particular case is to use **IPNS** within my smart contract so I would like to know if it is on the roadmap and how is the proper way to start implementing it and indexing it. Thank you for your support.

Cheers!

---

<div class="post-metadata">

**Author:** ![Leo](https://avatars.discourse-cdn.com/v4/letter/l/c2a13f/32.png) [@Leo](https://forum.thegraph.com/u/Leo)\
**Post date:** [January 3, 2023, 11:09pm UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721/7 "2023-01-03T23:09:07Z")

</div>

Hi @nicog, IPNS support is a planned extension to file data sources, but it will not be included on the first release of the feature.

---

<div class="post-metadata">

**Author:** ![adamfuller](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@adamfuller](https://forum.thegraph.com/u/adamfuller)\
**Post date:** [March 1, 2023, 10:39am UTC](https://forum.thegraph.com/t/gip-file-data-sources/2721/8 "2023-03-01T10:39:09Z")

</div>

File data sources support for IPFS has been added to Graph Node, and will be included in the next release (v0.30.0)
