graph-network-subgraph
graph-network-subgraph copied to clipboard
Bug - Schema names incongruent between actual vs. explorer web UI
Overview
Below are 2 examples I found where the schema name of a subgraph are incongruent between the actual subgraph (i.e. what can be queried with a connection) vs. what is shown on the explorer web UI.
Impact
- It makes the subgraph look broken
- It wastes time debugging the issue
Examples
indexers
- URL: https://thegraph.com/explorer/subgraph/graphprotocol/graph-network-mainnet?query=Effective%20cuts
- Web UI: In the "Schema" section, it is noted as
indexer
- Real Connection: requires
indexers
This query will fail
For example, the query below would break, despite it being written to match what is shown on the explorer UI:
indexer_query = gql(
"""
query {
indexer {
id,
stakedTokens,
delegatedStakeRatio
}
}
"""
)
This query will pass
indexer_query = gql(
"""
query {
indexers {
id,
stakedTokens,
delegatedStakeRatio
}
}
"""
)
transactions
- URL: https://thegraph.com/explorer/subgraph/graphprotocol/graph-network-mainnet?query=Effective%20cuts
- Web UI: In the "Schema" section, it is noted as
transaction
- Real Connection: requires
transactions
This query will fail
query = gql(
"""
query {
transaction {
id,
blockNumber
}
}
"""
)
This query will pass
query = gql(
"""
query {
transactions {
id,
blockNumber
}
}
"""
)
Proposal
- Make sure that the schema named found in the Web UI is congruent (==) to what a user would query
- Check all other subgraphs + schemas for similar issues (I only found 2 in a few minutes of working on this, so my assumption is it's a larger issue)
As an additional example, the query below doesn't work:
query = gql(
"""
query {
SignalTransactions {
id,
blockNumber,
timestamp,
signer,
type,
signal,
tokens,
subgraphDeployment,
withdrawalFees
}
}
"""
)
I think most users will try the following due to the WebUI:
- SignalTransactions
- SignalTransaction
The correct schema to use is actually this:
- signalTransactions
Proposal
If congruency between explorer UI and actual schema is not possible at this point, I strongly recommended making sample queries for 100% of the schema pieces to help guide users around the buggy naming
@bordumb
Using the single query indexer
instead of indexers
requires you to specify the id
of the Indexer
entity you want to query, that's why it fails.
This is correct because by default indexers
will return the first 100 results it finds for entities of type Indexer
query {
indexers {
id,
stakedTokens,
delegatedStakeRatio
}
}
This is currently incorrect, because by default it's expecting you to specify which specific entity you want to query
query {
indexer {
id,
stakedTokens,
delegatedStakeRatio
}
}
This is what a correct single query would look:
query {
indexer(id:"0x....") {
id,
stakedTokens,
delegatedStakeRatio
}
}
(of course you will need to replace "0x...." with whatever ID you want to query for, remember to use lowercase strings)
Also queries are expected to not be capitalized, so this is incorrect:
query {
SignalTransactions {
id,
blockNumber,
timestamp,
signer,
type,
signal,
tokens,
subgraphDeployment,
withdrawalFees
}
}
While this would be the correct query
query {
signalTransactions {
id,
blockNumber,
timestamp,
signer,
type,
signal,
tokens,
subgraphDeployment,
withdrawalFees
}
}
(the UI actually autocompletes that)
I don't think it's actually "buggy" naming, those are the actual naming conventions for queries for GraphQL, and their counterparts in the GraphQL schema "language" (which are the entities).