Skip to content

Commit

Permalink
fix: workaround query type issues if entity is named Metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmardefago committed Jan 31, 2024
1 parent 9229a49 commit 85034c1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
22 changes: 11 additions & 11 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ type GraphAccount @entity {
"Default display name is the current default name. Used for filtered queries in the explorer"
defaultDisplayName: String

# IPFS Metadata.
metadata: GraphAccountMetadata
# IPFS Meta.
metadata: GraphAccountMeta

# Operator info
"Operator of other Graph Accounts"
Expand Down Expand Up @@ -297,7 +297,7 @@ type GraphAccount @entity {
tokenLockWallets: [TokenLockWallet!]!
}

type GraphAccountMetadata @entity(immutable:true) {
type GraphAccountMeta @entity(immutable:true) {
"IPFS hash with account metadata details"
id: ID!
"Account that reference this metadata file. For compatibility purposes. For the full list use graphAccounts"
Expand Down Expand Up @@ -429,17 +429,17 @@ type Subgraph @entity {
"Total amount of NameSignal entities"
nameSignalCount: Int!

# Metadata from IPFS linked in GNS
# Meta from IPFS linked in GNS
"Subgraph metadata"
metadataHash: Bytes
"Subgraph metadata ipfs hash and entity"
metadata: SubgraphMetadata
metadata: SubgraphMeta

# Auxiliary fields
currentVersionRelationEntity: CurrentSubgraphDeploymentRelation
}

type SubgraphMetadata @entity(immutable:true) {
type SubgraphMeta @entity(immutable:true) {
"Subgraph metadata ipfs hash"
id: ID!
"Subgraph that reference this metadata. For compatibility purposes. For the full list use subgraphs"
Expand Down Expand Up @@ -496,15 +496,15 @@ type SubgraphVersion @entity {
createdAt: Int!

metadataHash: Bytes
# Metadata from IPFS linked in GNS
metadata: SubgraphVersionMetadata
# Meta from IPFS linked in GNS
metadata: SubgraphVersionMeta

entityVersion: Int!
"[DEPRECATED] Used for duplicate entities to enable old IDs from before the subgraph NFT update"
linkedEntity: SubgraphVersion
}

type SubgraphVersionMetadata @entity(immutable:true) {
type SubgraphVersionMeta @entity(immutable:true) {
"Subgraph version metadata ipfs hash"
id: ID!
"SubgraphVersion entity that references this metadata. For compatibility purposes. For the full list use subgraphVersions"
Expand Down Expand Up @@ -650,7 +650,7 @@ type SubgraphDeploymentManifest @entity(immutable:true) {
# }

"""
Metadata for the Indexer along with parameters and staking data
Meta for the Indexer along with parameters and staking data
"""
type Indexer @entity {
"Eth address of Indexer"
Expand Down Expand Up @@ -1448,7 +1448,7 @@ type _Schema_
name: "subgraphMetadataSearch"
language: en
algorithm: rank
include: [{ entity: "SubgraphMetadata", fields: [{ name: "displayName" }, { name: "description" }] }]
include: [{ entity: "SubgraphMeta", fields: [{ name: "displayName" }, { name: "description" }] }]
)
@fulltext(
name: "curatorSearch"
Expand Down
12 changes: 6 additions & 6 deletions src/mappings/ipfs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { json, Bytes, dataSource, JSONValueKind, log, DataSourceContext } from '@graphprotocol/graph-ts'
import {
SubgraphMetadata,
SubgraphVersionMetadata,
GraphAccountMetadata,
SubgraphMeta,
SubgraphVersionMeta,
GraphAccountMeta,
SubgraphDeploymentSchema,
SubgraphDeploymentManifest,
} from '../types/schema'
Expand All @@ -13,7 +13,7 @@ import { jsonToString } from './utils'

export function handleSubgraphMetadata(content: Bytes): void {
let id = dataSource.context().getString("id")
let subgraphMetadata = new SubgraphMetadata(id)
let subgraphMetadata = new SubgraphMeta(id)
let tryData = json.try_fromBytes(content)
if (tryData.isOk) {
let data = tryData.value.toObject()
Expand Down Expand Up @@ -41,7 +41,7 @@ export function handleSubgraphMetadata(content: Bytes): void {

export function handleSubgraphVersionMetadata(content: Bytes): void {
let id = dataSource.context().getString("id")
let subgraphVersionMetadata = new SubgraphVersionMetadata(id)
let subgraphVersionMetadata = new SubgraphVersionMeta(id)
let tryData = json.try_fromBytes(content)
if (tryData.isOk) {
let data = tryData.value.toObject()
Expand All @@ -53,7 +53,7 @@ export function handleSubgraphVersionMetadata(content: Bytes): void {

export function handleGraphAccountMetadata(content: Bytes): void {
let id = dataSource.context().getString("id")
let graphAccountMetadata = new GraphAccountMetadata(id)
let graphAccountMetadata = new GraphAccountMeta(id)
let tryData = json.try_fromBytes(content)
if (tryData.isOk) {
let data = tryData.value.toObject()
Expand Down
6 changes: 3 additions & 3 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ templates:
file: ./src/mappings/ipfs.ts
handler: handleSubgraphMetadata
entities:
- SubgraphMetadata
- SubgraphMeta
abis:
- name: EpochManager
file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json
Expand All @@ -738,7 +738,7 @@ templates:
file: ./src/mappings/ipfs.ts
handler: handleSubgraphVersionMetadata
entities:
- SubgraphVersionMetadata
- SubgraphVersionMeta
abis:
- name: EpochManager
file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json
Expand All @@ -750,7 +750,7 @@ templates:
file: ./src/mappings/ipfs.ts
handler: handleGraphAccountMetadata
entities:
- GraphAccountMetadata
- GraphAccountMeta
abis:
- name: EpochManager
file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json

0 comments on commit 85034c1

Please sign in to comment.