### Subgraph migration thingies
We are now migrating from using ipfs.cat() to file data sources to parse ipfs data.
file data sources :- https://thegraph.com/docs/en/developing/creating-a-subgraph/#file-data-sources
## 1. How the schema will change post migration.
- Previously, the entities stored the data retrieved from ipfs hash in top-level fields.
- for example this is the court entity in Kleros-display-subgraph, pre and post migration. But now they will be nested in a `metadata` field
- Pre:-
```
type Court @entity {
id: String!
timesPerPeriod: [BigInt!]
hiddenVotes: Boolean
policy: String
summary: String
name: String
description: String
requiredSkills: String
}
```
- Post :-
```
type Court @entity {
id: String!
timesPerPeriod: [BigInt!]
hiddenVotes: Boolean
policy: String
summary: String
metadata: CourtMetadata
}
type CourtMetadata @entity{
id: ID!
name: String
description: String
requiredSkills: String
}
```
## 2. How the gql queries will change.
- In terms of gql queries, the desirable fields will now be nested in `metadata` field, for both gtcr-subgraph and kleros-display-subgraph
- Pre:-
```
courts{
id
timesPerPeriod
hiddenVotes
policy
summary
name
description
requiredSkills
}
```
- Post :-
```
courts{
id
timesPerPeriod
hiddenVotes
policy
summary
metadata{
id
name
description
requiredSkills
}
}
```
## 3. PR's to migrate
1. gtcr-subgraph:
- https://github.com/kleros/gtcr-subgraph/pull/29
- deployment : https://thegraph.com/studio/subgraph/legacy-curate-gnosis/
2. kleros-display-subgraph:
- https://github.com/kleros/kleros-display-subgraph/pull/9
- deployment :- https://thegraph.com/studio/subgraph/kleros-display-test/
## 4. Known Blockers
Currently some of the ipfs files are not being resolved.
This could be related to the ipfs issues that the graph team has been having for the past week now.
https://status.thegraph.com/incidents/5g10shkyj7k9
## 5. Some insights on the File data source
- The on-chain entities (entities created by regular event handlers, eg. Court) and file based entities (entities created by File based handlers, eg. CourtMetadata), are only linked by an id.
- When we create a fileDatasource to resolve ipfs hash, it takes the load off-chain, hence is asynchronous.
- It is not possible to have the ipfs data in top-level fields since that would require us to update the on-chain entities, which is not possible as file based handlers cannot access on-chain entities.
- If that's the case how is data stored in the `metadata` field?
- It's stored there async, before we create a data source , we put the id in the metadata field(`court.metadata = id`), later the filebased handler will use this id to create a Filebased entity. thus linking it to the Court entity which is on-chain
In regular handler :

Then in file based handler :

This is how the schema looks like to link these together

## Some other things


Feel free to reach me for more info regarding migration.
Adios Amigo