johnny 5
johnny 5

Reputation: 20987

Graphql Filter by query

So I'm trying to learn graphql I've been playing around with the ENS subgraph on the graph

I've figured out how to do simple filtering but when I try to write more complex filters they do not compile.

I'm trying to get the top 5 transactions for the each of the top 5 domains. (e.g for each domain I want the top 5 transactions)

{
  #Sample Query to get the first 5 domains (not needed for question but used to validate results)
  domains(first: 5) {
    id
    name
    labelName
    labelhash
  }

  #attempt to filter the transfer.domain.id by TOP 5 domains.id
  transfers(where: { domain { id: domains(first: 5) { id } } }) {
    id
    domain {
      id
    }
    blockNumber
    transactionID
  }
}

EDIT I'm going to attempt to simplify my request since I'm not sure nesting queries is possible. How can I filter an inner query by Id:

transfers(where: {domain.id: "0x9c0fc2519ae862cee27778e5c34714d6c7e3ca21ad572df47ad9f6fe530909bd"}) {
  id
  domain {
    id
  }
  blockNumber
  transactionID
}

NOTE: Domain.Id = does not compile how would I write a filtered query like that?

However, My filter doesn't compile syntactically. How can I write a query which filters by a child property?

Upvotes: 2

Views: 1723

Answers (1)

codingwith3dv
codingwith3dv

Reputation: 369

You can query like this

query {
  getPost(id: "0x1") {
    title
    text
    datePublished
  }
}

Got this from https://dgraph.io/docs/graphql/queries/search-filtering/

Upvotes: 1

Related Questions